5 kyu
3-2-1 Fire!
65Dr Gabo
Loading description...
Games
Algorithms
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.
Why? There aren't coordinates in the interface of the function.
m = [ 'AvB', '>E<', 'C^D' ]
Maybe "E" must be hit 4 times here?
you don't care about the number of hits. Just the targets that have been hit.
Are you sure? Because there are many tests with double strike like this:
+------+ | C | |v A A| | | |\ <| +------+ ['A', 'C'] should equal ['A', 'A', 'C']
They're different objects, but they can have the same ID.
+----------+ |>A B<| | / D | | D B | => All enemies are defeated: ['A', 'B', 'B', 'D', 'D'] (Notice the repeated enemies) | | |\ < > /| +----------+
And there's 2
B
s andD
s on the map, and they're both hit, so it's all correct.You are right! Thank you!
mmh, I forgot about that subtlety. You didn't pay enough attention to this requirement:
(edit: seems I'm a little late... x) )
I think this kata also should have a tag 'game' since It's game-ish and fun
Apologies if dumb question, but I don't see where it's explained. Say we got a sample test:
So then the top battleship shoots:
How do I know whether the other spaceship below gonna reflect up or down? Can they shoot many times, and I have to check both options? I don't really see that info in description.
you have to try each laser one by one.
it will reflect both ways
only one time but it will expand as it catches front of other laser
yes
they do both systematically
you should add those 2 fixed tests: I bet a lot of implementation could fail them (surely they show up in the random tests, but it's better to have them in the fixed ones):
You are most probably right. I added those two cases as you suggested.
btw, do you have something like this, in your tests?
a map with this should be added in the fixed tests too.
I added this new one you suggested and this one:
still not good:
Note: what about using chars instead of numbers? (in the output)(I just saw your answer)EDIT: about the chars, if they are all unique, you can go back to a set as output x)
It was a small indentation problem in the code xD. It's fixed now.
:+1: all good!
thx for this nice kata! (just what I needed at the moment :) )
Ok, that's not an edge case missing, that's a problem in your solution: seem like your lasers are trversing the ships:
confirmed. ;p
That is already fixed, I noticed that while working on the other issue :)
Hi,
Seems a nice one, once again!
There is a problem with the kind of output, tho: it should be a sorted list (or a list that you sort during the tests), not a set, especially if there can be multiple identical numbers. Asking for a set is opening the door to incomplete solutions to pass the tests.
cheers
EDIT: x) hummmm... I see why you did that, now. x) But it really should be a list ;p
in addition, that would really ease the debugging, because... this...:
is a nightmare... x)
notes:
It should be fixed now (with sorted lists)!
(Forgot to close)
Edit: the chars are a good idea, I'll implement it.
Now enemies are uppercase letters and the tests are a little bit easier to follow (in the end, they are random :S). You may want to modify your solution.