diff options
| -rw-r--r-- | challenge-119/luca-ferrari/raku/ch-1.p6 | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-119/luca-ferrari/raku/ch-1.p6 b/challenge-119/luca-ferrari/raku/ch-1.p6 new file mode 100644 index 0000000000..2d8d1b200c --- /dev/null +++ b/challenge-119/luca-ferrari/raku/ch-1.p6 @@ -0,0 +1,20 @@ +#!raku + + +sub MAIN( Int $N where { $N < 256 && $N >= 0 } ) { + + # create an 8 digits binary string + '%08d'.sprintf( $N.base( 2 ) ) + # separate each digit into an array + .split( '', :skip-empty ) + # rotate by four elements + .rotate( 4 ) + # recombine + .join + # reparse as binary + .Str + .parse-base( 2 ) + # and print + .say; + +} |
