diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-10-30 07:59:53 +0100 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-10-30 07:59:53 +0100 |
| commit | df310a679e4648fdadd6f05abf0eaf9ca753c620 (patch) | |
| tree | 6e0e86d79a9e222f213280b33ee6fa40fd862322 | |
| parent | 97c29e8d390fa4161e350707866c8d2351ac5c82 (diff) | |
| parent | 85e041ce62ebb1025717e5ad04a8681d043c3f08 (diff) | |
| download | perlweeklychallenge-club-df310a679e4648fdadd6f05abf0eaf9ca753c620.tar.gz perlweeklychallenge-club-df310a679e4648fdadd6f05abf0eaf9ca753c620.tar.bz2 perlweeklychallenge-club-df310a679e4648fdadd6f05abf0eaf9ca753c620.zip | |
cat ch-*Merge remote-tracking branch 'upstream/master'
y# Please enter a commit message to explain why this merge is necessary,
83 files changed, 3828 insertions, 1776 deletions
diff --git a/.gitignore b/.gitignore index 6f111fe0c2..ba8194b15c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ *.bak ch-1 ch-2 +ch_1 +ch_2 go.mod go.sum tags diff --git a/challenge-001/paulo-custodio/Makefile b/challenge-001/paulo-custodio/Makefile new file mode 100644 index 0000000000..24da326a16 --- /dev/null +++ b/challenge-001/paulo-custodio/Makefile @@ -0,0 +1,8 @@ +all: brainfuck/ch-1.bf brainfuck/ch-2.bf + perl ../../challenge-001/paulo-custodio/test.pl + +brainfuck/ch-1.bf: brainfuck/ch-1.pl + perl brainfuck/ch-1.pl > $@ + +brainfuck/ch-2.bf: brainfuck/ch-2.pl + perl brainfuck/ch-2.pl > $@ diff --git a/challenge-001/paulo-custodio/brainfuck/ch-1.bf b/challenge-001/paulo-custodio/brainfuck/ch-1.bf new file mode 100644 index 0000000000..b1d94a8bb7 --- /dev/null +++ b/challenge-001/paulo-custodio/brainfuck/ch-1.bf @@ -0,0 +1 @@ +[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. diff --git a/challenge-001/paulo-custodio/brainfuck/ch-1.pl b/challenge-001/paulo-custodio/brainfuck/ch-1.pl new file mode 100644 index 0000000000..c9f6754286 --- /dev/null +++ b/challenge-001/paulo-custodio/brainfuck/ch-1.pl @@ -0,0 +1,22 @@ +#!/usr/bin/env perl + +# Challenge 001 +# +# Challenge #1 +# Write a script to replace the character ‘e’ with ‘E’ in the string +# ‘Perl Weekly Challenge’. Also print the number of times the character ‘e’ +# is found in the string. + +# Output brainfuck program + +use Modern::Perl; + +my $s = "Perl Weekly Challenge"; +my $text = ($s =~ tr/e/E/)." ".$s; + +for (split //, $text) { + print "[-]"; # zero cell + print "+" x ord($_); # set cell to ASCII value of character + print "."; # output character +} +print "\n"; diff --git a/challenge-001/paulo-custodio/brainfuck/ch-2.bf b/challenge-001/paulo-custodio/brainfuck/ch-2.bf new file mode 100644 index 0000000000..0a252de458 --- /dev/null +++ b/challenge-001/paulo-custodio/brainfuck/ch-2.bf @@ -0,0 +1 @@ +[-]+++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++. diff --git a/challenge-001/paulo-custodio/brainfuck/ch-2.pl b/challenge-001/paulo-custodio/brainfuck/ch-2.pl new file mode 100644 index 0000000000..7ef784110a --- /dev/null +++ b/challenge-001/paulo-custodio/brainfuck/ch-2.pl @@ -0,0 +1,36 @@ +#!/usr/bin/env perl + +# Challenge 001 +# +# Challenge #2 +# Write a one-liner to solve the FizzBuzz problem and print the numbers 1 +# through 20. However, any number divisible by 3 should be replaced by the word +# ‘fizz’ and any divisible by 5 by the word ‘buzz’. Those numbers that are both +# divisible by 3 and 5 become ‘fizzbuzz’. + +# Output brainfuck program + +use Modern::Perl; + +my $text = ""; +for my $n (1..20) { + if ($n%15==0) { + $text .= "fizzbuzz\n"; + } + elsif ($n%3==0) { + $text .= "fizz\n"; + } + elsif ($n%5==0) { + $text .= "buzz\n"; + } + else { + $text .= "$n\n"; + } +} + +for (split //, $text) { + print "[-]"; # zero cell + print "+" x ord($_); # set cell to ASCII value of character + print "."; # output character +} +print "\n"; diff --git a/challenge-001/paulo-custodio/go.pl b/challenge-001/paulo-custodio/go.pl index 97670bc755..d4639380d3 100644 --- a/challenge-001/paulo-custodio/go.pl +++ b/challenge-001/paulo-custodio/go.pl @@ -7,7 +7,23 @@ use Path::Tiny; or die "Usage: ",path($0)->basename," nr\n"; my $nr = sprintf("%03d", $ARGV[0]); -for my $dir (qw( ada awk basic c cpp d forth lua perl python t )) { +for my $dir (qw( + ada + awk + basic + bc + brainfuck + c + cpp + d + forth + fortran + lua + pascal + perl + python + t + )) { path("challenge-$nr/paulo-custodio/$dir")->mkpath; } path("challenge-$nr/paulo-custodio/README")->spew("Solution by Paulo Custodio\n"); diff --git a/challenge-001/paulo-custodio/stats.pl b/challenge-001/paulo-custodio/stats.pl index 1cb928a96a..bc344a2db3 100644 --- a/challenge-001/paulo-custodio/stats.pl +++ b/challenge-001/paulo-custodio/stats.pl @@ -12,11 +12,14 @@ our %LANG = ( awk => 'awk', basic => 'bas', bc => 'bc', + brainfuck=>'bf', c => 'c', cpp => 'cpp', d => 'd', forth => 'fs', + fortran => 'f90', lua => 'lua', + pascal => 'pas', perl => 'pl', python => 'py', ); diff --git a/challenge-001/paulo-custodio/t/test-1.yaml b/challenge-001/paulo-custodio/t/test-1.yaml index c36262e3b7..2c3894252e 100644 --- a/challenge-001/paulo-custodio/t/test-1.yaml +++ b/challenge-001/paulo-custodio/t/test-1.yaml @@ -3,8 +3,3 @@ args: Perl Weekly Challenge input: output: 5 PErl WEEkly ChallEngE -- setup: - cleanup: - args: Champion - input: - output: 0 Champion diff --git a/challenge-001/paulo-custodio/test.pl b/challenge-001/paulo-custodio/test.pl index 4e2418c4ae..c8dc2b9f75 100644 --- a/challenge-001/paulo-custodio/test.pl +++ b/challenge-001/paulo-custodio/test.pl @@ -17,7 +17,7 @@ our %LANG = ( awk => 'awk', basic => 'bas', bc => 'bc', - brainfuck=>'bfpp', + brainfuck=>'bf', c => 'c', cpp => 'cpp', d => 'd', @@ -137,15 +137,15 @@ sub build { return "gawk -f $prog --"; } if (/^basic$/) { - run("fbc $prog -o $prog_wo_ext") if (!-f $exe || -M $exe > -M $prog); + run("fbc $prog") if (!-f $exe || -M $exe > -M $prog); return $exe; } if (/^bc$/) { return "bc -lq $prog"; } if (/^brainfuck$/) { - run("perl bfpp.pl <$prog_wo_ext.bfpp >$prog_wo_ext.bf"); - return "brainfuck $prog_wo_ext.bf"; + #run("perl bfpp.pl <$prog_wo_ext.bfpp >$prog_wo_ext.bf"); + return "bf $prog_wo_ext.bf"; } if (/^c$/) { run("gcc $prog -o $prog_wo_ext -lmpfr -lgmp") if (!-f $exe || -M $exe > -M $prog |
