diff options
Diffstat (limited to 'challenge-052')
| -rw-r--r-- | challenge-052/markus-holzer/perl/ch-1.pl | 6 | ||||
| -rw-r--r-- | challenge-052/markus-holzer/raku/ch-1.p6 | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/challenge-052/markus-holzer/perl/ch-1.pl b/challenge-052/markus-holzer/perl/ch-1.pl index 582674b438..c6522aa1aa 100644 --- a/challenge-052/markus-holzer/perl/ch-1.pl +++ b/challenge-052/markus-holzer/perl/ch-1.pl @@ -5,7 +5,11 @@ sub stepping { my @n = split '', shift; my $m = shift @n; - for my $n ( @n ) { return 0 unless $m + 1 == ($m = $n) } + + for my $n ( @n ) { + return unless abs($m - $n) == 1; + $m = $n; + } 1; } diff --git a/challenge-052/markus-holzer/raku/ch-1.p6 b/challenge-052/markus-holzer/raku/ch-1.p6 index cabee9e7ea..4807703bbf 100644 --- a/challenge-052/markus-holzer/raku/ch-1.p6 +++ b/challenge-052/markus-holzer/raku/ch-1.p6 @@ -1,8 +1,8 @@ # Inspired by Simon -sub is-consecutive( UInt $n ) { - [==] ^$n.chars Z- $n.comb; +sub is-stepping( UInt $n ) { + not so $n.comb.rotor( 2 => -1 ).first: -> ($a, $b) { abs($a - $b) != 1 } } sub MAIN (UInt $start = 100, UInt $end = 999) { - .say for ($start..$end).grep( &is-consecutive ); + .say for ($start..$end).grep( &is-stepping ); }
\ No newline at end of file |
