Skip to content

Commit a0aedbd

Browse files
committed
[euler] add solution for problem 15 (just arithmetic, nothing cool here)
1 parent 31c1f20 commit a0aedbd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

euler/prob015-felher.pl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use v6;
2+
3+
# This program doesn't really simulate anything and is only here for the sake of
4+
# completeness. But to show something cool about perl6 let's at least introduce
5+
# the faculty as the ! postfix operator
6+
my Int sub postfix:<!>(Int $n) { [*] 1 .. $n }
7+
8+
# The strategy for this Problem is quite straight-forward: To move from the
9+
# upper left to the lower right corner of an NxN grid without ever going in the
10+
# wrong direction one has to go down N times and one has to go right N times.
11+
# The problem is therefore equivalent to "How many distinguishable ways exist to
12+
# order N white and N black balls?" and the answer to that problem is:
13+
14+
my \N = 20;
15+
say (2 * N)!/(N! * N!);

0 commit comments

Comments
 (0)