It says the output must be “Y or fewer lines of integers of porcupines alive.”. Putting aside how weird that sentence sounds, it just doesn’t match up with the example output.
The Y input is 3, but then all of the outputs are integers way higher than 3.
From what I understand (through some mental gymnastics, admittedly) is that I’m supposed to output how many porcupines are left alive between all the cages after the years pass. For the first test case, I’m supposed to output 168.
So, I tweaked my algorithm, and had 168 outputted. But then I get a failure message, saying it found nothing while expecting 164 (despite the output stream clearly having 168). After I uncomment the line that did the output, it then says it expected 168.
I’d really appreciate help understanding this puzzle, and why I’ve been getting that first failure notice I mentioned.
Output ‘Y or fewer lines’ means that you have to output at most Y number of lines, where Y is the variable indicating the number of years. This is because of the restriction ‘(do not repeat "0"s after the first time)’.
Essentially the requested output is the number of porcupines left alive at the end of every year. The first line of the output is the number left alive at the end of the first year, the second line is for the second year and so on. The output ceases once 0 porcupines are left regardless of the value of Y.
You are getting a failure notice since 3 lines of integers are expected in the output, namely 168,164 and 156. The console output will read your first line and compare it to the expected output, then read the second line and compare and so on. Since your first line of 168 was correct, it continued to read your second line, which you did not output. So the failure message popped out saying that it expected 164 but found nothing
I understand now, thanks I solved the puzzle.
“[…] saying it found nothing while expecting 164 […]”
Codingame (for some weird reason) shows the diff on a per-line basis. The comparison that’s done is on line 2 where 164 is on the second line for the expected output but empty (hence “nothing”) on your actual output. More specifically, “168[LineFeed]” is the part that’s matched, “[EndOfFile]” is the remainder of your output, “164[…]” is the remainder of the expected output.
So there’s that.
It’s unfortunate that I had to use the phrase “Y or fewer lines” - I had previously considered “At most Y lines” and “Up to Y lines” but I was not satisfied with all three of them. In the end I had to rewrite the entire sentence, breaking down the two-part segment into one single sentence. If you can suggest better wording for it now that you understand what I was trying to say, please let me know. Admittedly my english is not very good.
I think understand. Also, I suggest changing the wording to “Y or fewer lines of integers, each being how many porcupines are alive at the end of their respective years.”. It’s a bit wordy, but it gets the intent a lot clearer, which is what really matters.