7 kyu
Will you survive the zombie onslaught?
87 of 2,267Captain_Howdy
Loading description...
Games
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.
I've got a trouble: passed all tests, but click "Attempt" andit says the following:
expected:<[You shot all 0 zombies.]> but was:<[]> expected:<You shot [all 20 zombies].> but was:<You shot [20 zombies before being eaten: overwhelmed].>
What might it be?
It might be a bug in your solution.
Hard to tell.
It might be that the code inside your loop is not executed, so it returns an empty string. Print the input to see why.
why would you neeed to know exactly how you die by the zombie onslaught?
So any survivors know what to put on your gravestone?
Impossible to complete. I'm getting an error even when the function includes nothing but an empty string. Should be removed or corrected.
fixed, dont forget to reset the tests
@trashy_incel you don't have to reset everything. You can simply enclose the backward-compatibility with a
try...catch
block to prevent it from producing an error.This works: https://www.codewars.com/kata/52250aca906b0c28f80003a1/discuss#615857431274ac0029ce229c
i had simply forgotten about variable hoisting, how embarassing >~< it should be OK now, sorry for the inconvenience
I get different ammount of failed cases each test
That's not surprising, attempt tests are random.
Thanks, i didn't know that
This comment has been hidden.
This situation should be covered by the line: (If you run out of ammo at the same time as the remaining zombies reach you, return "You shot X zombies before being eaten: overwhelmed.".)
closed
C translation: should include fixed test case -> zombies==100 and distance==10 and ammo==20
C translation with more tests.
@geans once one of your translations has been accepted, you unlock the possibility of editing the kata. this is better than making a new translation
C++ translation
Approved by someone.
C translation
How to write to a string in C?
Hello Thomas Bucaioni! This question is best suited for sites like stackoverflow.
Good idea, cheers
Approved by someone.
JavaScript function name should be in
camelCase
. Is it too late to change it now?Feel free to change it with backward compatibility
Umm, how do I do that?
I forgot thoo but u can refer to Donald's reply on one of your comments ^^
done, with backwards compatibility
I think you broke it. See the issue above.
Nice, pretty fun kata.
Please use new python test framework.
Fixed
if(zombies==100 and distance==10 and ammo==20)... the function returns:'You shot 20 zombies before being eaten: overwhelmed.'
Am I wrong in thinking the "reason" was loss of ammo? there are 20 shots fire. One at each whole second, 1 through 10. One at each half second, 0.5 through 9.5. So when the zombies arrive, we are out of ammo. Or, does overwhelmed encompass any situation where it is impossible to kill all the zombies even if we had infinite bullets.
That was pretty much it: in my mind "out of ammo" was the situation where you have run out of ammo and are just waiting for the zombies to get to you.
The description is not clear about what is in your mind. Also, not all languages test this edge case.
(If you run out of ammo at the same time as the remaining zombies reach you, return "You shot X zombies before being eaten: overwhelmed.".)
that is in the details, i think in the case mentioned you run out for ammo at the same time zobies reach you, since you need to mutiply range by 2 because zombies move 0.5 meters
My solution works as expected on my machine but it's a different case on here.
That's because your foreign environment doesn't have all the correct tests. it's best to remain on CW for that reason.
Are you by any chance printing instead of returning the result?
I am able to pass all tests but one. I'm getting a Comparison Failure error and according to the stack trace, its occurring on line 21 of the fixed tests. Can you tell me the values of the variables are for that test so I can figure out whats going on?
you can print them at the beginning of your function, match them to the error messages to debug
This comment has been hidden.
the description now mentions this edge case
I dont get it. What's the difference between my outcome and required? I've tryed adding qutes inside the string and changing format of number of zombies to string and integer ( like so {str(zombies)}), and it still doesn't pass the tests. Below I've pasted my outcome:
Log
You shot all 3 zombies.
None should equal 'You shot all 3 zombies.'
Log
You shot 16 zombies before being eaten: overwhelmed.
None should equal 'You shot 16 zombies before being eaten: overwhelmed.'
Log
You shot 8 zombies before being eaten: ran out of ammo
None should equal 'You shot 8 zombies before being eaten: ran out of ammo.'
You're printing your results, rather than returning them.
That was it, thanks.
I'm getting some strange 'failed' messages (100 of them):
'You shot all 8 zombies.' should equal 'You shot 7.74072034845198 zombies before being eaten: ran out of ammo.'
I'm afraid I've not been able to reproduce this so far. I'll keep trying.
All arguments are floats...
This comment has been hidden.
I've ensured that all the values in the random tests are ints - are you still experiencing this issue?
The parameter name shadows a built-in in Python.
I'll get right on it :)
"range" changed to "distance".
Nothing's changed.
Missed a few before, but I think I've caught them all now.
Java translation
Looks good to me!
Hi,
Your description is lacking some specifics. Especially the precedence of the different operations:
Thanks for the feedback: I'll update the description.
Being picky, add reloading takes no time for simplicity.
Description updated.
wrong: you couldn't run out of ammo, in that case ;p => rather say it's an automatic rifle
enormous magazine != full
it still can have only a few bullets in it.well, sounds confusing, still.
Automatic rifle or machine gun as an improvement is fine by me.
To avoid confusion, I'll just say we're ignoring any reloading time :)
sounds good too
What's the expected answer for zombies = 2, range = 1 and ammo >= 2?
All the zombies get shot. See: Test.assert_equals(zombie_shootout(20, 10, 20), "You shot all 20 zombies.")
Ok, thanks.
No edge cases tested where different combinations of
zombies
,range * 2
, andammo
result in the same value.Doesn't the following test do that, or am I misunderstanding?
Test.assert_equals(zombie_shootout(20, 10, 20), "You shot all 20 zombies.")
That's only the case for
zombies == range * 2 == ammo
, but not for:zombies > (range * 2 == ammo)
zombies < (range * 2 == ammo)
ammo > (range * 2 == zombies)
ammo < (range * 2 == zombies)
range * 2 > (zombies == ammo)
range * 2 < (zombies == ammo)
Added tests for the above.
No random tests.
Random tests added.
There should be more than 3 tests, and with the current setup they are as good as not random at all.
More random tests added, and they're much more random now.
Input validation is more annoying than anything, and should be removed.
No problem, will do!