summaryrefslogtreecommitdiff
path: root/doesnt-he-have-intern-elves-for-this/README.org
diff options
context:
space:
mode:
Diffstat (limited to 'doesnt-he-have-intern-elves-for-this/README.org')
-rw-r--r--doesnt-he-have-intern-elves-for-this/README.org44
1 files changed, 44 insertions, 0 deletions
diff --git a/doesnt-he-have-intern-elves-for-this/README.org b/doesnt-he-have-intern-elves-for-this/README.org
new file mode 100644
index 0000000..158ce72
--- /dev/null
+++ b/doesnt-he-have-intern-elves-for-this/README.org
@@ -0,0 +1,44 @@
+See: https://adventofcode.com/2015/day/5
+** Part 1
+*** Purpose
+Given a list of lines of strings:
+
+#+begin_example
+sszojmmrrkwuftyv
+isaljhemltsdzlum
+fujcyucsrxgatisb
+qiqqlmcgnhzparyg
+#+end_example
+
+Categorize a string as favorable if it follows these rules:
+
+1. It contains at least three vowels (aeiou only), like aei, xazegov, or aeiouaeiouaeiou.
+2. It contains at least one letter that appears twice in a row, like xx, abcdde (dd), or aabbccdd (aa, bb, cc, or dd).
+
+But does NOT:
+1. Contain the strings ab, cd, pq, or xy, even if they are part of one of the other requirements.
+
+*** Method
+
+There are a lot of ways we can accomplish this. Personally, I prefer the obvious way:
+
+Construct a few different predicate procedures that determine whether one of the above condictions is true.
+Construct an overarching predicate function that runs all of the sub-functions, and uses and/or logic to report accept=#t/#f.
+
+Run all strings through, returning a boolean list, and then simply count the number of '#t's.
+
+** Part 2
+*** Purpose
+The next part revokes the old rules and introduces two new ones:
+
+1. Contains a pair of any two letters that appear at least twice in the string without overlapping, like xyxy (xy) or aabcdefgaa (aa), but not like aaa (aa, but it overlaps).
+2. Contains at least one letter which repeats with exactly one letter between them, like xyx, abcdefeghi (efe), or even aaa.
+
+*** Method
+The repeated-char? character must now be able to accept an argument that specifies a "gap" to look ahead.
+
+Rather than the old way, it makes sense to now look ~x~ characters ahead on each iteration. If ~x~ characters ahead is equal to current char, then we return true.
+
+The first rule is harder... In all cases of this "repeating char" rule, it is when the same character repeats three times.
+
+Maybe we can store /all/ pairs of characters as an a-list, using the index of the first character as the key, and the pair as