diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-05-19 13:05:38 +0100 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-05-19 13:05:38 +0100 |
| commit | e9b39d99075eeee987d3a516df331753ed4eed28 (patch) | |
| tree | 88d405d9bc313c217f4f2067fe6558b9eef129cd /challenge-113/james-smith | |
| parent | 1b55021a620a4d525412b0fa0e3c012cb2d291b2 (diff) | |
| download | perlweeklychallenge-club-e9b39d99075eeee987d3a516df331753ed4eed28.tar.gz perlweeklychallenge-club-e9b39d99075eeee987d3a516df331753ed4eed28.tar.bz2 perlweeklychallenge-club-e9b39d99075eeee987d3a516df331753ed4eed28.zip | |
Update README.md
Diffstat (limited to 'challenge-113/james-smith')
| -rw-r--r-- | challenge-113/james-smith/README.md | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/challenge-113/james-smith/README.md b/challenge-113/james-smith/README.md index 7ce644935d..b2d866761d 100644 --- a/challenge-113/james-smith/README.md +++ b/challenge-113/james-smith/README.md @@ -67,7 +67,9 @@ solutions... ```perl sub represent { my( $t, $n, $d ) = ( 0, @_ ); - return 1 if $n >= 10 * ( $d || 10 ); + ## Type 2 solutions... + return 1 if $n >= 10 *A ( $d || 10 ); + ## Type 1 solutions... $n >= ( $t += $_ * 10 + $d ) && ( $n % 10 == $t % 10 ) && return 1 for 0..3; 0; @@ -80,11 +82,13 @@ variable and the `for` loop by "unrolling" the loop as below... ```perl sub represent_unrolled { my( $n, $d ) = @_; - $n >= 10 * ( $d || 10 ) || - $n >= $d && $n%10 == $d || - $n >= 2*$d+10 && !( ($n-2*$d)%10 ) || - $n >= 3*$d+30 && !( ($n-3*$d)%10 ) || - $n >= 4*$d+60 && !( ($n-4*$d)%10 ) ? 1 : 0; + ## Type 2 solutions... + $n >= 10 * ( $d || 10 ) || + ## Type 1 solutions... + $n >= $d && $n%10 == $d || + $n >= 2*$d+10 && !( ($n-2*$d)%10 ) || + $n >= 3*$d+30 && !( ($n-3*$d)%10 ) || + $n >= 4*$d+60 && !( ($n-4*$d)%10 ) ? 1 : 0; } ``` |
