7 kyu
Party People
300 of 467saudiGuy
Loading description...
Algorithms
Arrays
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.
Help Execution Timed Out (12000 ms)
Issue
tag is for the issues with a kata, such as broken test cases, incorrect descriptions etc. Next time please post aQuestion
.spoiler
flag, it is a guesswork to try to help you. Looking how there is noperformance
tag and my first naive solution passed in 2500 ms, my guess is you got infinite loop somewhere in your code.While there is no
performance
, the input constraints are mentioned in description. With 10^5 input, the expected time complexity should be less than O(n^2). Your code looks to have O(n^2) because of operations like.splice
or.indexOf
nested in a loop.However, there was an issue raised about it below and seemingly O(n^2) should be accepted now? Maybe there are some inconsistencies between tests of different languages, that's up to the author to clarify.
Я потратила на это 3 часа, но это того стоило
Пожалуйста!
JavaScript translation
approved
I think you forgot to take in to account Pete only stays if he is alone. test.assert_equals(party_people([2, 1, 2, 0]), 4) #this was in the test section If Petes only stays if he is alone he would leave and the output should be 3
Pete stays if there is at least one person at the party. At most one is not part of the condition.
"However, Ava and Sheila are only staying if there are at least 4 people, Pete is only staying if there's 1 person, and Mark is only staying if there are at least 5 people. Therefore, Mark leaves, which makes Ava and Sheila leave, and Pete is left alone."
Better? ( This was always the intention. )
ETA: it didn't actually say "exactly one person," and two people include one person, but I see the confusion.
perfect hahahahaahah
LC translation
this translation updates the description. please approve Haskell first.
approved
Haskell translation
approved.
Why not use integers?Forget it.Kata, Haskell programs in general, and Haskell itself, use
Int
wherever, sometimes inappropriately. If negative values are not an option,Word
is the better datatype. Some time ago I decided to useWord
more often, even if I have to cast values for use invectorOf
( which is, of course, completely ridiculous. it's not like a negative length is an option there ). It does mean QuickCheck generates better random data more automatically, so I win some, I lose some. On balance, I prefer to do some casting but use more ( better ) descriptive datatypes.This comment has been hidden.
This comment has been hidden.
It was an issue. I forget to close it after modification.
This comment has been hidden.
done.
tests::easy_random_tests
in Rust generated[19, 3, 13, 6, 7, 11, 20, 16, 0, 14, 6, 2, 6, 12, 5]
and expected result 8 whereas the correct result is 3.Are you sure? The author's solution (in Python, Rust's one is its direct implementation) and mine in Python give 8 for this input.
This comment has been hidden.
Your reasoning is wrong.
I will add now this example in Rust fixed tests. I suggest to do the same in Python.
added.
This comment has been hidden.
Rust translation
approved.
There is a
performance
tag, butO(n^2)
solutions can pass just as well asO(n*log(n))
solutions. You need to decide whether this is desired before approval.removed now.
I don't see the performance constraints. Are you sure the tag is relevant here?
removed now.