So I draw a little diagram like this
to show that when we pick seven numbers, that includes seven different possible combinations of the six numbers they draw.#234567 1#34567 12#4567 123#567 1234#67 12345#7 123456#
"I see", says my significant other, "so seven numbers is like playing seven games, so eight numbers is like having eight games?"
Aha, no, I say, because with eight numbers, you have ... hold on sweetheart, let me write a script for this.
So I write this:
which dutifully prints out@numbers = (1..8); for ( 0 .. 7 ) { @outer = @numbers; $outer[$_] = '#'; for ( 0 .. 7 ) { @inner = @outer; unless ( $inner[$_] eq '#' ) { $inner[$_] = '#'; print @inner, $/; $count++; } } } print "$count possible winning combinations\n";
and shows that a System 8 entry is the same as 56 games.##345678 #2#45678 #23#5678 etc
OK, says the longsuffering Significant Other, "...and with nine numbers?"
At which point I realise my code isn't very smart.
What would other monks write if they wanted to perform this exercise on an array with an arbitrary number of items? And how short could it be?
($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print
In reply to Lottery combinations golf by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |