| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Page 5 | Page 6 | Next » |
|
As it turned out, Automating the Knight's Tour was a bit more difficult than I had realized. When initially researching the problem, I saw a relatively simple algorithm and figured, oh yeah, I can do that! Of course, without knowing the trick... there was no way I could have solved it in a long coffee break or lunch break. Either way, I was most impressed by DaveC's Excel VBA solution. And just to note, The Perch is much, much easier than the Knight's tour. For an added challenge, you can pick a new language. |
|
ALl sounds very Fear and Loathing to me... road trip, drinking and gambling with your lawyer!
|
|
3rd? I miss getting these early.
|
Re: Knocking Me Off The Perch
2009-08-19 09:13
•
by
It Girl
(unregistered)
|
Ha, and here I was flipping a coin with Guidenstern and Rosencrantz by the end of the second paragraph.... wait until he gets a load of those bats. |
Your netbook never leaves town without legal representation? Why, is it harboring illegally obtained debit card data? Wouldn't the drinks have been free if you'd gone to the casino first? |
|
What the hell does quote-unquote The Law of Large Numbers mean?
Surely that should be quote The Law of Large Numbers unquote. quote-unquote bothers the crap out of me. The whole point of it is to quote a phrase, but if you simply say quote-unquote before the phrase how do we know when the phrase is finished? This isn't grammer Nazism, it's logic Nazism. |
|
Ok, I've got the program ready, but I'm not sure where exactly to place my CasinoEmployeesTakeYouToALittleBasementRoomAndSweatYouException
|
Re: Knocking Me Off The Perch
2009-08-19 09:22
•
by
50% Opacity
(unregistered)
|
Especially when you can actually type quotes: "The Law of Large Numbers". |
|
OK, ignoring the irrelevant waffle about the multiple tables and runs of luck, here's a perl golf version at 92 characters, assuming you can bet any integer number of dollars above 10.
sub p{my($b)=@_;while($b>9){my$t=10;while((rand 38)<18){$b+=$t;$t=int($t*1.5);}$b-=$t;}$b;} |
Re: Knocking Me Off The Perch
2009-08-19 09:28
•
by
Code Dependent
|
I think it's Alex's way of reproducing the sound and feel of blathering legalese without having to remember what the lawyer said verbatim. Let's cut him some slack. |
Not sure when to stop... the obvious answer is when the money is all gone, so the single output will allways be zero!
The Perch does not specify that we should be the color oposit to the one that came 4 times? Also, the odds are 18/38 for red, 18/38 for black and 2/38 for green... |
Re: Knocking Me Off The Perch
2009-08-19 09:33
•
by
There is so much WTF in this I don't know where to start
(unregistered)
|
|
The roulette table has NO MEMORY of the previous sequence of events (black or red). Read this several times till you understand this concept.
Randomness is not the roulette table keeping a tally of all the reds and blacks in sequence and making sure there are the same number of each (ignoring the greens which I'll get to in a minute) or a fair-looking alternation of red and black sequences. The sequence of random black and red is truly random - 100 black followed by 100 red is JUST AS LIKELY as RED-BLACK-RED-BLACK (repeated forever) or RRRR-BBBB-RRRR-BBBB...or any other combination. Each subseqent outcome is completly unaffected by the previous colour. As far as the odds being 1:1 - the 2 greens are how the house winds. Yes - there are equal number of reds and blacks, so 1:1 payout looks like a good deal. However, there a 2 green possibilites on the table (i.e. neither red nor green) - this is why the house always win on average. Suggest your coding competition is scrapped in favour of reading 'Probabilities for Dummies' |
|
My first little book on mathematics did a good job of explaining how roulette works, and how roulette strategies don't. It ended with advice along the lines of: rather than play roulette, flush your money down the toilet; it's equally effective and saves the hassle of getting to the casino.
|
Re: Knocking Me Off The Perch
2009-08-19 09:43
•
by
Yazeran
(unregistered)
|
Especially considering that he explicitly mentioned something about being drunk.. I mean who here can honestly say that he/she would be able to remember precisely something a Lawyer has said (drunk or not)... ;-) Yours Yazeran Plan: To go to Mars one day with a hammer |
Re: Knocking Me Off The Perch
2009-08-19 09:45
•
by
Me
(unregistered)
|
|
"Suggest your coding competition is scrapped in favour of reading 'Probabilities for Dummies'"
Methinks the mention of "gambler's fallacy" in the original post means he already knows and he's just trolling for responses like yours ;) |
|
I'm afraid I don't understand the point of this problem.
The chances that something will hit a certain colour on the next roll are exactly the same no matter what was rolled before. So coding a solution to this will wind up exactly the same as if you just coded regular roulette. |
Suggest that you have never actually been gambling before. The lawyer in the story already states that The Perch was thought up in a situation "[w]herein both parties understand...the Gambler’s Fallacy" so it's useless to get on your soapbox and preach about a basic tenet of probability. I'm pretty sure we all know that one. This is about having fun, one of the things you're supposed to do at a casino (along with losing all your money due to the aforementioned Gambler's Fallacy). |
Re: Knocking Me Off The Perch
2009-08-19 09:46
•
by
James
(unregistered)
|
I was thinking that too but I am assuming that is part of the joke and the idea was to come up with some WTF code? |
Re: Knocking Me Off The Perch
2009-08-19 09:47
•
by
steenbergh
|
Also, it saves you the cost of renting a tux, so it might even be less money lost. Then again, calling a plumber to fix the drains might reverse that... |
Re: Knocking Me Off The Perch
2009-08-19 09:49
•
by
Yazeran
(unregistered)
|
Actually there is one sure way to win on the roulette: 1) Bet 1 dollar on red 2) If you win goto 1. 3) bet the double amount you did last time (bet on red again) 4) If you win goto 1. 5) Goto 3. It should be noted that you may need the entire worlds gross national product available for this to work.... (Not to mention that the casino should not have a limit on the maximum bet you can make, which incidentally exists exactly because of the recipe described above) Yours Yazeran Plan: To go to Mars one say with a hammer |
Re: Knocking Me Off The Perch
2009-08-19 09:53
•
by
Spelling Nazism
(unregistered)
|
|
And grammer (sic) is spelled grammar.
Captcha: Capio which sounds Italian, which reminds me of fascism. |
Re: Knocking Me Off The Perch
2009-08-19 09:55
•
by
ThatsALotOfGravy
(unregistered)
|
Woah woah woah, slow down. The chance of the combined event of getting black 100 times in a row is EXTREMELY low, on the order of 1 in 2^100 (let's ignore green). However, if it has already been black 99 times in a row, the chance of it being black again is still 1 in 2. |
Re: Knocking Me Off The Perch
2009-08-19 09:58
•
by
amischiefr
|
|
This is the same problem for any game like this, black jack is a perfect example.
Take your initial $10 bet. If you lose place a $20 bet. Continue doubling the bet until you win. Congratulations! You just won $10... That's why most tables have a min and a max, to limit the amount of times you can double up. |
Re: Knocking Me Off The Perch
2009-08-19 09:58
•
by
GettinSadda
|
FTFY |
Re: Knocking Me Off The Perch
2009-08-19 09:58
•
by
Rev. Creflo Baller
(unregistered)
|
|
He has, indeed, seen a lot more 4-in-a-rows than 5-in-a-rows. Approximately twice as many.
|
Re: Knocking Me Off The Perch
2009-08-19 09:59
•
by
@Deprecated
(unregistered)
|
Coincidentally, that is also the exact method used to dispose of all your money. |
|
Oh, you're talking about American Roulette. Not Roulette.
Just like American Football isn't usually played with one's foot... scnr... |
On what colour?
On what colour? Software requirements are getting vague these days... oh wait, they always were. |
|
Ok, let me write this function then. Firstly, the number of tables is irrelevant as the chance to with is 50% regardless of tables. Secondly, you don't specify how many runs to do in a single function, and provide no way to store state between runs, so I can only end the function when you can't play anymore. And of course, you can't play anymore when you reach $0.
So here's my function in C:
And for fun, here it is in Haskell:
And why not in perl:
Why yes, I am quite pedantic, how did you know? Captcha: ludus, nearly ludicrous? |
The quote wasn't saying that the odds of winning are 1 to 1, ie 50%. It was saying that the payoff for winning the bet are 1 to 1. If you bet $5, you get your original $5 back plus another $5. You win the amount of your bet. |
|
The specification is incomplete. "As soon as a table shows four consecutive blacks or reds, swoop in and place a bet." How big? Should it always be the minimum? Is the intention that you should play $10 if you have exactly $10 or >$25, and otherwise you should play the amount you have (since you won't have enough to place the second bet if you lose the first)? Or is part of the challenge figuring out the optimum (for some metric) amount to bet each time?
|
|
Returning 0 doesn't work. The minimum bet is $10. Your final total should be distributed between 0-9.
|
Re: Knocking Me Off The Perch
2009-08-19 10:10
•
by
Jim Cooper
(unregistered)
|
|
There's no need for any code, a calculator will do perfectly well.
In order to win $400 starting $10, with winning bets paying even money, the quickest way to get there is to win 6 times in a row, betting all you have each time (so you could get $640, actually). The odds for each bet are 18/37 (for normal roulette wheels with one zero), or 18/38 (for American roulette wheels with a zero and a double zero). Raising those numbers to the 6th power gets you the odds: 0.013 probability for normal wheels 0.011 probability for American wheels So about 1 chance in 100. As we all know, what the wheel span last time is completely irrelevant - although it is truly surprising the number of people who don't actually believe that in their heart of hearts :-) If you don't bet the whole lot every time it gets more difficult to work out :-) |
Re: Knocking Me Off The Perch
2009-08-19 10:10
•
by
Kanazuchi
(unregistered)
|
It's called the Martingale -- and it doesn't work. http://wizardofodds.com/askthewizard/bettingsystems-martingale.html |
Re: Knocking Me Off The Perch
2009-08-19 10:11
•
by
randomlyVarying
(unregistered)
|
|
Yes, the outcomes of two tosses (turn? role? death spiral?) of the roulette. Yes, the sequence is completely random. That does not mean, however, that all sequences are equally likely to occur.
For an entertaining summary, see: http://www.ted.com/talks/lang/eng/peter_donnelly_shows_how_stats_fool_juries.html |
|
I think the point of this exercise is not so much to program a mathematical proof of how and why you will go broke, but more to actually write the code that actually functions as described and watch it run. I suspect that if you do this you may be surprised at the results you will get. (and learn why some people actually win)
Back in the "before time" I coded up a battleship game in HP basic, you against the machine, no brains for the machine, just totally random, with a memory of where the pegs were. This got boring after a while (a very short while), so I made a few changes so the machine could play itself, fascinating for a few minutes, but a lot of paper was coming out of the teletype, so I eliminated all of the output except for the final win/lose results. Shortly after that I got a call from the system admin. Seems that eating up that kind of CPU time in 1975 was kinda frowned upon, go figure ;) The point is that I could have just put the variables down and calculated the result, but where is the fun in that. |
Not so, because you may end up with greater than zero but insufficient to meet the $10 minimum bet on the next spin... |
Re: Knocking Me Off The Perch
2009-08-19 10:18
•
by
Guillaume
(unregistered)
|
After a night like that, I'd probably spend that $0-9 on drinks. But yes, good point. |
Re: Knocking Me Off The Perch
2009-08-19 10:20
•
by
Jim Cooper
(unregistered)
|
|
BTW, in the calculations above, I left out step 3 (the betting 150% of a losing bet), as it wasn't clear when to stop betting*, so there's no way to work out how many bets can be placed. * Well, actually, it was. Anyone tempted to use this hare-brained scheme shouldn't place any bets at all, and should just drink $10 of beer :-) |
Re: Knocking Me Off The Perch
2009-08-19 10:24
•
by
Capt. Awesome
(unregistered)
|
An American football is a foot long. |
The probability is low, however equal any other combination of the same length. |
Re: Knocking Me Off The Perch
2009-08-19 10:26
•
by
sep332
(unregistered)
|
Yes, it's ludicrously low. But it's the EXACT SAME as the odd of getting R-B-R-B-R-B... for 100 bets in a row, or getting RRRR-BBBB-RRRR-BBBB... for 100 bets, or ANY exact sequence of 100. |
He didn't say it was a high probability, only that the probabilities of same-length sequences are equal. Which is true. ARGH. Three identical answers to the same question, and this WTF POS forum doesn't let me delete my post... |
|
I can't get this method to produce any winnings (like I suspected from the start). Most of the time I lose the first bet so I don't get anywhere. Also the complicated method of playing the against "streaks" of rolls does not have any greater chance of winning (as prediced). Still sometimes I can make a series of wins.
But most importantly the series always converges on $0, so it is impossible to keep this going forever. I'm not posting code, because it's messy and I have to get back to work. |
|
"I’ve seen a heckuva lot more 4-in-a-rows than I have 5-in-a-rows."
No, you've seen slightly less than 1/2 the number of 5-in-a-rows as 4-in-a-rows (would be exactly 1/2 except for greens. |
And by DaveC, I assume you mean BradC? Thanks! After cheating and reading the Wikipedia page, I started a second Excel VBA version that uses the Warnsdorff's algorithm (cool algorithm, Warnsdorff!! Much faster and more efficient than brute force!). I got the basic algorithm to work, but didn't get as far as designing a backup-and-retry if it didn't work from the start. |
|
In light of the losing condition be less than $10, here's my revised solution:
|
Re: Knocking Me Off The Perch
2009-08-19 10:43
•
by
aBase
(unregistered)
|
It's merely an American idiom, similar to calling a group of second-rate clubs "Premier League". |
|
The point of this "practice" clearly isn't to try coding a solution, but being a good enough programmer to analyze the problem first and realize there's no pattern to roulette so no code needs to be written.
|
| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Page 5 | Page 6 | Next » |