blob: 6511220e4d9a781fffd44432b1c2a8971ed35b33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
Solutions by Bruce Gray.
For ch-2, the Perl and Raku programs can take rationals on the command-line for experimentation,
or will run their test suites if invoked without arguments.
Sample runs:
$ perl perl/ch-1.pl
104743
$ raku raku/ch-1.raku
104743
$ perl perl/ch-2.pl 4817/5410
4817/5410 has CW parent,grandparent of: 4817/593,4224/593
$ raku raku/ch-2.raku 4817/5410
(4817/593 4224/593)
$ prove perl/ch-2.pl
perl/ch-2.pl .. ok
All tests successful.
Files=1, Tests=202, 0 wallclock secs ( 0.04 usr 0.01 sys + 0.09 cusr 0.01 csys = 0.15 CPU)
Result: PASS
$ prove -e raku raku/ch-2.raku
raku/ch-2.raku .. ok
All tests successful.
Files=1, Tests=202, 3 wallclock secs ( 0.05 usr 0.00 sys + 2.72 cusr 0.13 csys = 2.90 CPU)
Result: PASS
$ perl -MMath::PlanePath::RationalsTree -wE 'my $CW = Math::PlanePath::RationalsTree->new( tree_type => "CW" ); say join "/", $CW->n_to_xy( $CW->tree_n_parent( $CW->xy_to_n(@ARGV) ) );' 4817 5410
4817/593
(Fleshed out in ch-2_via_module.pl)
|