6 kyu
Lottery Ticket
8,688 of 13,611PG1
Loading description...
Fundamentals
Strings
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.
sweet little kata :3 perfect for 6 kyu
js/didn't check others:
missing fixed test where a subarray has a matching character multiple times such as
[['OOO', 79], 3]
with the duplicates required to reach the target - instructions state that a sub array may only be counted once. random tests are not sufficiently well crafted to consistently fail such solutionsadditionally, the test output should quote strings in the "testing for ..." it name, that's really annoying when looking to call it myself
I'm a little confused on the generated attempt test. I was given
[[BXUBG,75], [NNLLEGHQ,71], [PGKZJCC,85], [TSMEJKFJ,87], [EEX,86], [DJIZVOZ,79], [KRRFVLR,88]] and 1
'G' is code 71 and 'O' is code 79, both in two separate mini wins. Am I missing something?Well, yes, you're not saying what your function returns for that or what you think it should return for that. Additionally, there's bit of a flaw with how you print because you show letters but not which subarray it came from so you could have a mismatch there, probably unrelated though.
also why do you have a semicolon on one line but then don't bother. use them or don't damnit, don't mix
My observation isn't from my solution, but just from looking at the problem statement and the given test. Shouldn't the
win
in this case be 2?win
is an argument passed to the function, which you said is1
the number of mini-wins for that input is 2 maybe that's what you meant. yes. it is.
so, why then are you confused? I'm again guessing that it's because you don't know what your function returns for that input, that you saw that the result is wrong, made an assumption about what you returned but never checked, and never said either - that's what you're missing - what do you think is the answer for that input, what do you think your function returns, what DOES your function return - those are all different things, and by only considering two of them you miss where things have gone wrong.
or.. maybe you mean it should be exactly 2 to be an overall win, but that's not what the problem statement says. There's no way for me to tell whether that's what you mean when you only share a fraction of your reasoning and observations.
Very bad kata. Firstly, nothing is clear from the conditions, and there are no examples. Secondly, I solved the test correctly, but it gave an error. Thanks to the comments, I understood that I need to press submit until the test is completed, I pressed it five times, and still passed the test.
Add a test case for miniwins > win as there is currently none and random tests may miss this senario.
Example:
test.assert_equals(bingo([['TUCYPFOU', 84], ['LRG', 76], ['DV', 83]], 1), 'Winner!')
This comment has been hidden.
2 > 1
haha maybe next time I should read more carefully. I thought it should be equal !!!!
Lua translation !
Approved, thanks
Tests use deprecated function
toByte()
. The deprecation notice spoils the solution.This comment has been hidden.
duplicate issue
That issue has existed for 2 years??? Obviously it needs a bump then. You literally only have to replace
toByte()
withcode
to solve it.duplicate issues are bad; they make maintenance harder and they discourage users from trying a kata when they accumulate (a kata with tens of open issues is an immediate skip for many people). you can make a fork and i will approve it.
Ok, makes sense. Sorry for jumping at you like that. Here's the fork, hope I did everything right (haven't made a fork before):
https://www.codewars.com/kumite/66ae6d495b5b458eac8b2811?sel=66ae6d495b5b458eac8b2811
In random test may be two twin characters.
Read the question - 'Note you can only have one mini win per sub array.'
That sould be 7 at best, too easy for lv6.
This comment has been hidden.
duplicate issue
This comment has been hidden.
A problem with your code is not a kata issue, the tests are fine. Use
question
label. Read this again:Thank you very much
Perfect 6 kyu!
Testing for [[AKOXCRLP,90], [IBXFRAKK,75], [CRPO,65], [FB,82], [LXPW,70]] and 2 expected 'Loser' from me, why? There is double K, which code is 75, that means at least already my total is more than win
Hi,
Not an issue, a question (the kata works correctly). For instance:
Cheers
Testing for [[YOPEWBI,73], [JMXKLK,68], [YXUCQFUE,89]] and 1 It should work for random inputs too: expected 'Loser!' to equal 'Winner!' Why is 1 correct? ASCII table says code(I) -> 73 from the first subarray. code(Y) -> 89 from the last one. There should be 2
That's why.
That was very easy, c++.
Language: C++
Test suit missing the required headers
std::string|std::vector|std::pair
This comment has been hidden.
The most stupid task that is impossible to understand, the code should work according to the author's explanation but gives an error, correct the text and then publish. For example, according to the tests I should output 'Winner!' But why? [['FIQDTMTD',90], ['PHNGRRW',72], ['TTVSRU',72], ['WOXLT',68], ['ZXPL',84], ['LHKYCGQG',83], ['YT',88], ['XF',69], ['KDMRY',65]], 1
This comment has been hidden.
Nevermind, I made a typo transferring my code from another IDE.
This comment has been hidden.
This comment has been hidden.
not an issue, a question.
you're mishandling the
win
argument. That's why.Sometimes when number of miniwins equals winning number tests fail. I've literally had tests expecting 'Winer!' when miniwins = 3 and win = 3, and I also had tests expecting 'Loser!' in such situation. You can submit your solution if you click 'Attempt' enough times to draw a set of tests that are not violating assumptions set in the task. (This is for Python.)
Your code is actually incorrect, you just happened to get the test suite to generate a set of tests that your code will pass. Your code will count multiple miniwins if the "winning" character appears more than once in the string. For example, if the character string was 'AAA' and the number was 65, your code will record that as 3 miniwins, but it should only be one.
Oh gosh of course. Thank you so much!
Thank you so much! I was having this same problem and I couldn't figure out why.
hello, world!
'It should work for random inputs too - Expected: 'Winner!', instead got: 'Loser!''
I'm not sure what this means, can you elobarate? I pass 90% of the tests, others fail on this problem.
/
Sometimes the characters are repeated twice, make sure not count second time, if matches the ascii value
OP solved it, closing
This comment has been hidden.
fixed
The user can mutate the input affecting the expected value at least in javascript. Calculate the expected value before calling the user's function.
done for JS
Random tests
Testing for DSYLTWUI,87,TQDV,79,MKUVZJN,77,JGICV,87 and 1
Log
[ [ 'DSYLTWUI', 87 ],
[ 'TQDV', 79 ],
[ 'MKUVZJN', 77 ],
[ 'JGICV', 87 ] ] 1
It should work for random inputs too - Expected: 'Loser!', instead got: 'Winner!'
Why 'Loser!'?
No idea what you're doing but, you passed the kata and with your current code I can't reproduce that error. The control function returns
"Winner!"
for that input too. You can see that for yourself.I used a different implementation of the solution. In IDE the function returns the same "Winner!" but test message: "Expected: 'Loser!', instead got: 'Winner!'"
The input data above should return'Winner!'
Post your code that fails: https://docs.codewars.com/training/troubleshooting#post-discourse so it can be checked.
This comment has been hidden.
Probably that's because that solution mutates the input, affecting the expected value.
Your code do a correct answer, don't mind whats wrong with it
This comment has been hidden.
Python version generates warnings.
.
This comment has been hidden.
U must compare your "mini-wins" with the win number u got inputed. In example you have two subarrays with two wins. If your WIN number from input is less or equal to your number of wins then u are the winner.
U wrote this here Another error "AQGFNCPW,77,WIV,78,MV,85,XFIJAQN,73,RGOG,72,KI,79,HG,84,TTC,67,GKFQI,69,CLRM,88 and 1" .My solution finds 2 lucky tickets - ['XFIJAQN',73] ( [88, 70, 73, 74, 65, 81, 78]), 73 and ['TTC',67] - [84, 84, 67], 67. So u have 2 lucky tickets won, but if your WIN number from input is higher than your "2" lucky tickets, then u are loosing.
Read the description carefully. I hope this will help u.
hey, not sure i really understand it either. in that example how are you loosing? there's two mini-wins and the win number from input is 1. 2 is greater than or equal to 1, so you should be winning? there's a few tests that don't pass and i don't really understand the logic.
your soluiton doesn't follow the specifications. No issue here (comparison).
Good day,
I have a problem here: my solution works for 90%. One of the cases that doesn't work: "EKIV,81,RYVFY,87,KGPAMYPO,75,JDNOQF,75,JRFHMPNQ,90 and 1" My solution finds '1' lucky ticket - KGPAMYPO,75 (K is '75') and to me it looks as 1 lucky ticket === win so it should be correct. I'm a bit confused here, any help would be appreciated.
I try to solve Javascript version
Another error "AQGFNCPW,77,WIV,78,MV,85,XFIJAQN,73,RGOG,72,KI,79,HG,84,TTC,67,GKFQI,69,CLRM,88 and 1" .My solution finds 2 lucky tickets - ['XFIJAQN',73] ( [88, 70, 73, 74, 65, 81, 78]), 73 and ['TTC',67] - [84, 84, 67], 67.
I checked ASCII tables and can't find what I'd doing wrong here
In PHP, I earned the test, but when I try to attempt it failed ! Is there a bug ?
Debug here :
The tests are okay.
Your current solution doesn't meet the expected condition:
not an issue.
JS random tests generates warnings. Verified the random ones myself and they work.
Which warnings? I can't see any warning.
this test case is failed in
javascript
:But it's correct. Can you explain why it's not?
The first 2 tickets are winners, and that is >= 2.
The second ticket is not a winner because of the requirement: "Note you can only have one mini win per sub array."
handled
JS version generetas warnings
MHCEAHQR,76,AUIUYJUB,65,TKYJQU,74,DZLACK,66,DQNL,69,JMCFPA,65 and 1 YTTKHLF,89,ZXPUNQ,81,BIZOMT,86,VNXWULB,65 and 1 JP,84,ZEHDK,75,JBIZVXGG,86,PSLHLX,67,HW,70,RUFFVD,89 and 1
... and many others :(
Phyton version generetas warnings Example ticket = [['YXSPUIX', 84], ['EOL', 64], ['UZ', 80], ['CYWT', 73]] win =2
This comment has been hidden.
C version generates warnings.
Fixed
C++ version generates warnings.
Fixed
This comment has been hidden.
Your code may count more than one.
I don't understand the question. What is a character code in this case. I cannot identify what a mini win is.
just google for "ASCII character code", for example 'A' has ASCII value of 65.
This comment has been hidden.
Prove it. The tests are fine.
what? the tests are fine dude!
This comment has been hidden.
So you counted 2 wins, and you need at least 1 win. Why would you return 'Loser!' ? The test is correct.
thx you example helped me to understand the kata!
Rust translation :-)
I think data that comes in random tests are wrong. //println(bingo(arrayOf("GOO" to 80, "MZACH" to 66, "UMGWNM" to 84, "SZN" to 89), 2)) -- no mataches 0 //println(bingo(arrayOf("FTL" to 87, "XLRUS" to 82, "QLRDXW" to 87), 1)) -- 2 matches but tests expected "Winner"
I'm having problem too with the random tests in C. please help
You'd need to describe the situation in a reproducible manner for anyone to be able to do any helping.
sorry, i got the following for example:
Expected Winner! Received Loser!
Testing for {{"EKFQD", 81}, {"KGO", 71}, {"XLNXEO", 71}, {"TA", 71}, {"JPUWXOO", 67}, {"WSDONOUE", 87}} and 1
counted: 3
is suposed to be a loser but expects winer
Isn't 3 >= 1 ?
thanks a lot! have to practice my english!
Looks like there is a problem with random test cases 3 of them are always failing , no matter in which language u code. It is not showing details of the failed test cases. Please update ...
Nothing to update, really.
Print the arguments to console.
Using Ruby for this and I'm not sure where I'm messing up. Here are two Logs from where I'm using puts to print out the various values:
I'm passing around 90 tests each time. Looking at the second log alone: How can I get three matches on only two characters? Both of these logs show that the values for each character don't match the value needed for a match. Every test that I'm failing is similar to these two where I return loser but the test is expecting winner. I figure either I'm missing something or the tests are bad.
The Ruby random tests have between 2 and 9 subarrays, why are you analyzing only one? Also, note that for each subarray you can have at most one mini win. Check the instructions again.
Thanks for that, I moved my return to the wrong location while debugging a different problem. All solved now.
No problem, solved then.
Definitely not a 6 kyu in PHP, but I had fun. I wonder if it's harder in other languages?
This comment has been hidden.
So? Number of matches = 2, minimum required number of matches = 1. Everything is correct.
Originally in the description it said that the number of miniwins was supposed to be the same as win, but it has been fixed thanks to paulkan.
Looks like random test generates wrong tests (at least on C language). Here is my example:
Testing for {{"VJD", 66}, {"AYTNQRS", 89}, {"IL", 71}, {"KMKA", 65}, {"RP", 87}} and 1
89 == 89 (Y) 65 == 65 (A) winCnt = 2 win = 1 == 0 Expected Winner! Received Loser!
So we have 2 matches here, and win number should be 2, but random test puts 1 and expects "Winner!". Please update this kata.
UPD: After investigation I found that miniWin string which has correct ASCII key from other miniWin - has not been counted in random generated tests. It's the reason why random tests failing. Please update random tests. Thanks!
So? Number of matches = 2, minimum required number of matches = 1. Everything is correct.
Sorry, my fault. I missed "more than" in description: "If your total is more than or equal to (win), return 'Winner!'. Else return 'Loser!'."
Hi,
I wrote code in Javascript; For the below mentioned ticket; the mini-win(s) is 1 and the provided win is 1; so the expected should be Winner!, but the tests failed saying as Loser!
Testing for HMOAHIRY,77,VGDU,73 and 1 It should work for random inputs too - Expected: 'Loser!', instead got: 'Winner!'
Need help on this!
Thanks!
This comment has been hidden.
Please, read the mdn docs about the methods you use, shift mutates the array, that's why you're changing the expected output. Check my answer to your other post about how to use proper markdown, otherwise your code lose indentation (amongst another things) when pasted here.
Elixir translation kummited. Feel free to review/approve when you get some time. BTW, nice kata!
Approved, thanks :D
This comment has been hidden.
Julia translation kumited
Approved
Kotlin Translation
please, review and approve
Approved
3 of 100 random tests are failing but it does not show the actual test case details. It only says 'Winner!' should equal 'Loser!'
How do I look up test case input it failed for to work on fixing my code?
Thank you,
There is a builtin function for
print
ing out things to console in Python ;-)Never mind, I figured by re-reading problem statement fixed. Thank you though!!
Haskell : https://www.codewars.com/kumite/5bc2bd0641fa3d8d2f00004d?sel=5bc2bd0641fa3d8d2f00004d
Approved
@A.Partridge, C translation available.
C++ Translation
Approved
Ruby translation
Please review and approve
Approved
Python translation
Please review and approve
Approved
It appears the solutions have a few mistakes. I compared to ascii table and the ones that are getting marked errors are correct.
Looks correct to me!
This comment has been hidden.
It seems to be wrong to me too in PHP Language. All my tests pass and I submit it generate some random series and the expectation seems wrong. I've added a log to see what it was actually passing to understand why it was failing.
win: 2 ticket: [["BP",86],["BC",66],["POYGYR",89],["PZ",68],["GPHB",71],["QN",83],["QUOMXQ",79],["ODMMKL",69],["QTI",84]]
My function is returning Loser because there is just 1 mini-win on this serie and it is expecting 2. The only mini-win on this is ["ODMMKL",69]
Failed asserting that two strings are equal. Expected: 'Winner!' Actual : 'Loser!'
Please let me know if someone else is having same problem.
Note you can only have one mini win per sub array.
Hi @oznavigator I still think it is wrong.
This test is passing to me. so I am considering your note. I am almost sure there is something missing. Have you solved this on the php language? maybe a test case converted to php is wrong?
public function testOnlyOneMiniWin() { $this->assertEquals("Winner!", bingo([["BMJN",44]], 1)); }
PHP Translation Kumited - please accept :D
Approved a long time ago - closing suggestion