[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.