Skip to main content
lzma -9 saves one byte!
Source Link
Adam Katz
  • 366
  • 5
  • 10

Shell - Bytes: 25462545, False +ves: 0, False -ves: 0 = Score: 2582 2548 25462545

Code: 54 52 bytes, Dictionary: 2518 24942494 2493 bytes, FP: 1 0, FN: 0

wget -qqO- 'http://pastebin.com/raw.php?i=wh6yxrqp' \
  | perl -pne 's/\r//; s/^I$//' | lzma -cc9 > z

Shell - Bytes: 2546, False +ves: 0, False -ves: 0 = Score: 2582 2548 2546

Code: 54 52 bytes, Dictionary: 2518 2494 bytes, FP: 1 0, FN: 0

wget -qqO- 'http://pastebin.com/raw.php?i=wh6yxrqp' \
  | perl -pne 's/\r//; s/^I$//' | lzma -c > z

Shell - Bytes: 2545, False +ves: 0, False -ves: 0 = Score: 2545

Code: 54 52 bytes, Dictionary: 2518 2494 2493 bytes, FP: 1 0, FN: 0

wget -qqO- 'http://pastebin.com/raw.php?i=wh6yxrqp' \
  | perl -pne 's/\r//; s/^I$//' | lzma -c9 > z
better explain the tricks for `I` vs `i`
Source Link
Adam Katz
  • 366
  • 5
  • 10

The conditional compares the argument with itself after a string manipulation that alters the string if it matches any character followed by any number of characters followed by an uppercase letter (equivalent to s/^..*?[A-Z]// – ignore the ? if you don't understand it), which would compare coLoUr to oUr and Colour to Colour. This controls for mixed case (and fails all-caps), though because it skips the first letter, it doesn't reject. It accepts i. Yet (but neither i nor I are in the dictionary, see below).

If the conditional matches (there are no capitals after the first letter), unlzma is run on the contents of the file named z, which puts the uncompressed dictionary into standard output. grep then queries for the argument* quietly (-q), without regard to case—we've already controlled for casethat (-i), and on a whole line (-x).

*The argumentThe query is an altered a bitversion of the argument: if there isthe argument has a trailing capital I (case sensitive!), it is removed. This is fine because I converted Because we controlled for case earlier, the only time we'd remove a capital I would be for the word I, in which case the grep query seeks an empty string on its own line. The dictionary's I entry to bewas swapped for a blank line, so it still matcheswe'll get a match.

The conditional compares the argument with itself after a string manipulation that alters the string if it matches any character followed by any number of characters followed by an uppercase letter (equivalent to s/^..*?[A-Z]// – ignore the ? if you don't understand it), which would compare coLoUr to oUr and Colour to Colour. This controls for mixed case (and fails all-caps), though because it skips the first letter, it doesn't reject i. Yet.

If the conditional matches (there are no capitals after the first letter), unlzma is run on the contents of the file named z, which puts the uncompressed dictionary into standard output. grep then queries for the argument* quietly (-q), without regard to case—we've already controlled for case (-i), and on a whole line (-x).

*The argument is altered a bit: if there is a trailing capital I, it is removed. This is fine because I converted the dictionary's I entry to be a blank line, so it still matches.

The conditional compares the argument with itself after a string manipulation that alters the string if it matches any character followed by any number of characters followed by an uppercase letter (equivalent to s/^..*?[A-Z]// – ignore the ? if you don't understand it), which would compare coLoUr to oUr and Colour to Colour. This controls for mixed case (and fails all-caps), though it skips the first letter. It accepts i (but neither i nor I are in the dictionary, see below).

If the conditional matches (there are no capitals after the first letter), unlzma is run on the contents of the file named z, which puts the uncompressed dictionary into standard output. grep then queries quietly (-q), without regard to case—we've already controlled for that (-i), and on a whole line (-x).

The query is an altered version of the argument: if the argument has a trailing capital I (case sensitive!), it is removed. Because we controlled for case earlier, the only time we'd remove a capital I would be for the word I, in which case the grep query seeks an empty string on its own line. The dictionary's I entry was swapped for a blank line, so we'll get a match.

Quotes aren't needed around the initial `$1` because "the input is always a single word, all ASCII `[A-Za-z]`."
Source Link
Adam Katz
  • 366
  • 5
  • 10

Shell - Bytes: 25492546, False +ves: 0, False -ves: 0 = Score: 2582 25482548 2546

Code: 5454 52 bytes, Dictionary: 2518 2494 bytes, FP: 1 0, FN: 0

[ "$1"$1 = "${1#?*[A-Z]}" ]&&unlzma<z|grep -qix "${1%I}"

If I were guaranteed to only get tests consisting of letters, I could strip out the first pair of quotes and reduceQuotes are not needed around the code size to 52initial (final score: 2546)$1 because "the input is always a single word, all ASCII [A-Za-z]. (Other"  However, quotes areare needed becausearound the substitutionsparameter expansions because they might result ingenerate an empty string.)

Shell - Bytes: 2549, False +ves: 0, False -ves: 0 = Score: 2582 2548

Code: 54 bytes, Dictionary: 2518 2494 bytes, FP: 1 0, FN: 0

[ "$1" = "${1#?*[A-Z]}" ]&&unlzma<z|grep -qix "${1%I}"

If I were guaranteed to only get tests consisting of letters, I could strip out the first pair of quotes and reduce the code size to 52 (final score: 2546). (Other quotes are needed because the substitutions might result in an empty string.)

Shell - Bytes: 2546, False +ves: 0, False -ves: 0 = Score: 2582 2548 2546

Code: 54 52 bytes, Dictionary: 2518 2494 bytes, FP: 1 0, FN: 0

[ $1 = "${1#?*[A-Z]}" ]&&unlzma<z|grep -qix "${1%I}"

Quotes are not needed around the initial $1 because "the input is always a single word, all ASCII [A-Za-z]."  However, quotes are needed around the parameter expansions because they might generate an empty string.

better explain the exit status
Source Link
Adam Katz
  • 366
  • 5
  • 10
Loading
removed FP, shrunk dictionary, improved explanations and tests
Source Link
Adam Katz
  • 366
  • 5
  • 10
Loading
Source Link
Adam Katz
  • 366
  • 5
  • 10
Loading