Created
April 26, 2015 13:23
-
-
Save flatcap/fa13870ea99f790f0c2b to your computer and use it in GitHub Desktop.
Sunday Times Teaser 2744 (2015-04-26)
This file contains 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; |
This file contains 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 | |
{ | |
count["B"] = 0; | |
count["C"] = 0; | |
count["D"] = 0; | |
for (i = 12; i > 0; i--) { | |
count[$i] += i; | |
} | |
b = count["B"]; | |
c = count["C"]; | |
d = count["D"]; | |
# printf ("B: %2d, C: %2d, D: %2d\n", b, c, d); | |
if ((b == c) && (c == d)) { | |
print $0; | |
} | |
# rows++; | |
# if ((rows % 500000) == 0) { | |
# printf ("complete %0.1f%%\n", rows/399168); | |
# } | |
} |
This file contains 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
#!/bin/bash | |
permute.pl B B B C C C C D D D D | sed 's/$/ B/' > a1 | |
score.awk a1 > a2 | |
grep "C C C" a2 | grep "D.*[^D] D D [^D].*D" | uniq > a3 | |
WINNER=$(cat a3 | cut -b1) | |
echo WINNER = $WINNER | |
sed 's/ /\n/g' a3 | nl | grep "$WINNER" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment