6 kyu
Fruit Machine
151 of 3,322adrian.eyre
Loading description...
Arrays
Games
Fundamentals
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.
How can the 3 reels be different when each reel must contain 10 different items and there are only 10 different items to choose from in scoring? Does he mean arranged differently? Or maybe items not included in scoring can be included in the reels? If that's the case it should be stated clearly.
python new test framework is required. updated in this fork
Approved
C#: method name should be
PascalCase
(Please refer to implementation of backward compatibility here )Amazing Kata, Thanks!!!
However, the tests pass no trial, is it possible?
...what?
Do you mean that, when you press "Test" your solution works, but when you press "Attempt" your solution fails?
If so, that is possible - the "Test" part only contains a few fixed/specific tests; in the "Attempt" there are many random tests, including configurations that you may not have thought about/implemented correctly.
Yes, that's exactly what I wrote about. Already, I found errors and "Attempt" passed. Thanks.
In random tests, an error sometimes appears. I ran the same code 10 times and in 3 cases it appeared, and in the rest the tests were passed!
Reel 1 = Wild Star Bar Bell Seven Cherry King Shell Queen Jack Reel 2 = Wild Bar Queen Bell Shell Seven Jack Star King Cherry Reel 3 = King Queen Seven Star Shell Cherry Bar Bell Jack Wild spins = 0 0 5 Expecting - 10 Test Failed Expected: 10 But was: 20 Completed in 38.3670ms RandomTests() Log Reel 1 = Shell Star Bar Seven Cherry Jack Wild Queen King Bell Reel 2 = King Bar Jack Bell Seven Shell Wild Queen Cherry Star Reel 3 = Bell Bar Cherry Wild Shell Queen Seven Star Jack King spins = 2 6 3 Expecting - 10 Test Failed Expected: 10 But was: 20
In my case, this is due to the fact that I multiply by 2 the result if there are 2 identical pictures and there is a "Wild" picture, regardless of the types of matching pictures. The error should appear on every check, but random tests do not take this into account!
The Ruby translation would be nicer if there were sample tests added. It's possible to debug from the Attempt output, but not very much fun.
Ruby now has sample tests (added some time ago)
The "scoring" is blacked out.
Yes it's a pain having to highlight the text whenever I want to refer to the table instead of just being able to glance at it.
Sorry about that....updated score board
Could you make that font a little bigger?
This comment has been hidden.
Oh man, I was barely passed random test cases and It was really fun to solve. I came here after solving your Mexico Wave kata and this one is really liked :)
@adrian.eyre since you're active I'll leave this as a suggestion rather than editing directly there's no python translation to fork python 3.8/new test framework posting replacement code below (separately to avoid spoilering this message)
This comment has been hidden.
Hi Natan, thank you for this. Please feel free to edit with your updates or create a translation with your changes. Alternativley I'll try and find the time to update myself 🙂
Thanks for this.
I don't seem to be able to select python as a translation since it is an already existing language for the kata. I'll just edit it in then!
oh wait. I can't. locked/10k honor >.> I figured there weren't that many completions but okay x) (?? it's ~535 python completions)
Hi @natan, I've managed to update the code now. Sorry it wouldn't let you do it, I would have liked you to have the recognition of the translation.
Thank you, once again.
Ha, that's okay, not what I'm here for. Thank you for the status update :3
Can't wait to hit submit and see how someone much smarter than me has solved this in 1 line compared to my reams of code...
One fun part of not being smart is being amazed by others xD
This comment has been hidden.
Me every time I submit my code
This is a good and fun Kata but can you provide a dictionary or lookup for equivalent values for each spin? Or do we really have to write it out ourselves?
No, because that is the point of the kata: to find a proper/efficient way to manage the inputs.
The comment you wrote has more words than the dictionary itself :p Takes like 30 seconds to type it out
Thank you @Darshan97 your clue that the dictionary can be written within 30 seconds allow me to solve this kata.
This comment has been hidden.
fun to work on but damm did It feel like I had to do alot of data management to make the input usable.
The Kata creator should also include a dictionary for value look ups. God damm.
If you wrote that much about the data managment, that means you didn't find a "good way" to do it. Check out others solutions to see how you can handle that in better ways.
(for instance, consider that there are katas about conversion of integer values to the equivalent words, from 0 to 1 000 000. How will you do that without becoming crazy if you cannot find ways to write the minimum?)
hihihihi fair point, atleast I'm improving, definitly noticing things are becoming easier to solve. but i guess only 1 way to improve efficientcy is by making more kata's and improving even more :P
I use python and I have a problem. There are 1-4 'Failed' in the 'Random tests', it says like "Should return: '10': 20 should equal 10", but my return equals 'Expecting result'. Why is it failed?
"don't mutate the input"?
This comment has been hidden.
ah, I actually misread the assertion message you wrote. Well, print the inputs so that you can see what's going on when you encounter that failure. I'd bet on an error in your algo handling the actual number of "Wild".
The user is not active anymore.
@adrian.eyre, C/C++ & Java translations available. Be sure to approve the Java version last. It has all changes to the description, so that should avoid merge conflicts.
Approved all, thank you for the translations :-)
Fun kata. Maybe provide the object/hash/dict of card values though so people don't have to write it out themselves?
I passed all the sample tests, but am failing the third 'attempt' test (ruby).
It says: Should return: '10' - Expected: 10, instead got: 0
I can only guess from that that it's failing when there are two wilds and something else, but when I test that on my own it works. Any help figuring out what that is testing for?
Hi @jhughessuta, I'm unable to see your code so cannot help, sorry.
This comment has been hidden.
Maybe add to the instructions that spins are never more than 9, I initially added some unnecessary code to account for spins that were 10 or more.
This comment has been hidden.
I think you're using the variable
spin
not the argumentspins
that is passed into the function.spin
is the global variable that is created for the random tests and should not be altered.Hopt this helps.
Yes! Thank you so much.
This comment has been hidden.
fixed my code, was missing an 's'. Fail, lol
Crystal translations for you, cheers :)
Approved. Thank you :-)
(C#) If you make it mandatory to work with a List, at least put the using directive System.Collections.Generic in there,....
Fair comment, I've added it now.
I have an error with the random in Python and I don't know why. I tried the random input with PyCharm and it work fine (the code return the proper solution).
Hi @Boumbap, whats the error?
I'm using Python and my code get an error for one of the random test. For exemple, with the input :
Reel 1 = ['Wild', 'Seven', 'Star', 'Bell', 'Shell', 'Bar', 'Jack', 'Cherry', 'Queen', 'King'] Reel 2 = ['Cherry', 'Bar', 'Shell', 'Queen', 'King', 'Jack', 'Bell', 'Wild', 'Seven', 'Star'] Reel 3 = ['Jack', 'Wild', 'Queen', 'Star', 'Bell', 'King', 'Shell', 'Cherry', 'Bar', 'Seven'] Testing for [4, 6, 7]
I get this message :
! Should return: '0': 2 should equal 0
So the error is saying my code return 2 instead of 0. But when I try this input with my code in PyCharm (so on my computer) it return 0 (the proper solution).
I've made the random tests to display what result its looking for now just in case I've mixed the expected and actuals around in the tests.
Please try again and let me know what outputs you're getting.
Same problem, I have an error for one of the randoms input.
Reel 1 = ['Bell', 'King', 'Bar', 'Shell', 'Wild', 'Cherry', 'Star', 'Seven', 'Jack', 'Queen'] Reel 2 = ['Shell', 'Seven', 'King', 'Cherry', 'Bar', 'Bell', 'Jack', 'Queen', 'Wild', 'Star'] Reel 3 = ['Jack', 'Bar', 'King', 'Star', 'Seven', 'Bell', 'Queen', 'Shell', 'Cherry', 'Wild'] Testing for [6, 5, 4] Expecting result = 0
I'm ok with the expecting result, I have this result with my code on PyCharm. But the same code get an error on codewars : ! Should return: '0': 8 should equal 0
mmmmm, would you mind posting your solution here and mark as spoiler :-)
I'll make my guess...: Boumbap, could you be mutating the
reels
variable in your code, by any chances ?This comment has been hidden.
Ok, no mutation of the arguments. :) (that's bad practice!)
One tip: use
enumerate
in the definition ofspin2
(it will avoid thereels.index(reel)
part. I let you search for theenumerate
documentation... ;) )And your trouble lays in the third
elif
part. Your algorithm doesn't match the behavior wanted with the description. Tell my if you want an advice "just a bit more precise" (but just a bit ;) ).Thanks B4B, I was just about to reply :-)
@Blind4Basics, I don't get what's wrong with the last elif. So yes please, I do want more advice.
Ok. Think about what could be
spin2
whenset(spin2)
gives you something like{'Wild', 'Queen'}
...This comment has been hidden.
The point of enumerate was to write:
spin2 = [reel[spin[i]] for i,reel in enumerate(reels)]
It's more verbose, so the code is easier to follow. But it's more verbose... And effectively, your modification makes sens too, with therange(3)
.About the "new info", considering that many guys did pass the kata without problems, could you have read the log of the following or previous test, actually ?
EDIT : Hu... I forgot the way the random tests are dsplayed... I'll take a look, but I'm really tired, right now (it's midnight on my side of the world... ;) )
EDIT²: checked. Your algorithm is good. It should pass the tests (it did on my side!) If it's not the case, check the modifications you did that you didn't talk about in your previous message: your problem lays there, right now.
I'm going to bed, cheers!
I am aware of the many guy who pass without problems (27 with python) BUT maybe my solution is kind of original ... (probably not the most efficient)
I think the
spin2
is always wrong with the random test but somehow I can pass some of them (probably luck). But, I'm repeating myself, I've errors in Codewars but not in PyCharm.And I think we are on the same side of the world (It's also midnight for me ;))
Could you paste the full code you are using ? (yeah, still not in bed... :-/ Thanks to Dinglemouse and his "Soundex"... ;) )
Note: which part of Europe or Africa ? (personnaly: bread, wine, beret and Eiffel Tower... ;) )
.
This comment has been hidden.
HAHA! Second french guy I cross path with, on codewars! ;)
About your code, you've got a misspelling error in the definition of
spin2
:spins[i]
, notspin[i]
. CW didn't raise an error because the variablespin
is defined in the tests cases, so you didn't use the argument of your function but a variable in a larger scope. With that, all will be good. ;)Happy coding on CW!
Oh My Glob ! That was so obvious.
Thank a lot for your suppor and happy baguette :)
ZZzzzz
:-)
This comment has been hidden.
Python - I think one of the randome test still have the actual and expected value mixed up in the assert. There is always one random test that says my expected value is incorrect, so I run my code in an ide with the failed input and it returns the proper value.
Another very nice and neat one! Congrats!
:)
Why do you use "Test.expect" instead of "Test.assertEquals". It is really annoying to use console.log to get the result, that the own method returns...
I've changed the Javascript tests to "Test.assertEquals" now, sorry.
Great! Thanks a lot!