5 kyu
The Hunger Games - Zoo Disaster!
496 of 2,770dinglemouse
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
there are 11 animals but
Map.of()
only goes up to 10 entries. Coincidence ? I think not...But it is.
Don't lions eat sheep???
These lions are fussy. They don't eat chickens or pandas either.
Why is there no dinglemouse in the zoo? And what would it eat?
Because I have eluded capture so far...
If caged I would have to eat crow.
Random tests are terribly noisy. They should not print to stdout, and context information should be provided with titles of tests and/or with failure mesages.
Loved this one. One of the best kyus i'v done in a while. Easy to understand what needs to be done. 0 Maths. Text formatting was a bit annoying tho. But probably a bit too easy for 5.
Go approved... still looking at the other one
...And Rust approved. Thanks!
COBOL translation.
Approved :-)
how do i get the animal list (python)
the list or dictionary of who eats who
This comment has been hidden.
I dont understand what the output is supposed to be (Python)
You have an example in the description. You can also look the sample tests in the trainer (the output is
expected
).did it thank you. the initial return statement given is very misleading tho
Ahhh... That was fun, incredibly enjoyable. Loved this kata!
Always so many small teaching parts in your Katas! :) I did so far enjoy all of them!
Thanks :-)
There is a new C++ translation up for review.
src/Solution.cs(6,46): error CS8652: The feature 'target-typed object creation' is currently in Preview and unsupported. To use Preview features, use the 'preview' language version. src/Solution.cs(42,22): error CS8652: The feature 'or pattern' is currently in Preview and unsupported. To use Preview features, use the 'preview' language version.
:(
This kata was very fun, but, for me, the formated string result was such a big pain, you've got no ideea. Why can't I just print the remaining animals after each step? Anyways, great, fun kata.
"lion,chicken,cow".... nothing happen, the chicken protect the cow from the lion ?! xD
It's a very fierce chicken xD
Cowardly lion.
(Haskell):
When I try to run the Test suite (not Attempt) I get an error:
It looks like the module is named
ZooKeeping
, but the tests try to importZoo
. Updating the tests to importZooKeeping
fixes the error.@dinglemouse
Haskell update here
issue
)(maybe the test gen needs further attention, maybe I should go read the original translation and match it. atm it can generate multiple of the same animal, not sure if it's supposed to do that or what it's supposed to do in general ..)
testcases can be viewed/sanity checked by modifying the Solution and then running the tests:
adding
import Debug.Trace
and modifying the solution's first line to:and error messages can be viewed by changing the same line to:
Glorious! A+ effort, thanks.
Ehhh. Unpublishing that update while I go sleep. My solution doesn't agree with the original reference solution when there are duplicates (is the input allowed to have duplicates?) And I'm not sufficiently awake to get to the root of that whole situation. Also I should probably rewrite the test gen to match the original.
Published it again.
Approved.
Solved this using a recursive function. Does this qualify as best practice?
It qualifies recursion practice ;-)
Thank you very much for authoring these kind of katas! They are so much more fun to solve than lot's of the other katas just because of the "story".
Compliments are always welcome. Thanks!
Try them all here: https://www.codewars.com/collections/dinglemouse
DM
thanks for this kata, i feel dumb when i compare my solution to others, good ;)
at least, got good practice ^_^!
let's give the food chain at the entrance. What's the point of typing it manually?
Sorry for your typing. I hope there are many interesting and varied solutions for this Kata, so I certainly do not what to influence/restrict those by specifying input in some particular way. I prefer if each code warrior just does what they think is best.
I agree with you, this does not limit our choice! However, in my opinion, it would be slightly better if the text from the condition was passed as the third argument in the function. Then it would be possible to loop through it and create the necessary dictionary or list ... we are programmers after all :) And thanks for Kata!
Leaving it as is will give more variety of solutions. Good and Bad.
Bottom line. With 1300+ solution already, I won't be changing this Kata.
But thanks for the feedback - I will keep it in mind for future Kata :-)
Nice KATA. But the instruction should be more thorough and give some details what should be an output in case of extraordinary inputs e.g. if input string is empty - why the output should contain 2 empty strings instead of three. How can we guess that. This should be specified in instruction. The same is concerning two consecutive operations(eatings) e.g. what if we have two bears and they eat the same ( one after the other) - should it be returned one time only (?) or we should treat that as two separate eatings even though they are the same.
Ufff.. anyway I eventually solved it and the idea of Kata , I must admit, is very nice. Cheers!
This comment has been hidden.
Just forgot to add that I used C#.
What is the error that you're getting?
I got following error: Test Failed Expected: < "fox,bug,chicken,grass,sheep", "chicken eats bug", "fox eats chicken", "sheep eats grass", "fox eats sheep", "fox" > But was: null
Is your function returning?
Yes, in visual studio I got the correct answer for the test string. In my solution there is a reccurency and the final list is out of the function block but I believe it is not an issue. Looks like the codewars test is not working with reccurency , I don't now . I am not so experience with codewars - I have just completed 12 Katas so far but this is the first time I used reccurency.
Did you mean recursion?, and it is probably the problem, make sure you return the call, not only calling the function.
Yes I meant recursion . So that means that in coedwars to pass the tests I cannot use recursion by returning another call to the same function? Correct? If so I will try to solve this case by adding another loop.
No, it means you have to return the call, not only call the function. I can't tell what the problem is without seeing your code, so I'm only guessing here.
You can use recursion if problem allows it, but what Chrono meant here is that your recursive solution is probably not structured correctly. It's difficult to tell without seeing your code, but whenever similar problem pops up for some newbie, the most common reason is that they do not return the result of recursive call and ignore it, because they think that just calling the function recursively is enough and ignore the result of the inner call.
We believe that your problem is similar, but as I said, it's just guessing.
This comment has been hidden.
No, you didn't. See the line before
return null;
you should be returning that instead.Yes, you are right. I corrected as you said and it works now. But why the hell it worked in VisualStudio. Before the null ss returned the function was recalled so the function should execute anyway. Anyway thanks a lot for assistance.
Love it! Thanks for creating this Kata
I cannot get past this test. I have passed 9 out of 10 but this I fail. (Python) Why does my bear eat them all? :)
['bear,grass,grass,grass,grass,sheep,bug,chicken,little-fish,little-fish,little-fish,little-fish,big-fish,big-fish,big-fish', 'sheep eats grass', 'sheep eats grass', 'sheep eats grass', 'sheep eats grass', 'bear eats sheep', 'bear eats bug', 'bear eats chicken', 'bear eats little-fish', 'bear eats little-fish', 'bear eats little-fish', 'bear eats little-fish', 'bear eats big-fish', 'bear eats big-fish', 'bear eats big-fish', 'bear'] should equal ['bear,grass,grass,grass,grass,sheep,bug,chicken,little-fish,little-fish,little-fish,little-fish,big-fish,big-fish,big-fish', 'sheep eats grass', 'sheep eats grass', 'sheep eats grass', 'sheep eats grass', 'bear eats sheep', 'bear eats bug', 'bear eats chicken','big-fish eats little-fish', 'big-fish eats little-fish', 'big-fish eats little-fish', 'big-fish eats little-fish', 'bear eats big-fish','bear eats big-fish', 'bear eats big-fish', 'bear']
As I have read the rules again I think that my solution was good. 'Always the LEFTMOST animal capable of eating will eat before any others.' May I post my code here?
Try reading again this part - " list of zoo animals, and what they can eat"
Bears do NOT eat little-fish.
TY. I solved it. My bear was too hungry.
This was a realy awesome kata, loved it!
:-)
The Haskell check of the solution for this task is broken: "the module Zoo is missing." So I can not "attempt" my solution, although the "run sample tests" is successfull.
I had the same problem. As a workaround: you can change name the module you wrote from ZooKeeper to Zoo.
I feel like my grandmother even mentioning this but, "who eats who" should be "who eats whom". Fun Kata though :).
Fixed. Thanks Grandma!
Fresh :)
i was a bit confused with the output section of this kata. given an empty input, i expected the expected output would be two empty strings - the tests, however, only expect one empty strign to be returned if an empty string is given as input. IMO this could use with a touch up ;)
And in my original Java Kata, it is just like you thought it should be...
Which language are you referring to where this is not the case? It might be a bug in a translation. Thanks
I am talking about C#. Sorry, i should have stated that.
You are correct. There is a bug in the C# translation. I've asked the translator to fix it. Thanks for reporting!
Very good kata "story", thanks a lot !
Very good kata. I felt like you needed a solid understanding of several fundamentals to pass.
Glad you liked it. Cheers :-)
The method should be called 'whoEatsWhom'
#sorrynotsorry
touché!
Very good kata, many fundamentals are neccesary to pass this one.
Thanks for kind comments :-)
@Dinglemouse I always find your awesome animal-related katas 10 min before bedtime, try and brain them out a bit and then I dream the weirdest cr4p - last time it was ants bridge and I dreamt I was teaching them switch statements in god!amn PHP ;( Will leave this one for tomorrow! Anyway, point of this comment being: great job with your katas, I find them incredibly enjoyable :)
@arfro. LOL. Thanks for you comment.
FYI - They have exactly same effect on me, but I dream them first and then I make them.
More animal Katas are in the pipeline... stay tuned.
:-)
C# translation added!
Hi @joesmith100,
Can you please fix the C# translation.
There is bug for empty input (reported in the recent discourse)
Currently the test case look like below (which conflicts the Kata description and my original Java Kata)
But it should look like this (and your solution to change accordingly)
This comment has been hidden.
No. You might want to read the desciption again..
This comment has been hidden.
FYI - The best place for help with a specific problem might be here: https://gitter.im/Codewars/codewars.com/kata-solving-help
DM
This comment has been hidden.
The tests are not big but there are 500 random test cases.
Perhaps your solution has excessive looping?
while
(containsEdible(...)for
{ ... }, and containsEdible(...) itself is alsofor
insidefor
I think (guessing) your containsEdible might be an area to look at. Consider if there is easier way to decide to break from the main
while
loop.A unique and fun kata, thanks
Cheers for your kind comment :-)
python translation! ;)
Approved!
Thanks :-)
Was ranked between 5 and 6kyu... i think Voile needs some last points to 1dan, so approved as 5kyu:-)... Happy Hunger Games...
Thanks Dad!
:-)
Not that a 6 to 5kyu difference would have a visible difference to
1dan
progress though :PI usually approve katas according to average rank unless it's really inaccurate, so given this is voted 5kyu in average I'd choose 5kyu if I were approving this kata.
@Voile: Yes... but there are 2 averages, so which do you choose, higher or lower;-)? Maybe i should rank it 1kyu and your 1dan progress is completed;-)? @dinglemouse: i don't think that this is your real photo, seems to me it's a fake;-)?!
@smile67. Nope, that's really me!
You can tell it's real, because if it wasn't my head would be photo-shopped onto some old body to show off my new shirt.
That was fun! :]
zoo
should have been anArray
of course, but that must not be changed any more. And why return the original input as the first output? Afraid you'd forget? :yum:Thanks :-)
Maybe.
I was thinking it may make it easier to debug if ever somebody claims a random test is wrong.
That's a valid point, actually.
ADVERT
When all the animals are eating each other that is what I call a Zoo Disaster!
\o/
this will be my evening relaxation task for today... :)
Get a JS translation done and I'll finish this in 10 minutes with an upvote :)
@Voile Voila :-)
Done!
Took me 15 minutes because I'm coding on a mobile phone :P
Great! Now where's the promised upvote?
Sorry, just went home :)
Upvoted and ranked :D