Benesh
  • Member for 7 years, 10 months
  • Last seen more than 2 years ago
Streamlined for-loop for comparing two lists
Accepted answer
9 votes

Your solution's time complexity is O(n2), which is far from optimal. Your lists contain 19 elements - so your solution performs an order of 361 operations. In order to get a linear solution, you can ...

View answer
Conditionals validation for Tic Tac Toe
8 votes

Start with replacing common code with function calls. For example, you can create a method for checking if an entire row has the same text: bool checkRow(int row) { int col = row*3; return ...

View answer
Poor AI for 2048 written in Haskell
Accepted answer
7 votes

First of all - way to go! Type signatures, pattern matching, monads - you're clearly on the right track. Some general tips: Don't reinvent the wheel! When you encounter a function that looks like ...

View answer
Can this recursive binary search in C be made more concise?
6 votes

Your solution combines iteration and recursion, which means that a lot of unnecessary work is done. Normally you'll want to choose only one method. A simple iterative version: int re_search(int ...

View answer
Finding the next higher digital permutation of a number
5 votes

First of all: your code is very readable and you seem to know your way around standard library functions, which is very important is Haskell. Good job! A couple of suggestions: A simpler ...

View answer
Basic Pokedex using if-else statements
5 votes

About nested if statements: void f() { if(cond1) { ... } else if(cond2) { ... } else { } } Can be rewritten as: void f() { if(cond1) ...

View answer
Enumerating a boolean in C
Accepted answer
4 votes

Well, according to the ANSI book: The identifiers in an enumerator list are declared as constants of type int So the cast is redundant: typedef enum { true = ~0, false = 0 } bool; Also, ...

View answer
Cryptographic Extensions
1 votes

You code is readable, your names are meaningful and it seems like you know your way around C#. Keep up the good work :) Some general non-crypto C# comments: using blocks Your using using a lot and ...

View answer