Hacker News new | ask | show | jobs
by Kenji 3276 days ago
I jumped into CodeWars.com just to see what it's about. Take a look at this puzzle:

The code does not execute properly. Try to figure out why.

int multiply(int a, char *b) {

  return a b;
}

WTF? Who the hell multiplies a char pointer with an int? Why not just a char? Do I need to multiply the pointer address or the value the pointer points at? Do I need to check for NULL?

Why not write proper code instead of solving these "puzzles"?

1 comments

You can only make an account on the site if you solve a "puzzle" in one of the languages. It's meant to be extremely obvious to programmers but be absolute jargon to anyone else.

Your comment is exactly the point of the puzzle. Change char to int and you gain access.

Nope. It was the multiply sign between a and b that was missing. And a cast of char* to int in the line with the return statement. That was the actual solution. Besides, I have no intention of joining this site because the real world poses enough actual puzzles that are worth solving.