Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[euler] problem 100
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| use v6; | ||
|
|
||
| =begin pod | ||
| =TITLE XOR decryption | ||
| =AUTHOR Andrei Osipov | ||
| L<https://projecteuler.net/problem=100> | ||
| 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. | ||
| 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. | ||
| 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. | ||
| Expected result: 756872327473 | ||
| =end pod | ||
|
|
||
| my $blue = 15; | ||
| my $total = 21; | ||
|
|
||
| ( $blue , | ||
| $total ) = 3 * $blue + 2 * $total - 2, | ||
| 4 * $blue + 3 * $total - 3 | ||
| while $total <= 10 ** 12 ; | ||
|
|
||
| say $blue; |