Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove whitespace [Gun.io WhitespaceBot]

  • Loading branch information...
commit 9b60042593f45c7c965b3f4f3583c78833d48949 1 parent 3e5a269
Gun.io Whitespace Robot authored
View
30 bin/bench
@@ -12,12 +12,12 @@ BEGIN {
use List::Util qw{min max};
use Scalar::Util qw{looks_like_number};
-use BenchTools;
+use BenchTools;
if (grep{m/-h(?:elp)?/} @ARGV) {
print qq{
USAGE: bench [output_type] [language] [problem] [options]
-
+
output_type:
report: prints a report to STDOUT with an overview of what was run (default)
json: encodes the data collected from all runs to JSON and then prints to STDOUT
@@ -25,19 +25,19 @@ if (grep{m/-h(?:elp)?/} @ARGV) {
languages are expected to be non-numeric strings.
problems are expected to be numeric strings.
- It is possible to ask for specific solutions to a problem can be done by listing a problem like 000:01,02
+ It is possible to ask for specific solutions to a problem can be done by listing a problem like 000:01,02
options:
--count=NNN (default is 100)
- --order=XXX
+ --order=XXX
EXAMPLES:
- bench perl5 0
- bench 0 --count=10 --order=language
- bench json 000 > all_000.json
- bench rawdata perl5 rakudo ruby
- bin/bench 0:2 1:1,3 2 perl5 --count=10
+ bench perl5 0
+ bench 0 --count=10 --order=language
+ bench json 000 > all_000.json
+ bench rawdata perl5 rakudo ruby
+ bin/bench 0:2 1:1,3 2 perl5 --count=10
\n} ;
exit;
}
@@ -76,9 +76,9 @@ $requested->{lang} = languages_hash unless defined $requested->{lang};
$requested->{prob} = problems_hash unless defined $requested->{prob} || $requested->{benchee};
map{ $requested->{$_} = [sort keys %{$requested->{$_}}] } grep{$_ ne 'opt'} keys %$requested; #revert the unique values to a
-$requested->{interp} = {map{ $_ => [map{$_}
- grep{ -x $_ }
- @{config()->{language}->{$_}->{interp}}
+$requested->{interp} = {map{ $_ => [map{$_}
+ grep{ -x $_ }
+ @{config()->{language}->{$_}->{interp}}
]
} @{$requested->{lang}}
};
@@ -91,7 +91,7 @@ die "No Euler Problem for that language" unless @$runs;
my $order_numeric = { map { $_ => 1 } qw/min avg max file total/ };
-if (scalar(@$runs)
+if (scalar(@$runs)
&& defined $requested->{opt}->{order}
&& scalar( grep{$_ eq $requested->{opt}->{order}} keys %{$runs->[0]} )) {
$runs = ($order_numeric->{$requested->{opt}->{order}})
@@ -110,7 +110,7 @@ sub report {
max( map{length} map{$_->{interpreter}} @$runs ),
max( map{length} (defined $_->{problems})?map{$_->{problem}}@$runs:'---'),
max( map{length} map{$_->{file}} @$runs );
- printf qq{$root_fmt min max avg total\n}, '', '', '', '';
+ printf qq{$root_fmt min max avg total\n}, '', '', '', '';
map{ my $row = $_;
printf qq{$root_fmt %02.4f %02.4f %02.4f %02.4f\n},
@@ -125,6 +125,6 @@ sub json {
print encode_json($runs);
}
sub graph {
- D {GRAPH => $runs};
+ D {GRAPH => $runs};
}
View
8 bin/stat
@@ -12,7 +12,7 @@ BEGIN {
use List::Util qw{min max};
use Scalar::Util qw{looks_like_number};
-use BenchTools;
+use BenchTools;
# what are we to be doing (overview | report)
my $cmd = (defined $ARGV[0] && main->can($ARGV[0])) ? shift @ARGV : 'overview' ;
@@ -23,8 +23,8 @@ sub overview {
my $fmt = join ' ', '%8s', map{sprintf q{%%%ds}, length($_)} languages;
$fmt.="\n";
printf $fmt, ' ', languages;
-printf $fmt, '+1 solve', map{ my $L = $_;
- scalar( grep{$_>1} map{scalar(keys %$_) } values %{ solutions->{$L} } )
+printf $fmt, '+1 solve', map{ my $L = $_;
+ scalar( grep{$_>1} map{scalar(keys %$_) } values %{ solutions->{$L} } )
} languages;
printf $fmt, 'done in', map{sprintf q{%d/%d}, scalar( keys %{ solutions->{$_}}), $total_solutions } languages;
}
@@ -34,7 +34,7 @@ sub report {
$fmt.="\n";
printf $fmt, ' ', languages;
for my $prob ( sort keys %{ problems_hash() } ) {
- printf $fmt, $prob, map{($_ eq '0')? '-' : $_ }
+ printf $fmt, $prob, map{($_ eq '0')? '-' : $_ }
map{ scalar( keys %{ solutions->{$_}->{$prob} })
} languages;
}
View
2  compiled_language_support.txt
@@ -3,7 +3,7 @@ Introduction
To allow compiled lanuages to be run, we have a two pass compile
and run. The first pass takes a configurable script name, exec's
that script passing the current file. The script will then
- output another command to be run. It's this command that is
+ output another command to be run. It's this command that is
acutally timed.
All this is done in a jail, which is deleted after each run. No
View
6 inc/Module/AutoInstall.pm
@@ -22,7 +22,7 @@ my ( $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly );
my ( $PostambleActions, $PostambleUsed );
# See if it's a testing or non-interactive session
-_accept_default( $ENV{AUTOMATED_TESTING} or ! -t STDIN );
+_accept_default( $ENV{AUTOMATED_TESTING} or ! -t STDIN );
_init();
sub _accept_default {
@@ -363,7 +363,7 @@ sub _install_cpanplus {
$conf->set_conf( makeflags => $makeflags );
$conf->set_conf( prereqs => 1 );
-
+
while ( my ( $key, $val ) = splice( @config, 0, 2 ) ) {
$conf->set_conf( $key, $val );
@@ -653,7 +653,7 @@ sub _version_check {
# check for version numbers that are not in decimal format
if ( ref($cur) or ref($min) or $cur =~ /v|\..*\./ or $min =~ /v|\..*\./ ) {
if ( ( $version::VERSION or defined( _load('version') )) and
- version->can('new')
+ version->can('new')
) {
# use version.pm if it is installed.
View
4 inc/Module/Install/Fetch.pm
@@ -13,13 +13,13 @@ BEGIN {
sub get_file {
my ($self, %args) = @_;
- my ($scheme, $host, $path, $file) =
+ my ($scheme, $host, $path, $file) =
$args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) {
$args{url} = $args{ftp_url}
or (warn("LWP support unavailable!\n"), return);
- ($scheme, $host, $path, $file) =
+ ($scheme, $host, $path, $file) =
$args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
}
View
8 inc/Module/Install/Makefile.pm
@@ -64,7 +64,7 @@ sub clean_files {
my $self = shift;
my $clean = $self->makemaker_args->{clean} ||= {};
%$clean = (
- %$clean,
+ %$clean,
FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_),
);
}
@@ -73,7 +73,7 @@ sub realclean_files {
my $self = shift;
my $realclean = $self->makemaker_args->{realclean} ||= {};
%$realclean = (
- %$realclean,
+ %$realclean,
FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_),
);
}
@@ -124,7 +124,7 @@ sub write {
$self->configure_requires( 'ExtUtils::MakeMaker' => $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/ );
- # Generate the
+ # Generate the
my $args = $self->makemaker_args;
$args->{DISTNAME} = $self->name;
$args->{NAME} = $self->module_name || $self->name;
@@ -194,7 +194,7 @@ sub fix_up_makefile {
my $top_class = ref($self->_top) || '';
my $top_version = $self->_top->VERSION || '';
- my $preamble = $self->preamble
+ my $preamble = $self->preamble
? "# Preamble by $top_class $top_version\n"
. $self->preamble
: '';
View
26 lib/BenchTools.pm
@@ -9,7 +9,7 @@ use Data::Dumper;
use Scalar::Util qw{looks_like_number};
use List::Util qw{min max};
use YAML qw{LoadFile};
-use Benchmark::Stopwatch::Pause;
+use Benchmark::Stopwatch::Pause;
use Exporter qw{import};
use Memoize;
@@ -29,10 +29,10 @@ our @EXPORT = qw{
run_command
};
-sub D (@){print Dumper(@_)}; #so I'm lazy
+sub D (@){print Dumper(@_)}; #so I'm lazy
memoize('root_dir');
-sub root_dir {
+sub root_dir {
my $root_dir = [fileparse(abs_path(__FILE__))]->[1];
my $base_dir = base_dir();
$root_dir =~ s/(.*)$base_dir.?/$1/; # cd ..
@@ -57,15 +57,15 @@ memoize('solutions');
sub solutions {
my $root_dir = root_dir();
my $solutions = {};
- find(sub{ my $p = $File::Find::name;
- $p =~ s/$root_dir//;
+ find(sub{ my $p = $File::Find::name;
+ $p =~ s/$root_dir//;
my ($lang,$prob,$solution) = split /[\/]/, $p;
$solutions->{$lang}->{$prob}->{$solution} = $File::Find::name
- if $lang !~ m/^(?:bin|inc|[.]git)/
+ if $lang !~ m/^(?:bin|inc|[.]git)/
&& defined $lang # language should be in a useful format
&& length $lang
&& defined $solution # we should have a solution
- && length $solution
+ && length $solution
&& $solution !~ m/^[.]/ # hide any 'hidden' file
;
}, $root_dir);
@@ -85,18 +85,18 @@ sub languages_hash { return {map{$_=>1} languages } }
memoize('build_runs');
sub build_runs {
my $requested = shift;
- [ map{ my $lang=$_;
+ [ map{ my $lang=$_;
my $problem_set = config()->{language}->{$lang}->{problem_set} || $lang;
map { my $interp = $_;
-
+
system(config()->{language}->{$lang}->{pre_run})
if defined config()->{language}->{$lang}->{pre_run};
-
+
my @benchee =
map { { language => $lang,
interpreter => $interp,
file => $_,
- %{ run_command( join(' ', $interp, $_,
+ %{ run_command( join(' ', $interp, $_,
(config()->{hide_cmd_output}) ? '&> /dev/null' : ''
),
$requested->{opt}->{count}
@@ -104,7 +104,7 @@ sub build_runs {
},
}
} @{ $requested->{benchee}};
-
+
my @probs =
map{ my ($prob,@imp) = split /[:,]/, $_;
return 'xxx' unless defined $prob;
@@ -131,7 +131,7 @@ sub build_runs {
if defined config()->{language}->{$lang}->{post_run};
grep{defined} @benchee, @probs;
-
+
} @{ $requested->{interp}->{$lang} } #2 for every interep for that language in the config
} @{$requested->{lang}} #1 for every language requested
View
4 perl5/002/01.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl
use strict;
use warnings;
use Memoize;
@@ -22,7 +22,7 @@ sub fib {
my $i = 2; # we really could start anywhere but we know that 1 = 1 and it's not even
my $sum = 0;
while ((my $f = fib($i++)) < 4000000) {
- $sum += $f unless $f %2;
+ $sum += $f unless $f %2;
}
print $sum;
View
8 perl5/044/01.pl
@@ -5,13 +5,13 @@
# Problem 44
# 23 May 2003
-#
+#
# Pentagonal numbers are generated by the formula, Pn=n(3n-1)/2. The first ten pentagonal numbers are:
-#
+#
# 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ...
-#
+#
# It can be seen that P4 + P7 = 22 + 70 = 92 = P8. However, their difference, 70 22 = 48, is not pentagonal.
-#
+#
# Find the smallest pair of pentagonal numbers for which their sum and difference is pentagonal; what is their difference?
my $min_diff;
View
2  perl5/066/01.pl
@@ -19,7 +19,7 @@
my $maxD;
my $maxX=-1;
-for (2..1000) {
+for (2..1000) {
my $D = $_;
next unless squarefree($D);
my @sol = Math::Pell->new({D=>$D})->find_minimal_sol;
View
4 perl5/079/01.pl
@@ -8,7 +8,7 @@
#
#The text file, keylog.txt, contains fifty successful login attempts.
#
-#Given that the three characters are always asked for in order, analyse the file so as to determine the secret passcode of unknown length.
+#Given that the three characters are always asked for in order, analyse the file so as to determine the secret passcode of unknown length.
@@ -44,7 +44,7 @@
$passcode =~ s/$third(.*)$second/$second$1$third/;
#print "entry: $entry, passcode: $passcode\n";
-
+
#remove duplicates:
my %count;
$passcode = join('', map { $count{ $_ }++ ? '' : $_ } split //, $passcode );
View
6 perl6/003/01.pl
@@ -25,17 +25,17 @@
# uncomment & rename method for easy conversion to normal sub :)
#my $n = @_.shift;
my $n = $!cur;
-
+
return 0 if $n % 2 == 0;
return 1 if $n < 4;
-
+
my $x = 3;
while ( $x <= sqrt $n ) {
return 0 unless $n % $x;
$x += 2;
}
return 1;
- }
+ }
}
my $to_factor = 600851475143;
View
4 perl6/004/01.pl
@@ -3,9 +3,9 @@
# Problem 4
# 16 November 2001
-#
+#
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.
-#
+#
# Find the largest palindrome made from the product of two 3-digit numbers.
View
4 perl6/017/01.pl
@@ -3,7 +3,7 @@
# Euler Project #17: http://projecteuler.net/index.php?section=problems&id=17
# If the numbers 1 to 5 are written out in words: one, two, three, four, five,
# then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
-#
+#
# If all the numbers from 1 to 1000 (one thousand) inclusive were written out in
# words, how many letters would be used?
#
@@ -65,7 +65,7 @@ (%number_names, $number)
$name ~= %number_names{$biggest};
$n -= $biggest;
}
- return $name;
+ return $name;
}
my $letter = 0;
View
4 perl6/017/02.pl
@@ -3,7 +3,7 @@
# Euler Project #17: http://projecteuler.net/index.php?section=problems&id=17
# If the numbers 1 to 5 are written out in words: one, two, three, four, five,
# then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
-#
+#
# If all the numbers from 1 to 1000 (one thousand) inclusive were written out in
# words, how many letters would be used?
#
@@ -62,7 +62,7 @@ (@numbers, %number_lengths, $number)
$n -= $number;
}
}
- return $length;
+ return $length;
}
my @numbers = %number_lengths.keys.map({+$_}).sort.reverse;
View
2  perl6/017/03.pl
@@ -3,7 +3,7 @@
# Euler Project #17: http://projecteuler.net/index.php?section=problems&id=17
# If the numbers 1 to 5 are written out in words: one, two, three, four, five,
# then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
-#
+#
# If all the numbers from 1 to 1000 (one thousand) inclusive were written out in
# words, how many letters would be used?
#
View
6 perl6/036/01.pl
@@ -13,9 +13,9 @@ ($n)
my $upper_limit = 10000; # should be 1000000, but that takes forever to run on
# Rakudo right now.
-my @p = gather loop (my $i = 1; $i < $upper_limit; $i+=2)
- {
- take +$i if IsPalindromicIn10($i) && IsPalindromicIn2($i);
+my @p = gather loop (my $i = 1; $i < $upper_limit; $i+=2)
+ {
+ take +$i if IsPalindromicIn10($i) && IsPalindromicIn2($i);
};
@p.perl.say;
@p.map({sprintf("%b", $_)}).perl.say;
View
6 perl6/038/01.pl
@@ -26,9 +26,9 @@ (@seeds, $n)
# Okay: we know that ConcatenatedProduct(9, 5) is a solution, 918273645. We're
# looking for the max solution, and the beginning of each answer is our seed
-# number. Therefore, seed numbers must have a first digit of 9 to be worth
-# considering. We can rule out 2 or 3 digit seeds, because any multiplier
-# greater than 1 will give a 3 or 4 digit result (respectively), and there's
+# number. Therefore, seed numbers must have a first digit of 9 to be worth
+# considering. We can rule out 2 or 3 digit seeds, because any multiplier
+# greater than 1 will give a 3 or 4 digit result (respectively), and there's
# no integer solution N for 2+3N = 9 or 3+4N = 9.
my @candidates;
View
8 perl6/052/01.pl
@@ -1,8 +1,8 @@
use v6;
-# based on code by PerlJam
+# based on code by PerlJam
# btilly points out that $n must be divisible by 9, which leads to a further factor
-# of three speedup.
+# of three speedup.
my $pass_start = 5; # start at the first number divisible by nine after this one
my $pass_end = 17; # 17 * 6 has an additional digit
@@ -13,7 +13,7 @@
my $digits = (2*$n).comb.sort;
next unless ($digits ~~ /0|5/);
# say "$n ==> $digits";
-
+
if $digits eq (3*$n).comb.sort
&& $digits eq (4*$n).comb.sort
&& $digits eq (5*$n).comb.sort
@@ -23,7 +23,7 @@
exit 0;
}
}
-
+
$pass_start *= 10;
$pass_end *= 10;
}
View
4 scala/002/01.scala
@@ -1,9 +1,9 @@
// a tail recursive fib implementation
// http://en.literateprograms.org/Fibonacci_numbers_%28Scala%29
-def fib(n: Int): Long = fib_tr(n, 1, 0)
+def fib(n: Int): Long = fib_tr(n, 1, 0)
def fib_tr(n: Int, b: Long, a: Long): Long = n match {
- case 0 => a
+ case 0 => a
case _ => fib_tr(n - 1, a + b, b)
}
View
8 scala/003/01.scala
@@ -1,14 +1,14 @@
import scala.Math._
// http://mathworld.wolfram.com/DirectSearchFactorization.html
-//
+//
// What is the largest prime factor of the number 600851475143 ?
// produces a list of divisors of x, in decreasing order, excluding x
def divisors(x: Long): Seq[Int] = {
// start at sqrt of x, since that's the largest possible divisor
- val r = round(floor(sqrt(x))).toInt to 1 by -1
- // identify divisors
+ val r = round(floor(sqrt(x))).toInt to 1 by -1
+ // identify divisors
r.filter(x % _ == 0)
}
@@ -17,7 +17,7 @@ def isPrime(x: Long): Boolean = {
divisors(x).length == 1
}
-// pull the first divisor that's prime (also the largest, since
+// pull the first divisor that's prime (also the largest, since
// divisors returns in decreasing order
val biggun = 600851475143L
println(divisors(biggun).filter(isPrime(_)).first)
View
2  scala/007/01.scala
@@ -4,7 +4,7 @@ import scala.Math._
def divisors(x: Int): Seq[Int] = {
// start at sqrt of x, since that's the largest possible divisor
val r = round(floor(sqrt(x))).toInt to 1 by -1
- // identify divisors
+ // identify divisors
r.filter(x % _ == 0)
}
View
2  scala/010/01.scala
@@ -4,7 +4,7 @@ import scala.Math._
def divisors(x: Int): Seq[Int] = {
// start at sqrt of x, since that's the largest possible divisor
val r = round(floor(sqrt(x))).toInt to 1 by -1
- // identify divisors
+ // identify divisors
r.filter(x % _ == 0)
}
Please sign in to comment.
Something went wrong with that request. Please try again.