File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
challenge-023/stuart-little Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ Solutions by Stuart Little
Original file line number Diff line number Diff line change 1+ # !/usr/bin/env perl6
2+ use v6 ;
3+
4+ sub dff (@ a where {$ _ . all ~~ Int }) {
5+ @ a . rotor(2 => -1 ). map ({ $ _ [1 ] - $ _ [0 ] })
6+ }
7+
8+ for (1 .. @ * ARGS [0 ]. Int ). map ({ reduce { $ ^ b . ($ ^ a ) }, @ * ARGS [1 .. * ]. map (*. Int ), | (& dff xx $ _ ) }) {. say }
9+
10+ # run as <script> <number of difference iterations> <space-separated integer array entries>
Original file line number Diff line number Diff line change 1+ # !/usr/bin/env perl6
2+ use v6 ;
3+
4+ my @ PRIMES = (2 .. * ). grep (*. is-prime );
5+
6+ sub fct ($ n ,@ a ) {
7+ $ n . abs == 1 && return @ a ;
8+ my $ fact = @ PRIMES . first ($ n %% * );
9+ return fct(($ n div $ fact ), (| @ a ,$ fact ));
10+ }
11+
12+ say @ * ARGS [0 ]. Int . & fct (())
13+
14+ # run as <script> <integer>
You can’t perform that action at this time.
0 commit comments