Comment On Knocking Me Off The Perch

Not too long ago, I went up to Windsor, Ontario with my lawyer, Mr. Van Dress. Like my netbook, I never like to leave town without legal representation. Since there are really only three things to do in Windsor – drink, gamble, and buy Cuban cigars – we picked up some stogies, drank until we were confident we’d win, and headed over to the casino. [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5 | Page 6Next »

Re: Knocking Me Off The Perch

2009-08-19 00:51 • by Alex Papadimoulis

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.

Re: Knocking Me Off The Perch

2009-08-19 09:05 • by JK (unregistered)
ALl sounds very Fear and Loathing to me... road trip, drinking and gambling with your lawyer!

Re: Knocking Me Off The Perch

2009-08-19 09:13 • by JoPoser (unregistered)
3rd? I miss getting these early.

Re: Knocking Me Off The Perch

2009-08-19 09:13 • by It Girl (unregistered)
282595 in reply to 282592
JK:
ALl sounds very Fear and Loathing to me... road trip, drinking and gambling with your lawyer!


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.

Re: Knocking Me Off The Perch

2009-08-19 09:18 • by Code Dependent
Like my netbook, I never like to leave town without legal representation.
Your netbook never leaves town without legal representation? Why, is it harboring illegally obtained debit card data?
...drank until we were confident we’d win, and headed over to the casino.
Wouldn't the drinks have been free if you'd gone to the casino first?

Re: Knocking Me Off The Perch

2009-08-19 09:18 • by thnurg (unregistered)
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.

Re: Knocking Me Off The Perch

2009-08-19 09:20 • by DOA
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)
282599 in reply to 282597
thnurg:
What the hell does quote-unquote The Law of Large Numbers mean?


Especially when you can actually type quotes: "The Law of Large Numbers".

Re: Knocking Me Off The Perch

2009-08-19 09:24 • by Me (unregistered)
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
282603 in reply to 282597
thnurg:
What the hell does quote-unquote The Law of Large Numbers mean? *snip*
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 what is expected...

2009-08-19 09:33 • by Daniel (unregistered)

There should be two inputs (starting bankroll and number of tables) and a single output (final bankroll)

Not sure when to stop... the obvious answer is when the money is all gone, so the single output will allways be zero!

The odds for betting on black or red are 1-to-1.

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'

Re: Knocking Me Off The Perch

2009-08-19 09:38 • by Dazed (unregistered)
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)
282608 in reply to 282603
Code Dependent:
thnurg:
What the hell does quote-unquote The Law of Large Numbers mean? *snip*
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.

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)
282609 in reply to 282606
"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 ;)

Re: Knocking Me Off The Perch

2009-08-19 09:45 • by Addison (unregistered)
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.

Re: Knocking Me Off The Perch

2009-08-19 09:46 • by MC (unregistered)
Suggest your coding competition is scrapped in favour of reading 'Probabilities for Dummies'


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)
282613 in reply to 282606
There is so much WTF in this I don't know where to start:
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'


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
282614 in reply to 282607
Dazed:
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.


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)
282615 in reply to 282606
There is so much WTF in this I don't know where to start:
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'

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)
282616 in reply to 282597
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)
282617 in reply to 282606
There is so much WTF in this I don't know where to start:
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.


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
282618 in reply to 282579
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
282619 in reply to 282615
Yazeran:
Actually there is one sure way to win on the roulette:

1) Own the casino
2) ???
3) Profit!

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)
282621 in reply to 282615
Yazeran:
There is so much WTF in this I don't know where to start:
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'

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


Coincidentally, that is also the exact method used to dispose of all your money.

Re: Knocking Me Off The Perch

2009-08-19 09:59 • by Sid2K7 (unregistered)
Oh, you're talking about American Roulette. Not Roulette.
Just like American Football isn't usually played with one's foot...

scnr...

Re: Knocking Me Off The Perch

2009-08-19 09:59 • by Severity One
As soon as a table shows four consecutive blacks or reds, swoop in and place a bet.

On what colour?

Otherwise, place another bet worth 150% of the previous bet (instead of $10, place $15).

On what colour?

Software requirements are getting vague these days... oh wait, they always were.

Re: Knocking Me Off The Perch

2009-08-19 10:01 • by Guillaume (unregistered)
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:

int perch(int numTables, int initialMoney)
{
return 0;
}


And for fun, here it is in Haskell:

perch :: (Num a) => a -> a -> a
perch nt m = 0


And why not in perl:

sub perch
{
0;
}


Why yes, I am quite pedantic, how did you know?

Captcha: ludus, nearly ludicrous?

Re: Knocking Me Off The Perch

2009-08-19 10:03 • by Dan (unregistered)
The odds for betting on black or red are 1-to-1.


Not quite. Only 19 out of 40 spots are red; the same applies for black.

When green comes up, red and black both lose.


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.

Re: Knocking Me Off The Perch

2009-08-19 10:03 • by pjt33
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?

Re: Knocking Me Off The Perch

2009-08-19 10:09 • by Kiriai (unregistered)
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)
282628 in reply to 282600
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)
282629 in reply to 282615
Yazeran:
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....
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)
282630 in reply to 282617
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

Re: Knocking Me Off The Perch

2009-08-19 10:11 • by fmtaylor (unregistered)
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.

Re: Knocking Me Off The Perch

2009-08-19 10:12 • by Jim (unregistered)
echo '$0'

Re: Not sure what is expected...

2009-08-19 10:18 • by Julia
282633 in reply to 282605
Daniel:

Not sure when to stop... the obvious answer is when the money is all gone, so the single output will allways be zero!


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)
282634 in reply to 282627
Kiriai:
Returning 0 doesn't work. The minimum bet is $10. Your final total should be distributed between 0-9.


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)
282635 in reply to 282628

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)
282636 in reply to 282622
Sid2K7:
Oh, you're talking about American Roulette. Not Roulette.
Just like American Football isn't usually played with one's foot...

scnr...


An American football is a foot long.

Re: Knocking Me Off The Perch

2009-08-19 10:25 • by mol1111
282637 in reply to 282617
ThatsALotOfGravy:
There is so much WTF in this I don't know where to start:
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.


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).


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)
282638 in reply to 282617
ThatsALotOfGravy:
There is so much WTF in this I don't know where to start:
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.


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.


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.

Re: Knocking Me Off The Perch

2009-08-19 10:26 • by Adriano
282639 in reply to 282617
ThatsALotOfGravy:
There is so much WTF in this I don't know where to start:
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.


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.

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...

Re: Knocking Me Off The Perch

2009-08-19 10:28 • by SlyEcho
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.

Re: Knocking Me Off The Perch

2009-08-19 10:31 • by Michael A (unregistered)
"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.

Re: Knocking Me Off The Perch

2009-08-19 10:37 • by BradC
282642 in reply to 282579
Alex Papadimoulis:

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 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.

Re: Knocking Me Off The Perch

2009-08-19 10:41 • by Guillaume (unregistered)
In light of the losing condition be less than $10, here's my revised solution:


int perch(int numTables, int m)
{
int bet = 10;
int win = 0;
while(m >= 10)
{
if(win)
bet += bet >> 1;
else
bet = 10;
if(bet > m)
bet = 10;
m += (win = (rand() % 2)) ? bet : -bet;
}
return m;
}

Re: Knocking Me Off The Perch

2009-08-19 10:43 • by aBase (unregistered)
282644 in reply to 282622
Sid2K7:
Oh, you're talking about American Roulette. Not Roulette.
Just like American Football isn't usually played with one's foot...

scnr...
It's merely an American idiom, similar to calling a group of second-rate clubs "Premier League".

Re: Knocking Me Off The Perch

2009-08-19 10:44 • by CommonSense (unregistered)
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.
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5 | Page 6Next »

Add Comment