Skip to content

Commit 47b40b1

Browse files
committed
[euler] problem 100
1 parent f55f5e4 commit 47b40b1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

categories/euler/prob100-andreoss.pl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use v6;
2+
3+
=begin pod
4+
5+
=TITLE XOR decryption
6+
7+
=AUTHOR Andrei Osipov
8+
9+
L<https://projecteuler.net/problem=100>
10+
11+
If a box contains twenty-one coloured discs, composed of fifteen blue discs and six red discs, and two discs were taken at random, it can be seen that the probability of taking two blue discs, P(BB) = (15/21)×(14/20) = 1/2.
12+
13+
The next such arrangement, for which there is exactly 50% chance of taking two blue discs at random, is a box containing eighty-five blue discs and thirty-five red discs.
14+
15+
By finding the first arrangement to contain over 10¹² = 1,000,000,000,000 discs in total, determine the number of blue discs that the box would contain.
16+
17+
Expected result: 756872327473
18+
19+
=end pod
20+
21+
my $blue = 15;
22+
my $total = 21;
23+
24+
( $blue ,
25+
$total ) = 3 * $blue + 2 * $total - 2,
26+
4 * $blue + 3 * $total - 3
27+
while $total <= 10 ** 12 ;
28+
29+
say $blue;

0 commit comments

Comments
 (0)