[BUG] Clojure : bad input value for Winamax Sponsored Challenge

The Winamax Sponsored Challenge doesn’t work with Clojure. Even when I use the auto-generated code I get exceptions when running the second testcase.
An exception is thrown right at the start of the second test case.

The issue seems to be coming from input value such as 5C. The read function tries to interpret it as an number (because it start with a number) but fails because of the C that follows.
As I understand to, 5C should be provided with surrounding double quote (“5C”) , or as separated values (5 then C).


PS: Coding is awesome. Keep up the good work :slightly_smiling:

1 Like

For some reason, I am limited to C++/Java/Javascript/Python3/C/Go/PHP/Python/Ruby on that puzzle. That said, you should not need the quotes to parse it as a string. If some operation pushes the interpreter to try and cast to a number, use (str (read)) to force the right type at initialization.

Thanks for your feedback Yoha.

Unfortunately, the error is triggered within the read function, so before str had a chance to cast it to a string.
I tried with a REPL : type (read), then input 5C (without double quote). Got the same exception error.

At this point, I do not see any solution to make it work on user side.

Thanks again.

Well I finally managed to solve it by wrapping a (try catch) form around the read function.
Quite ugly, but it works. I now get all the inputs correctly and I can focus on solving the puzzle itself.

1 Like

torleif, when you entered the puzzle, were the selected language Clojure, or did you chose it afterward?
I ask you that because Clojure shouldn’t be available for that puzzle so it may be interesting for the team to know that.

On a side note, when I go on AI bots challenge I did not played (PR, PR2, PCR), clojure is already selected. Though it might be a coincidence since there is a possibility that I changed the language on these puzzle to Clojure for testing purpose.


As far as I remember, Clojure was the selected language. I’m doing all the puzzles in clojure only.

Am I allowed to complete it anyway? Already got the first two test cases working :slightly_smiling:

1 Like

I’d suppose finishing the puzzle in Clojure wouldn’t really be a problem as long as you don’t apply to a job at winamax, but only someone from the team like @MaximeC can answer you.


Here is a nice way to do it without try/catch.

(with-in-str "5C\n"
  (let [card (read-line)]
    (vector (- (int (first card)) (int \0)) (second card))))
;; => [5 \C]

This way you get a number and a character for each card. The with-in-str is just so you can test it on the REPL.

You might want to take a look at this thread:

1 Like

Thanks for this chrm, very interesting.
I came to the same conclusion that read is trying to recognize the input as a valid syntax (being a form, a function, a number…), but your explanations make more sense. :slightly_smiling: