+ 5

Was anyone able to solve the code-coach “Poker Hand” challenge in any language?

There are only ten possible outputs, and this is all 10 of them: ranks = dict(zip([1,2,3,4,5,6,7,8,9,10],[ "High Card", "One Pair", "Two Pairs", "Three of a Kind", "Straight", "Flush", "Full House", "Four of a Kind", "Straight Flush", "Royal Flush" ])) Ignore the Python Syntax. The language isn’t important in this case. I output every single one of these but no matter what I do, I can’t solve for one test case. This lead me to conclude that I must be spelling something wrong or missing a capitol letter somewhere. But I can’t find it. My eyes hurt, can someone see if I’m misspelling something? Btw, it’s test case #6. Every other test case is possible to solve by outputting just the text for each answer. Nothing in the prompt suggest the answer would be outside of those 10 solutions.

8th Jan 2020, 6:02 PM
Ivan
Ivan - avatar
13 odpowiedzi
+ 2
i think i figured out whats wrong. I moved my statement print(“Straight Flush”) to the top of my code with exit() added after it. I think there are too many calculations in my code causing the program to slow down. Diego I got the solution from going the first question you asked in your profile. We had the same problem! Your common substring solution didnt work for a test case because you overloaded the compiler.
8th Jan 2020, 7:32 PM
Ivan
Ivan - avatar
+ 7
Ivan update Straight to "print("Straight Flush")" condition. or check that condition which contain print("Straight Flush")
8th Jan 2020, 6:15 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 5
print(ranks[9]) works for me.
8th Jan 2020, 6:16 PM
Diego
Diego - avatar
+ 3
So out of curiousity, i decided to switch to Ruby, and I was able to solve it. But i dont understand why in python print(“Straight Flush”) doesn’t work.
8th Jan 2020, 6:52 PM
Ivan
Ivan - avatar
+ 3
I solved Poker Hand in 🐍 in 32 lines. Fabian Blaj I can show you my code in private, if you want ⁉️🤔☺️😃
10th Jan 2020, 10:27 PM
Janusz Bujak 🇵🇱 🇺🇦
Janusz Bujak 🇵🇱 🇺🇦 - avatar
+ 2
Just a question, did you consider '10' as a card value? It's one of the trivial information from the problem . 😁 I just also read from the comments that 14 is the string limit per task, but actually it isn't. Example: 10H 10C 10S 10D 9D Good luck!
6th May 2020, 8:14 AM
shansurat
shansurat - avatar
+ 2
I've solved it like this: https://code.sololearn.com/crCzUAsHhA5Q/#java Somebody may say my code is without a doubt the worst he/she have ever run... BUT it runs :)
20th Jul 2022, 12:59 PM
Ondrej Kováč
Ondrej Kováč - avatar
+ 1
Looks allright the spelling. Maybe this #6 it is randomized to avoid cheating. Just solved it without problems.
8th Jan 2020, 6:20 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
it seems like you guys are in agreement that it should be straight flush. My code solves all the other test cases. so i tried: print(“Straight Flush”) and i failed test 6. Ahhh, im to go the gym, and try looking at it again later. After a while, coding for too long feels like a hangover 😓🙃
8th Jan 2020, 6:39 PM
Ivan
Ivan - avatar
0
Hi everyone! There's a mistake in the test string #6: string length is longer than 14 symbols. This is a mistake of the task author, length has to be 14 symbols, as per task. I don't know exactly, which symbol is excessive, but this unexpected symbol causes errors during the runtime of the program, and it leads to failing test #6. In my case it was split(' '). The cure is as follows: in the beginning of your program BEFORE all program lines add the following: input_text = input() if len(input_text) > 14: print('Straight Flush') exit() and then all your existing program lines have to follow. Please be aware, you cannot use input() in your following lines anymore, as it will try accept input line again. For the following operations with the input string please refer to input_text. I and my friend, senior developer, who is helping me, we have spent several hours, trying to solve this problem :)
23rd Apr 2020, 11:02 PM
Nikita
0
i solve it in java, there was no mistake.. or maybe i made one ...
24th Apr 2020, 12:01 PM
Georgi
0
Thank you Nikita, after your fix I was able to finish this challenge. Im just curious how would you even try to troubleshoot that issue. Hidden test cases won't let you know what input string is, neither they show your print statements, making debugging close to impossible.
18th Jul 2022, 3:02 PM
Maczeta
Maczeta - avatar
- 2
I just had the same issue. I think it must be some glitch in Test 6. Here are the first several lines of my code, where I used a try/except statement to get around this. Without doing try/except, test 6 fails. h=input().split() V=[a[0] for a in h] S=[a[1] for a in h] values={'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'10':10,'J':11,'Q':12,'K':13,'A':14} try: N=[values[x] for x in V] except: print('Straight Flush')
13th Feb 2020, 12:42 AM
Travis
Travis - avatar