[Community puzzles] The barnyard

Stephane, note that the solutions’ position might vary rows and when doing the upper triangular matrix, you should take care of the cases, when there is an empty column.

Agreed, the example is wrong. Please fix. :slightly_smiling:

My problem was that I did not output solution (animal, value) in the same order that animals appeared in input.

Solved it yesterday with a recursive bruteforce.

Someone needs to fix the problem description. It says

“You are given a list of the species that you have and the total number of heads, horns, legs, wings and eyes.”

This second part of this is not true. You are given only n of these totals (where n is the number of species). The rest are left unknown (at least initially).

It might also make sense to point out this means that the problem has a unique solution only for certain inputs. (Presumably all the test cases have a unique solution? Or if the solution is not unique, are we expected to provide any correct solution? All the correct solutions?)

As a newcomer to CodinGame, I have to say I’m unimpressed by that level of sloppiness in the problem specification.

Thats not really sloppiness, the puzzle has been modified a few time after it was released, but the sample did not change.

As it is taken automatically from first test case, I’m not sure the moderators can now edit it simply.

[Edit] Oops, not talking of the same thing

The Input section of the puzzle description mentions that N lines with trait counts are given. Also there is Example input/output, where it can be seen.

As for sloppiness complaints, and questions about solutions. Puzzle description provides enough information to figure everything out by yourself. I’d say the specifications for the problems here are as good as they come in the real world. In case you are unimpressed with real world, well… tough luck.

Yes, I’ve noticed a huge demand for programmers who can’t even state a simple problem clearly. After all, you can be sure their programs exhibit exactly the desired/correct behavior in all those cases they weren’t able to properly articulate in the initial spec.

I wrote the puzzle but someone modified a bit the description.
There were initially no first line with the number of animals.
I even opened a thread to edit this glitch but you seem not to know exactly what’s going on here so please, before flaming everyone, please read and dig your hole as everyone here did before you.

The problem is, it’s not programmers who state problems to programmers. Most of the time it’s either people without any programming experience, or not people at all, but some real world circumstances that have to be resolved. It’s programmer’s job to clarify or even outright define the specifications.
A programmer who can only solve perfectly specified problems has no use in real world.

If you like perfectly done specs, you should try the CodinGame Sponsored Challenge puzzle :smiley:

2 Likes

“It’s programmer’s job to clarify or even outright define the specifications.”

If someone points out a bug in one of my programs, I consider she’s doing me a favor and I fix it. Similarly, if someone points out a mistake in the specification…

I wouldn’t go so far as to say “A programmer who can’t provide a good spec for even a simple problem has no use in the real world.” But I would say she has some room for improvement.

“If you like perfectly done specs, you should try the CodinGame Sponsored Challenge puzzle”

Hi Satine,

I do, and I will but I want to try Game of Drones first. I’m just learning Python so it might be a bit of a slow process.

That was kinda a joke, this Challenge is just “Try to guess what the puzzle is about, and do your best to solve it” :slightly_smiling:

But you didn’t point out a bug. You used it as an excuse to bathe us in your condescending and tell us how amazingly unimpressed you are with the site.

Started this puzzle and this is the first time I’ve found such an incomplete, even misleading, description in a CodingGame puzzle :frowning:
Too bad as the puzzle is a complicated one.

Indeed the initial code has been updated, but not the example :-/

Also, one crucial sentence is misleading :

You are given a list of the species that you have and the total number of heads, horns, legs, wings and eyes.

Actually, the detailled total number is NOT given has some organs are (voluntary it seems) missing.
For instance, in the sample, “Eyes” total is NOT given, despite Rabbits and Chickens having 2 eyes each.
This highly complicate the solution. Which is fun and a great challenge for sure.

But the description quality is not up to what can be seen in other CG challenges & puzzles.

I’ve coded a whole solution until realization that “Eyes” were missing from the sample. Sniff :angry:
The sentence is misleading in my option.

Hi, I have not solved a puzzle like this before and would like to learn how. Is this based on a particular algorithm or methodology? Could someone point me in the direction on what I should learn in order to solve this please - thanks :slight_smile:

This puzzle can be seen as a system of linear equations.

You can (as i did) solve it by Gaussian elimination.

May seems a bit complicated, but if you spend some time thinking before coding it is almost possible to solve it without a headache :upside_down_face:

Woohoo. Took me some time and experimenting but finally I could solve this one. Thanks for creating it, @nicola :slight_smile:

The lazy way (the one I chose ^^):
Use a linear algebra module, Python’s numpy.linalg for example.

More interesting ways listed here:

  • Gaussian elimination, as said above,
  • Cramer’s rule (requires an implementation of Determinant)
  • Matrix Inversion (for example you can use the formula with adjugate matrix, you’ll need to implement Determinant, Adjugate Matrix, Matrix Product)
1 Like