6 kyu
T.T.T.44: A game of Grab the "red envelope"(抢红包游戏)
Loading description...
Puzzles
Games
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.
Manage to come across this kata during CNY eve,which is a blessing for the upcoming year!
PS: ~~~ 新年快乐 恭喜发财 红包拿来 (❁´◡`❁) 🐇👲🧧
恭贺新禧
I don't think any of the tests is correct in this kata:
Currently the fixed tests and the reference solution expect this:
Which is completely different from what is stated in the descriptions. The lucky man sequence in the first example is
1,3,2,3
(the1
comes from the beginning), which happens to be the same in both cases because1,3,2,(-3-)
is the same as1,(-3-),2,3
(where(-x-)
means ignore that number). They are, of course, different in the second example (the stated procedure ends at turn38
) and mostly different in the random tests.The correct procedure should be this (as mentioned by myjinxin in the comments below):
That also means you'll have to recompute the fixed tests, rewrite the descriptions and invalidate all solutions so far, but that's probably not a big deal.
I think there is no problem with the fixed tests and the reference solution. What's your
correct results
of the fixed tests? ;-)The result of the second fixed test using the stated procedure is
[946.4, 2237, 2361.5, 2390.2, 2064.9]
.Here's a step-by-step log:
OK. Code and tests Changed.
For me picking the lucky-man description is confusing... According to the solutions, the first 'grab' is ignored (the lucky-man is starting to be picked from the 1st 'grab'). So right now:
notice that after the first grab the lucky-man should be index 2, instead it's 1 (picked from the next grab).
the
lucky man
in first round is always the first man(element 0). The process of game is:I undestand. Saying that this is confusing and I bet people will spend lots of time understanding why some tests work, some don't. Just because of that 'skip' of the first grab.
I modify the description add some text like above ;-)
Cool. Will be very helpful for others, I hope ;)
still took me some time to understand the correct order of events :)
This comment has been hidden.
no computer now, can not test your code. in my code, I round them at the last step.
This comment has been hidden.
what's the last s in the var line mean?
This comment has been hidden.
Oh, I see what's happening...
The difference lies in the understanding of the "lucky man".
I mean people who get the most money at each round is the "lucky man". But in your code, it seems choose the person who has the Maximum total amount.
Perhaps my description is not clear enough, now you can understand what I mean?
Yes, you are right;-)... So i will change the code and see what happens;-)! Many thanks and perhaps it's really a point for your description (or maybe i was too quick again;-))...
perhaps I should add something to this point ;-)
Can test it later again, just on the way to sports;-)...
This comment has been hidden.
modified the description to:
Is this more clear? I don't know if my grammar and expressions are correct, because of my bad English ;-)
just a easy way, for example: at one round, send
$100
, five person grab:[44.1,24.4,8,2.4,21.1]
, the man who grabed44.1
is the "lucky man". he need send $100 at next round.What means "with the same pieces", you mean the next array of pieces always of same amount (5)? The one who was lucky man can never be lucky man on next stage, because of "-100"?? Or isn't it counted here?
you should elect "lucky man" first, and then send the next $100. you reduce the $100(it's the money of next round) in front of elect, so you ignore the possibility that this person will continue to be a "lucky man"(his money always be negative number).
Have it now, was not so easy to understand, wait a moment and i give you the solution... I'm not at home, so it's a little bit difficult;-)....
the process is:
Code works now... Sorry for the delay, as days before always cw errors and timeouts, so difficult to test and submit the solution. It's was not so easy, i think (for me) the description wasn't clear in some simple points. So here the questions/answers really helped;-)! It's important to say, that the choice of the "lucky man" only depends on the input arrays and nothing more, i think... (i was calculating something, which was wrong)
So see you later on... just doing my sports now;-)!
See you later, Mr.eight-packs ;-)
Yes, just back again;-)... so i think i should say "good night" to you;-)! Thanks again for your help, the problem wasn't the kata, but the description (for me), so nice to see the many tries of different solutions;-)... Perhaps it helps others to solve it!