diff options
author | bd <bdunahu@operationnull.com> | 2024-06-16 22:17:54 -0600 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2024-06-16 22:17:54 -0600 |
commit | fd93afc17c30e480e437a28c6d495b521c0e7fb3 (patch) | |
tree | e42a78324668f5dfa10bda8cab078449d5d01e9d /doesnt-he-have-intern-elves-for-this/dhhieft-test.scm | |
parent | 5745b2875046d0bbe3bf25f1d03a297b624c55c6 (diff) |
AoC 2015.5 p1+2
Diffstat (limited to 'doesnt-he-have-intern-elves-for-this/dhhieft-test.scm')
-rw-r--r-- | doesnt-he-have-intern-elves-for-this/dhhieft-test.scm | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/doesnt-he-have-intern-elves-for-this/dhhieft-test.scm b/doesnt-he-have-intern-elves-for-this/dhhieft-test.scm new file mode 100644 index 0000000..88e019b --- /dev/null +++ b/doesnt-he-have-intern-elves-for-this/dhhieft-test.scm @@ -0,0 +1,167 @@ +;; -*- compile-command: "guile -L . dhhieft-test.scm"; -*- +(use-modules (srfi srfi-64) + (dhhieft)) + + +(test-begin "harness") + + +(test-equal "string->vowels none" + "" + (string->vowels "")) + +(test-equal "string->vowels vowels" + "aeiou" + (string->vowels "aeiou")) + +(test-equal "string->vowels single consonant" + "" + (string->vowels "x")) + +(test-equal "string->vowels mix" + "uoiea" + (string->vowels "uywoigxebwa")) + +(test-assert "three-vowels? empty string" + (not (three-vowels? ""))) + +(test-assert "three-vowels? two vowels" + (not (three-vowels? "axkoh"))) + +(test-assert "three-vowels? exactly three vowels" + (three-vowels? "axkioh")) + +(test-assert "three-vowels? four vowels" + (three-vowels? "axkiohe")) + +(test-assert "three-vowels? uppercase vowels" + (three-vowels? "AXKIOHE")) + +(test-assert "repeated-char? empty string" + (not (repeated-char? "" 0))) + +(test-assert "repeated-char? single char" + (not (repeated-char? "a" 0))) + +(test-assert "repeated-char? single repeat" + (repeated-char? "aa" 0)) + +(test-assert "repeated-char? single repeat other" + (repeated-char? "xx" 0)) + +(test-assert "repeated-char? single repeat break" + (not (repeated-char? "a?a" 0))) + +(test-assert "repeated-char? needle-in-hay" + (repeated-char? "ugknbfddgicrmopn" 0)) + +(test-assert "favorable? ugknbfddgicrmopn" + (favorable-string? "ugknbfddgicrmopn" #f)) + +(test-assert "favorable? aaa" + (favorable-string? "aaa" #f)) + +(test-assert "favorable? jchzalrnumimnmhp" + (not (favorable-string? "jchzalrnumimnmhp" #f))) ;; no double letter + +(test-assert "favorable? habegwjzuzvuyypu" + (not (favorable-string? "habegwjzuzvuyypu" #f))) ;; contains ab + +(test-assert "favorable? hacdegwzuvuyypxu" + (not (favorable-string? "hacdegwzuvuyypxu" #f))) ;; contains cd + +(test-assert "favorable? haegwjzuvuqyypqu" + (not (favorable-string? "haegwjzuvuqyypqu" #f))) ;; contains pq + +(test-assert "favorable? haegwjzuvuyypxyu" + (not (favorable-string? "haegwjzuvuyypxyu" #f))) ;; contains xy + +(test-assert "favorable? dvszwmarrgswjxmb" + (not (favorable-string? "dvszwmarrgswjxmb" #f))) ;; single vowel + +(test-equal "file run through" + 2 + (dhhieft " +ugknbfddgicrmopn +aaa +jchzalrnumimnmhp +haegwjzuvuyypxyu +dvszwmarrgswjxmb" #f)) + +(test-assert "repeated-char? over-extend-lookahead" + (not (repeated-char? "a" 3))) + +(test-assert "repeated-char? single gap false" + (not (repeated-char? "aab" 1))) + +(test-assert "repeated-char single gap simple" + (repeated-char? "aba" 1)) + +(test-assert "repeated-char double gap simple false" + (not (repeated-char? "acab" 2))) + +(test-assert "repeated-char double gap simple" + (repeated-char? "acba" 2)) + +(test-assert "repeated-char double gap simple" + (repeated-char? "acba" 2)) + +(test-assert "repeated-char single gap needle in hay" + (repeated-char? "abcdefeghi" 1)) + +(test-assert "long-distance-match? empty" + (not (long-distance-match? ""))) + +(test-assert "long-distance-match? single char" + (not (long-distance-match? "a"))) + +(test-assert "long-distance-match? single repeat" + (not (long-distance-match? "aa"))) + +(test-assert "long-distance-match? match but shared" + (not (long-distance-match? "aaa"))) + +(test-assert "long-distance-match? simple match" + (long-distance-match? "abab")) + +(test-assert "long-distance-match? match alongside share" + (long-distance-match? "aaaa")) + +(test-assert "long-distance-match? simple fail" + (not (long-distance-match? "aaba"))) + +(test-assert "long-distance-match? far match" + (long-distance-match? "aabcdefgaa")) + +(test-assert "long-distance-match? needle-in-haystack match" + (long-distance-match? "qjhvhtzxzqqjkmpb")) + +(test-assert "long-distance-match? needle-in-haystack no match" + (not (long-distance-match? "ieodomkazucvgmuy"))) + +(test-assert "favorable? p2 meets none" + (not (favorable-string? "" #t))) + +(test-assert "favorable? p2 no long-distance match" + (not (favorable-string? "ieodomkazucvgmuy" #t))) + +(test-assert "favorable? p2 no repeat-char" + (not (favorable-string? "uurcxstgmygtbstg" #t))) + +(test-assert "favorable? p2 meets all" + (favorable-string? "qjhvhtzxzqqjkmpb" #t)) + +(test-assert "favorable? p2 meets all other" + (favorable-string? "xxyxx" #t)) + +(test-equal "file run through p2" + 3 + (dhhieft " +aaaa +qjhvhtzxzqqjkmpb +xxyxx +uurcxstgmygtbstg +ieodomkazucvgmuy" #t)) + + +(test-end "harness") |