Draft
Casino Roulette
24eladkap
Loading description...
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.
I think it would be useful to specify that it is the 'European Roulette Wheel' which is being used in this problem. Also specifying the numbers for black and red:- BLACK = [2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33, 35] RED = [1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36]
This provides a solid base for the solution. Other than that, I thought it was an excellent kata. I hope eladkap and others may find this comment useful.
Improve test case logging. This means nothing:
This section seems redundant and should be removed. (also it's missing BLACK, RED choices)
You put 15 in the BLACKS in your solution but it's in REDS in the preloaded.
This fails random tests here and there.
I fixed that in preloaded
Having multiple different output types is bad.
This could easily be fixed by changing return to some string: 'Winnings: 10.' or similar.
Noooooooooooo! Strings are not the answer.
The correct solution here does not involve strings at all.
IMHO It's better to return integers:
> 0
: winnings0
: no winnings/no betsraise ValueError
: no moneyHaving multiple different input types is bad.
Could you explain this a little? Because I don't see the problem.
It's same as the issue above. The point is that it becomes tricky to translate such kata to some other languages, among other things... Passing numbers as strings seems like a reasonable compromise.
Probably the problem is the second item of bets, sometimes an integers and sometimes a string.
Surely statically typed languages would just pass the numbers as strings, and leave the python version as is?
I don't think, that returning string is good at any case. If function cannot return integer, it should throw an exception.
Ah, second item of bets is the problem.
I actually don't see that as a problem. In dynamically types languages, you look at the type and then the content; in statically types languages, you define a wrapper type, and look at the type constructor and then the content.
It'd be fun to use overloading or multiple dispatch to solve that. :]
@dolamroth: wrong thread
Usually
EVEN
includes only 2,4,..,36 (not 0).Description should specify whether
EVEN
includes0
.This is Roulette.
EVEN
pays 2 to 1.If
EVEN
includes0
, the casino will lose money.Casinos don't lose money.
This kata loses money :smiley:
Can I place a million consecutive one dollar bets on
EVEN
?( That should net me slightly over
$ 27 000
. Make that ten dollar bets, that should keep me for the rest of the year. )I updated description: See: - EVEN - for even numbers (including zero)
BTW, in Roulette the odds for payouts are calculated carefully so the Casino won't lose money - that's correct. The rules are not trivial, so I made this kata a simple for coding.
Sorry, that is just not a good way to solve this issue. Nobody would expect
EVEN
to include0
, and the description at that point is not blinking, bold, big and some flashy colour. ( And excluding0
can be coded quite simply; not buying that argument either. )Please exclude
0
fromEVEN
.'RED'
and'BLACK'
should be listed in "Player Choices on the Board"According to wikipedia
15
should be black, not red.Payouts for black/red numbers are not listed in the description.
Added those payouts. Thanks
The expected result is a number, not string.
Fixed this issue. Thanks
Tests shouldn't log anything.
Fixed this issue - Test logs only "Test result: True/False"
Do you not understand what "anything" means?
I fixed the description (Fourth Example)
Please use appropriate datatypes.
"Winnings"
can just be a positive number;"No winnings"
could just be number0
; there is no reason to special case"No bets"
( and example 4 doesn't !! ); "Not enough money" should throw an error.Strings are always suspect, and very often just plain wrong.
I see what you suggest Johan. Actually I wanted to make this kata interactive as if it was a function inside Roulette interactive game. Enum would be a good practice here instead of just strings. This is actually my first kata :) I made this kata so fast that I did not give much thinking about every technical detail.
Next kata would be much better ;)
By saying "next kata will be good", do you mean you are going to leave this one in a bad shape? :)
Keeping input and output data types mixed as they are now will make this kata real pain to translate, and API which requires juggling strings with integers is real pain to work with.