diff options
| author | Paulo Custodio <pauloscustodio@gmail.com> | 2021-01-25 20:07:40 +0000 |
|---|---|---|
| committer | Paulo Custodio <pauloscustodio@gmail.com> | 2021-01-25 20:07:40 +0000 |
| commit | c402c40f216b437ab1aba13793d493eb25cbfd14 (patch) | |
| tree | 957f61c2428b4dc71ff703b10fecc17700824d0b /challenge-001 | |
| parent | fcad77840d011bba81e63bb4b76adfdcf06fc96f (diff) | |
| download | perlweeklychallenge-club-c402c40f216b437ab1aba13793d493eb25cbfd14.tar.gz perlweeklychallenge-club-c402c40f216b437ab1aba13793d493eb25cbfd14.tar.bz2 perlweeklychallenge-club-c402c40f216b437ab1aba13793d493eb25cbfd14.zip | |
Replace tabs by spaces so that indentation looks correct
Diffstat (limited to 'challenge-001')
| -rw-r--r-- | challenge-001/paulo-custodio/forth/ch-1.fs | 20 | ||||
| -rw-r--r-- | challenge-001/paulo-custodio/forth/ch-2.fs | 18 | ||||
| -rw-r--r-- | challenge-001/paulo-custodio/perl/ch-1.pl | 3 | ||||
| -rw-r--r-- | challenge-001/paulo-custodio/perl/ch-2.pl | 2 | ||||
| -rw-r--r-- | challenge-001/paulo-custodio/test.pl | 12 |
5 files changed, 27 insertions, 28 deletions
diff --git a/challenge-001/paulo-custodio/forth/ch-1.fs b/challenge-001/paulo-custodio/forth/ch-1.fs index a552383f39..b48413dfdb 100644 --- a/challenge-001/paulo-custodio/forth/ch-1.fs +++ b/challenge-001/paulo-custodio/forth/ch-1.fs @@ -1,22 +1,22 @@ #! /usr/bin/env gforth \ 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. CREATE message ," Perl Weekly Challenge" -: replace-e ( cstr -- n ) - 0 SWAP ( n cstr ) \ n = number of chars replaced ) - COUNT BOUNDS ?DO - I C@ 'e' = IF \ is an 'e' - 'E' i C! \ replace by 'E' - 1+ \ count it - THEN - LOOP +: replace-e ( cstr -- n ) + 0 SWAP ( n cstr ) \ n = number of chars replaced ) + COUNT BOUNDS ?DO + I C@ 'e' = IF \ is an 'e' + 'E' i C! \ replace by 'E' + 1+ \ count it + THEN + LOOP ; -message replace-e . +message replace-e . message COUNT TYPE CR BYE diff --git a/challenge-001/paulo-custodio/forth/ch-2.fs b/challenge-001/paulo-custodio/forth/ch-2.fs index 35da0c8833..eb91bb272d 100644 --- a/challenge-001/paulo-custodio/forth/ch-2.fs +++ b/challenge-001/paulo-custodio/forth/ch-2.fs @@ -1,18 +1,18 @@ #! /usr/bin/env gforth \ 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’. -: fizzbuzz ( n -- ) - 1+ 1 ?DO - I 15 MOD 0= IF ." fizzbuzz" ELSE - I 3 MOD 0= IF ." fizz" ELSE - I 5 MOD 0= IF ." buzz" ELSE I . - THEN THEN THEN - CR - LOOP +: fizzbuzz ( n -- ) + 1+ 1 ?DO + I 15 MOD 0= IF ." fizzbuzz" ELSE + I 3 MOD 0= IF ." fizz" ELSE + I 5 MOD 0= IF ." buzz" ELSE I . + THEN THEN THEN + CR + LOOP ; 20 fizzbuzz diff --git a/challenge-001/paulo-custodio/perl/ch-1.pl b/challenge-001/paulo-custodio/perl/ch-1.pl index 37593c4a80..edfc497225 100644 --- a/challenge-001/paulo-custodio/perl/ch-1.pl +++ b/challenge-001/paulo-custodio/perl/ch-1.pl @@ -1,7 +1,7 @@ #!/usr/bin/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. @@ -11,4 +11,3 @@ use 5.030; my $s = "Perl Weekly Challenge"; say(($s =~ tr/e/E/), " ", $s); - diff --git a/challenge-001/paulo-custodio/perl/ch-2.pl b/challenge-001/paulo-custodio/perl/ch-2.pl index 139724a6ec..c64625432b 100644 --- a/challenge-001/paulo-custodio/perl/ch-2.pl +++ b/challenge-001/paulo-custodio/perl/ch-2.pl @@ -1,7 +1,7 @@ #!/usr/bin/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’. diff --git a/challenge-001/paulo-custodio/test.pl b/challenge-001/paulo-custodio/test.pl index 382882369a..633176940e 100644 --- a/challenge-001/paulo-custodio/test.pl +++ b/challenge-001/paulo-custodio/test.pl @@ -5,8 +5,8 @@ use warnings; use Test::More; use 5.030; -is capture("perl perl/ch-1.pl"), "5 PErl WEEkly ChallEngE\n"; -is capture("gforth forth/ch-1.fs"), "5 PErl WEEkly ChallEngE\n"; +is capture("perl perl/ch-1.pl"), "5 PErl WEEkly ChallEngE\n"; +is capture("gforth forth/ch-1.fs"), "5 PErl WEEkly ChallEngE\n"; my $expected = <<END; 1 @@ -38,8 +38,8 @@ is capture("gforth forth/ch-2.fs"), $expected; done_testing; sub capture { - my($cmd) = @_; - my $out = `$cmd`; - $out =~ s/[ \t\v\f\r]*\n/\n/g; - return $out; + my($cmd) = @_; + my $out = `$cmd`; + $out =~ s/[ \t\v\f\r]*\n/\n/g; + return $out; } |
