6 kyu
Asteroid Collision
109saudiGuy
Loading description...
Algorithms
Arrays
Lists
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.
Question: In the example ([-2, -1, 1, 2]) ➞ [-2, -1, 1, 2], why don't the -1 and 1 meet and destroy each other?
This comment has been hidden.
I just wanted to see some unique solutions since this is not a performance-based kata. I can remove this line if you want.
This comment has been hidden.
removed
would be good to have in the example/fixed tests:
done.
regarding last point: I think it is necessary to pass a copy. If I use:
then, user can pass all random tests by just
return None
return asteroids
.no, in that case, he cannot. It could happen if the calls were:
summary, either:
or
try:
and initial solution:
oh right, I forgot your solution is mutating the input (bad practice... ;) )
hidden spec, or wrong reference solution. See below:
According to what I understand from the description, those two (7 and -98) should never cross => ?
positive meaning right, negative meaning left.. -98 will destroy 7.
(sec, did I invent an additional spec...? :thinking: )
oh dear... My asteroids move
abs(size)
at most... XDhmmm... Maybe use smaller random sizes? (like between -40 and 40?)
done.
I think the ref solution is wrong:
the 100 vs -100: all asteroids in between should be destroyed, and those 2 as well, shouldn't they? (probably linked to the presence of the 0 in between?)
btw: the random tests are printing stuff to the console.
Corrected now.
Won't generate 0 now.
Asteroids with a value of 0 are assumed to be moving right, this is not specified.
0
shouldn't appear anyway; it's not a valid asteroid.Won't generate 0 now.
.