XSquared
--------
Beginner
--------
Summary: Almost an exact match for my test function. Nicely done.
Code Review:
Code:
long double digRev( int val )
{
long double newNum = 0;
while( val != 0 ) {
newNum *= 10;
newNum += ( val % 10 );
val /= 10;
}
return newNum;
}
Scores:
Correctness: 10
Speed: 10
Elegance: 10
Portability: 10
Intermediate
------------
Summary: XSquared made the connection and solved the problem. Well done! I modified it to run as a function for easier testing. The original was a main function.
Code Review:
Code:
int stickLen( void )
{
int sticks[ 8 ];
int i;
sticks[ 0 ] = 1;
sticks[ 1 ] = 1;
for( i = 2; i < 8; i++ ) {
sticks[ i ] = sticks[ i - 1 ] + sticks[ i - 2 ];
}
return sticks[ 7 ];
}
Scores:
Correctness: 10
Speed: 10
Elegance: 10 (Hard coded values, but I can let that slide)
Portability: 10
Advanced
--------
Summary: Works well, doesn't match up to the speed of other entries and not even close to the test function, but still a nice piece of work.
Code Review:
Code:
char findFirstNonRepeat( char *s )
{
int charCounts[ 256 ] = { 0 };
int i = 0;
while( *s != '\0' ) {
charCounts[ (*s) ]++;
i++;
s++;
}
s -= i;
while( *s != '\0' ) {
if( 1 == charCounts[ (*s) ] ) return *s;
*s++;
}
return '\0';
}
The first problem is the same with everyone's entry. Assuming that a char can hold 256 values. Aside from that the code is correct and easy to follow.
Scores:
Correctness: 10 (Works great)
Speed: 5 (Nothing extraordinary)
Elegance: 8 (Well written)
Portability: 9 (One unwarranted assumption)