6 kyu
Handshake problem
127 of 13,413Laurynas Lazauskas
Loading description...
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.
Java:
camelCase
, notPascalCase
Refer here on how to enable backward compatability to not invalidate all solutions
is there any solution to get attendance (IN/OUT) from machine by using oracle form boimatric attend by oracle form
Very interesting kata, 10/10!
This kata is a little bit backwards, so it took some time to understood it, but still a lot of fun!
For anyone asking, the table name is 'participants'.
Expected results are inconsistent between Haskell and Ruby, Crystal. The same input expects different results. For example an input of 696 expects 38 in Haskell but 23 in Ruby.
Need proper random tests for solutions like this.
Fixed with proper random tests for Java, JS and Python.
This comment has been hidden.
Please don't spoil solutions in the comments.
Calm down boy, no spoilers at all. Just intro to Graph Theory
why for 0 handshakes amount of partisipants have to be 0? It might be 1 participant... Just due to this inaccuracy in test my code isnt beautifull :c
It says minimal, and 0 < 1.
Oh God. You are right))
very boring it is more a mathematical brain teaser than anything else
it is not ALGORITHMS case, its mathematic...
If the code works in Plunker, but then it throws an error, what could be the matter?
Easier than I thought tho
SQL Translation
APPROVED
This comment has been hidden.
This comment has been hidden.
Your code being too slow is not a kata issue. Use
question
label next time.Nice kata!
In js language, the input parameters are 171 handshakes, and every time I execute the program, there is always an error in 171 handshakes. The program always expects a different result.
Testing for handshakes = 171: expected 171 to equal 804
Testing for handshakes = 171: expected 171 to equal 250
Testing for handshakes = 163: expected 163 to equal 162
Testing for handshakes = 171: expected 171 to equal 212
Testing for handshakes = 171: expected 171 to equal 322
Testing for handshakes = 171: expected 171 to equal 628
Testing for handshakes = 171: expected 171 to equal 658
Testing for handshakes = 171: expected 171 to equal 665
Testing for handshakes = 171: expected 171 to equal 488
Testing for handshakes = 171: expected 171 to equal 932
Help fix this error.
Error messages for JS tests were incorrect. Input of tests was not 171, it was a mistake in the text.
Still, for some reason, your solution tends to (incorrectly) return 171 for many inputs.
Spent some good time here. xD 70% math.
Wow what a kata. Especially 5 people === 7 handshakes. Respect bro u are so smart (NOPE)
Some farmers may not handshake, and all pairs of farmers hansdhake at most once, so if we have 7 handshakes, we need at least 5 farmers to perform them.
This comment has been deleted.
Issue with Haskell version. It seems to expect a different answer from Ruby and Crystal versions. Ruby and Crystal expect 19 to be correct for the below but Haskell expects 42 instead. This can't be right.
Falsifiable (after 1 test): 850 Borked out at: 850 Expected: 42, Got: 19
D translation
NASM translation.
This comment has been hidden.
Please use a spoiler flag when you post some code. What is testcase 4?
I was getting 4 should be equal to 5
And what's the input? Do you assume your code is correct and all the other people (more than 6000 at this time) solution are not, just because your code seems to fail only on this case?
( JS, possibly others )
assert.strictEqual(getParticipants(0), 1)
0
handshakes requires at least0
participants, not at least1
, no matter what somebody's closed form formula says. ( https://www.codewars.com/kata/5574835e3e404a0bed00001b/discuss/javascript#57c73760fa9fc58bfc00027b )Fix for:
Cobol and Python approved, rest has merge conflicts
I did not check if any descriptions had problems .. :O
Forks: Haskell, Go, C.
I see no difference at all with current version of description (or the version in Rust translation published a few hours ago)...
CW works in inscrutable ways .. all of them approved now.
All other 9 languages forked, anyone care to approve? (Lazy to post it here due to too troublesome)
Other ones approved.
As the original author of this problem I would like to point out that since Johnny is organizing the event, he is inevetably a participant, so even if noone arrives and Johnny doesn't get a chance to shake hands with other farmers, there is still one participant 😁
But I don't really have any investment in this to oppose anything
That is a completely plausible reason, which totally overrides the mathematical bullsh!t. :P If it is specified that for
handshakes = 0
,hands = 1
. :]So as long as it says nowhere that the photographer also shakes hands ( does he even have a free hand to shake hands? :P ), let's stick to the mathematical interpretation.
Also, let's please not undo those guys' good work ..
Yeah, no, I don't intend to undo anything. Thanks for everyone maintaining this and I am just happy people are having fun. :)
(author is inactive)
Approved!
This comment has been hidden.
The test is fine.
"minimal amount". Ah, I get it now. Thanks.
I'm getting a 4 should equal 5 error that is stopping my code from passing. If i understand this correctly its implying that 4 handshakes would need a minimum of 5 people to perform? I have either vastly misinterpreted the original question or something is wrong with the testing criteria. If theres somehow my code could induce this shenanigan i can share it . . . i also got a 4 should equal 3 error on one of the smaller preliminary tests. Seems its something to do with 4 handshakes that it refuses to clarify as needing 4 ppl minimum.
If you don't understand the kata, it's not a kata issue, but rather a question. Issues are bugs in the kata.
i think i do understand the kata, its looking for combinations, if there was an issue with my understanding it would just be if im reading the error incorrectly. the fact that the number it is supposed to spit out is the minimum and i got errors claiming it should be two different numbers seems to imply something isnt functioning right in general as you cant have two possible minimums, only the lower number would be the minimum (it said 4 should equal 5 and 4 should equal 3 on seperate attempts). What information would you need beyond what i gave to tell if its somehow my doing or was a bug?
There's no bug, the kata is correct, more than 3000 people solved it and nobody ever reported a substantial issue more than 6 years after its creation. What the log tells you it that you return 4 and the correct answer is 5.
ok, that makes sense. thx
This comment has been hidden.
done
and this time with the suggestion resolved :)
!
COBOL translation (author inactive)
Crystal, Julia && R (author inactive)
Thanks!
Please review Go Translation
Hi. I approved, but I missed a minor issue: the parameter is missing in the function signature of initial code. Can you fix it?
You can make amends by translating this to Cobo.. ;)
Tool late :p
I've added it, so closing :)
Please review C++ Translation
This comment has been hidden.
approved
Please review C Translation
approved by someone
Haskell : https://www.codewars.com/kumite/5bcd5342c9fc4c71ae0000a3?sel=5bcd5342c9fc4c71ae0000a3
Updated + reposted above
Ruby has no randoms.
rand()
To be more clear, Ruby translation has no random test cases.
fixed
Java translation provided and ready for review.
This comment has been hidden.
Done
This comment has been hidden.
This comment has been hidden.
if handshakes are 7 must return 10 and not 5
Perhaps you've misunterstood the details. In order to perform 7 handshakes you do need at least 5 people. If everyone handshaked, then 5 people would produce a total of 10 handshakes, while 4 people would produce 6 handshakes (not enough).
I was confused by the statement:
I originally interpreted this as a requirement. So if there were 3 handshakes, then there must be 4 farmers, as if there were only 3, all of the possible handshakes happen. Maybe change that sentence to something like
Good point, thank you. Updated the description.
Really nice! Test cases should vary more, though...
"Drop the beet" made me laugh hard!
Would be good with some more test cases, preferably random.
Nice kata. :-)
JS and Python translation kumited.
If you want to approve...
Approved. Thank you! :)