Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Purge trailing whitespace from euler examples
  • Loading branch information
Paul Cochrane committed Feb 23, 2015
1 parent 5b69f97 commit eac20d1
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 63 deletions.
4 changes: 2 additions & 2 deletions euler/prob003-eric256.pl
@@ -1,15 +1,15 @@
use v6;

sub is_prime ($num) {
for (2..^$num) {
for (2..^$num) {
return 0 unless $num % $_;
}
return 1;
};

class Primes {
has $.current = 0;

method next {
$!current++;
$!current++ until is_prime($.current);
Expand Down
10 changes: 5 additions & 5 deletions euler/prob006-polettix.pl
@@ -1,14 +1,14 @@
# The sum of the squares of the first ten natural numbers is,
#
#
# 1**2 + 2**2 + ... + 10**2 = 385
#
#
# The square of the sum of the first ten natural numbers is,
#
#
# (1 + 2 + ... + 10)**2 = 55**2 = 3025
#
#
# Hence the difference between the sum of the squares of the first
# ten natural numbers and the square of the sum is 3025 - 385 = 2640.
#
#
# Find the difference between the sum of the squares of the first
# one hundred natural numbers and the square of the sum.

Expand Down
2 changes: 1 addition & 1 deletion euler/prob008-duff2.pl
Expand Up @@ -3,7 +3,7 @@
my $num = "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450";

# Basically:
# 1. build a list of indices,
# 1. build a list of indices,
# 2. convert that into a list of 5 character strings that start at those indices,
# 3. convert that into a list of the product of the digits
# 4. sort the list from #3
Expand Down
4 changes: 2 additions & 2 deletions euler/prob009-polettix.pl
@@ -1,10 +1,10 @@
# A Pythagorean triplet is a set of three natural
# numbers, a b c, for which,
#
#
# a**2 + b**2 = c**2
#
# For example, 3**2 + 4**2 = 9 + 16 = 25 = 5**2.
#
#
# There exists exactly one Pythagorean triplet for which a + b + c = 1000.
# Find the product abc.

Expand Down
2 changes: 1 addition & 1 deletion euler/prob010-polettix.pl
@@ -1,5 +1,5 @@
# The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
#
#
# Find the sum of all the primes below two million.

use v6;
Expand Down
16 changes: 8 additions & 8 deletions euler/prob012-polettix.pl
@@ -1,25 +1,25 @@
# The sequence of triangle numbers is generated by adding the natural
# numbers. So the 7th triangle number would be
#
# 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.
#
#
# 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.
#
# The first ten terms would be:
#
#
# 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
#
#
# Let us list the factors of the first seven triangle numbers:
#
#
# 1: 1
# 3: 1,3
# 6: 1,2,3,6
# 10: 1,2,5,10
# 15: 1,3,5,15
# 21: 1,3,7,21
# 28: 1,2,4,7,14,28
#
#
# We can see that 28 is the first triangle number to have over five
# divisors.
#
#
# What is the value of the first triangle number to have over five
# hundred divisors?

Expand Down
58 changes: 29 additions & 29 deletions euler/prob017-duff.pl
Expand Up @@ -4,36 +4,36 @@

# playing with multiple dispatch

multi sub num-to-word(0) { 'zero' }
multi sub num-to-word(1) { 'one' }
multi sub num-to-word(2) { 'two' }
multi sub num-to-word(3) { 'three' }
multi sub num-to-word(4) { 'four' }
multi sub num-to-word(5) { 'five' }
multi sub num-to-word(6) { 'six' }
multi sub num-to-word(7) { 'seven' }
multi sub num-to-word(8) { 'eight' }
multi sub num-to-word(9) { 'nine' }
multi sub num-to-word(10) { 'ten' }
multi sub num-to-word(11) { 'eleven' }
multi sub num-to-word(12) { 'twelve' }
multi sub num-to-word(13) { 'thirteen' }
multi sub num-to-word(14) { 'fourteen' }
multi sub num-to-word(15) { 'fifteen' }
multi sub num-to-word(16) { 'sixteen' }
multi sub num-to-word(17) { 'seventeen' }
multi sub num-to-word(18) { 'eighteen' }
multi sub num-to-word(19) { 'nineteen' }
multi sub num-to-word(20) { 'twenty' }
multi sub num-to-word(30) { 'thirty' }
multi sub num-to-word(40) { 'forty' }
multi sub num-to-word(50) { 'fifty' }
multi sub num-to-word(60) { 'sixty' }
multi sub num-to-word(70) { 'seventy' }
multi sub num-to-word(80) { 'eighty' }
multi sub num-to-word(90) { 'ninety' }
multi sub num-to-word(0) { 'zero' }
multi sub num-to-word(1) { 'one' }
multi sub num-to-word(2) { 'two' }
multi sub num-to-word(3) { 'three' }
multi sub num-to-word(4) { 'four' }
multi sub num-to-word(5) { 'five' }
multi sub num-to-word(6) { 'six' }
multi sub num-to-word(7) { 'seven' }
multi sub num-to-word(8) { 'eight' }
multi sub num-to-word(9) { 'nine' }
multi sub num-to-word(10) { 'ten' }
multi sub num-to-word(11) { 'eleven' }
multi sub num-to-word(12) { 'twelve' }
multi sub num-to-word(13) { 'thirteen' }
multi sub num-to-word(14) { 'fourteen' }
multi sub num-to-word(15) { 'fifteen' }
multi sub num-to-word(16) { 'sixteen' }
multi sub num-to-word(17) { 'seventeen' }
multi sub num-to-word(18) { 'eighteen' }
multi sub num-to-word(19) { 'nineteen' }
multi sub num-to-word(20) { 'twenty' }
multi sub num-to-word(30) { 'thirty' }
multi sub num-to-word(40) { 'forty' }
multi sub num-to-word(50) { 'fifty' }
multi sub num-to-word(60) { 'sixty' }
multi sub num-to-word(70) { 'seventy' }
multi sub num-to-word(80) { 'eighty' }
multi sub num-to-word(90) { 'ninety' }

multi sub num-to-word($n is copy) {
multi sub num-to-word($n is copy) {
my (@words,$m);

# The next three lines should be in a loop, but it's not really
Expand Down
6 changes: 3 additions & 3 deletions euler/prob024-moritz.pl
@@ -1,12 +1,12 @@
use v6;

# idea: the last 9 digits can be permuted in 9! = 362880 ways.
# so there are 9! numbers that start with a 0, 9! numbers that start with a
# 1 etc.
# so there are 9! numbers that start with a 0, 9! numbers that start with a
# 1 etc.
# So to get the first digit, divide our target by 9!, and the rounded
# result is the first digit.
#
# then we remove the first digit from the pool of available digits,
# then we remove the first digit from the pool of available digits,
# divide the rest by 8!, round, store result in $n. Then the $n'th
# lowest available digit is the second digit that we search.

Expand Down
6 changes: 3 additions & 3 deletions euler/prob025-polettix.pl
@@ -1,8 +1,8 @@
# The Fibonacci sequence is defined by the recurrence relation:
#
#
# Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1.
# Hence the first 12 terms will be:
#
#
# F1 = 1
# F2 = 1
# F3 = 2
Expand All @@ -17,7 +17,7 @@
# F12 = 144
#
# The 12th term, F12, is the first term to contain three digits.
#
#
# What is the first term in the Fibonacci sequence to contain 1000 digits?

use v6;
Expand Down
6 changes: 3 additions & 3 deletions euler/prob029-polettix.pl
@@ -1,15 +1,15 @@
# Consider all integer combinations of a**b for 2 < a < 5 and 2 < b < 5:
#
#
# 2**2=4, 2**3=8, 2**4=16, 2**5=32
# 3**2=9, 3**3=27, 3**4=81, 3**5=243
# 4**2=16, 4**3=64, 4**4=256, 4**5=1024
# 5**2=25, 5**3=125, 5**4=625, 5**5=3125
#
# If they are then placed in numerical order, with any repeats
# removed, we get the following sequence of 15 distinct terms:
#
#
# 4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125
#
#
# How many distinct terms are in the sequence generated by
# a**b for 2 < a < 100 and 2 < b < 100?

Expand Down
2 changes: 1 addition & 1 deletion euler/prob036-xenu.pl
@@ -1,6 +1,6 @@
#
# it's very slow, it took several hours to complete on Intel Core i7 920
# DON'T TRY EXECUTING THIS SCRIPT WITH RAKUDO 2010.08 OR OLDER!
# DON'T TRY EXECUTING THIS SCRIPT WITH RAKUDO 2010.08 OR OLDER!
# Because of memory leak in these versions, this code eats tens of gigabytes of RAM
#
use v6;
Expand Down
6 changes: 3 additions & 3 deletions euler/prob052-duff.pl
Expand Up @@ -6,10 +6,10 @@
my $n = $mag; # number to start searching from
loop {
my $s = (2*$n).comb.sort;
last if
last if
$s eq (3*$n).comb.sort &&
$s eq (4*$n).comb.sort &&
$s eq (5*$n).comb.sort &&
$s eq (4*$n).comb.sort &&
$s eq (5*$n).comb.sort &&
$s eq (6*$n).comb.sort;
$n++;
if log10(6*$n).Int > log10(2*$n).Int {
Expand Down
4 changes: 2 additions & 2 deletions euler/prob081-moritz.pl
Expand Up @@ -12,8 +12,8 @@

say "Size: $max-x x $max-y";

@m[0][$_] += @m[0][$_-1] for 1..$max-x-1;
@m[$_][0] += @m[$_-1][0] for 1..$max-y-1;
@m[0][$_] += @m[0][$_-1] for 1..$max-x-1;
@m[$_][0] += @m[$_-1][0] for 1..$max-y-1;

for 1..$max-y-1 -> $y {
for 1..$max-x-1 -> $x {
Expand Down

0 comments on commit eac20d1

Please sign in to comment.