(read-line) not working for clojure puzzles

Hi - I am trying to complete the puzzles using clojure. It seems to me that the calls to (read-line) to obtain stdin input are not working. This makes any puzzle that uses that impossible. Would be great if you could fix it.

More specifically I seem to need to call read-line twice. The second time it is called it behaves as I would expect it to the first time I call it. That seems to give me a work around but still doesn’t seem quite right,

Hello,
Thanks for pointing that out. It’s a problem with how we generate our code. If there is a newline between a (read) and a (read-line), the latter will return a string with just the newline.
In your case, when you are doing 2 read-lines in a row, you a finishing the line you read previously, and then reading the next line.
We’ll correct our Clojure generator shortly.
As a quick fix in the meantime, you could place a (read-line) between (read) & (read-line).

That’s great. I’ll look forward to the fix and use the workaround in the time being. Thanks for the quick response.

Could it be that you fixed the initial problem but the generated code for a puzzle still uses the workaround?
You can try the Onboarding with Clojure code.

The demo code looks like this:
(let [enemy1 (read-line) dist1 (read) enemy2 (read-line) dist2 (read)]

But the variables contain wrong data if I change it to:
 (let [enemy1 (read) dist1 (read) enemy2 (read) dist2 (read)]

Data seems to be loaded correct.

1 Like

You are quite right, we’ll get to work on that promptly. Thanks.

In almost all cases where there is a list to read I replace the wierd boilerplate code by this :

(take N (repeatedly read))

Which returns a list of N element read from stdin

1 Like

That’s it!

wrong:
(let [enemy1 (read-line) dist1 (read) enemy2 (read-line) dist2 (read)]

right:
(let [enemy1 (read) dist1 (read) enemy2 (read) dist2 (read)]

Alternatively use: (repeatedly N read)