Created
April 26, 2015 13:21
-
-
Save flatcap/4aabc6339f6b4b85ad25 to your computer and use it in GitHub Desktop.
Sunday Times Teaser 2742 (2015-04-12)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
BEGIN { | |
} | |
{ | |
top = $1$2$3; | |
mid = $4$5$6; | |
bot = $7$8$9; | |
if ((top > mid) || (mid > bot)) { | |
next; | |
} | |
if ((top < 100) || (mid < 100) || (bot < 100)) { | |
next; | |
} | |
if ((top > 500) || (mid > 500) || (bot > 500)) { | |
next; | |
} | |
sum_top = $1 + $2 + $3; | |
sum_mid = $4 + $5 + $6; | |
sum_bot = $7 + $8 + $9; | |
if ((sum_top != sum_mid) || (sum_mid != sum_bot)) { | |
next; | |
} | |
mean = (top + mid + bot) / 3; | |
if ((top != mean) && (mid != mean) && (bot != mean)) { | |
next; | |
} | |
printf ("%d %d %d\n", top, mid, bot); | |
} | |
END { | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
three three-digit hymn numbers | |
all <= 500 | |
one is the mean of the others | |
no digits repeated | |
for each number: sum of digits is the same |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use Algorithm::Permute; | |
Algorithm::Permute::permute { | |
print "@ARGV\n"; | |
} @ARGV; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment