2048 Scores


#1

Sorry if this question has been posted elsewhere, but I’m working on a functional approach to the 2048 Scores puzzle. I’m pretty much done with the logic but upon testing I am failing the basic tests even though my output should be correct.

When I output the correct answer the tests say they found “Nothing”.

I tried hardcoding the answer, but when I do that it changes the answer it’s expecting to an incorrect answer. Really not sure why it’s behaving this way, but I’d love a little advice.Thanks!


#2

Which language? Have you tried to compile/run your code locally? Are you sure to understand how the I/O of your language work (the simplest explanation to a failing hardcoded solution is that something is not printed correctly)?


#3

Thanks for the reply. I’m using javascript, and yes it works locally when run through a node terminal.
For the first test case hardcoding console.log(“2”), results in a failure (found “2”, expecting “4”). Hardcoding console.log(“4”) also results in a failure (found Nothing, expecting “2”), even though the output is clearly displayed in the terminal.


#4

Well, the expected output (to the example) is:

4
2

and the following hardcoded solution passes:

console.log("4\n2");

#5

Ahh, I’m dumb! Totally missed the turns output parameter requirement. Feels bad.

Thank you for the help!