From 957a83cede7fcd913c8849a58fa18b62453d115a Mon Sep 17 00:00:00 2001 From: Simon Proctor Date: Tue, 25 Feb 2020 11:39:22 +0000 Subject: Sudden ephiany --- challenge-049/simon-proctor/raku/ch-1.p6 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/challenge-049/simon-proctor/raku/ch-1.p6 b/challenge-049/simon-proctor/raku/ch-1.p6 index 82a55473f7..7e05281b98 100644 --- a/challenge-049/simon-proctor/raku/ch-1.p6 +++ b/challenge-049/simon-proctor/raku/ch-1.p6 @@ -6,5 +6,13 @@ use v6.d; sub MAIN( UInt $x #= Number to look for multiple of ) { - ( $x, * + $x...* ).hyper.first( { $_ ~~ m!^ <[10]>+ $! } ).say; + my $current = 1; + my $current-bin = $current.base(2); + + while ( ! ( $current-bin %% $x ) ) { + $current++; + $current-bin = $current.base(2); + } + + say $current-bin; } -- cgit From ce3cc584a47e37793e7795f8db88a5b8aada8471 Mon Sep 17 00:00:00 2001 From: Simon Proctor Date: Tue, 25 Feb 2020 11:40:52 +0000 Subject: Sudden ephiany part 2 --- challenge-049/simon-proctor/raku/ch-1.p6 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/challenge-049/simon-proctor/raku/ch-1.p6 b/challenge-049/simon-proctor/raku/ch-1.p6 index 7e05281b98..a53c9166fb 100644 --- a/challenge-049/simon-proctor/raku/ch-1.p6 +++ b/challenge-049/simon-proctor/raku/ch-1.p6 @@ -6,13 +6,13 @@ use v6.d; sub MAIN( UInt $x #= Number to look for multiple of ) { - my $current = 1; - my $current-bin = $current.base(2); - - while ( ! ( $current-bin %% $x ) ) { - $current++; - $current-bin = $current.base(2); + my @seq = lazy gather { + my $current = 1; + loop { + take $current.base(2); + $current++; + } } - say $current-bin; + @seq.first( * %% $x ).say; } -- cgit