[Community Puzzle] Porcupine Fever

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

In the community puzzle ā€œPorcupine Feverā€ you are give tuples of input with the number of sick (S), healthy (H) and alive (A) pigs. From my understanding and the input of pretty much all test cases S + H = A. Thatā€™s not the case in test case ā€œDead Farmā€ where a couple of times S + H > A and the only way to clear the validator is to overwrite A with S + H in the input. Is my thinking seriously borked here or is there a problem with the inputs?

1 Like

Yes, there is a problem with the inputs.
Iā€™m not sure how QC is done here, but the creator and/or approvers might be able to fix the problem? @Unihedron, @Wladek

1 Like

Other two approversā€¦ Iā€™m only allowed to mention 2 people at a time right now.

@JBM, @Arglanir

:slight_smile:
I validated that one without even looking at the A count, so yeah, thatā€™s a very plausible issue.
My suggestion would be to do the same; but if youā€™ve got specific cases for me to fix, Iā€™d gladly take care of them too.

Edit: oh wait, there is an explicit test case. Ok, here I go.

Counter-edit: looks like the author fixed already (fifteen minutes ago). Reload and try again?

1 Like

Inputs are correct now. Thanks :wink:

Sorry to have validated that with an error. I did get an error but I thought I had forgotten something in my code, and after a little modification (probably a modification that doesnā€™t use ā€œAā€ directly) all was ok.
I found the redundancy of information a little strange and I should have checked that.

Hey, I fixed that. I crafted the last two test cases ā€œlarge farmsā€ with an automated script, which did not add up numbers properly. I did fix that later for the final test case, but I forgot to regenerate the second to last test case. Itā€™s an embarrassing mistake which should now be fixed. Sorry for the inconvenience and thanks for sticking with it!

1 Like

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

1 Like

I understand now, thanks :slight_smile: 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.