m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2020-12-25 15:45:54 +0100
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2020-12-25 15:45:54 +0100
commite2e8223c6bd35483a17fd803fc1622a1f09ef80c (patch)
tree38817e96f05cdf7b8aa3a06e364b41936716ec15
parentcdb9021fa920744577f65679ef31e81d839b9f2a (diff)
Add day 19
-rw-r--r--19/a.lua101
-rw-r--r--19/b.sh367
-rw-r--r--19/b/Makefile23
-rw-r--r--19/b/grammar.l11
-rw-r--r--19/b/grammar.y146
-rw-r--r--19/b/main.c8
-rw-r--r--19/b/mixins.c8
7 files changed, 664 insertions, 0 deletions
diff --git a/19/a.lua b/19/a.lua
new file mode 100644
index 0000000..0f3164c
--- /dev/null
+++ b/19/a.lua
@@ -0,0 +1,101 @@
+rules = {}
+
+function char(c)
+ return function(s, i)
+ if s:sub(i,i) == c then
+ return i+1
+ else
+ return nil
+ end
+ end
+end
+
+function pick(f, g)
+ return function(s, i)
+ j = f(s, i)
+ if j then
+ return j
+ else
+ return g(s, i)
+ end
+ end
+end
+
+function chain2(fs)
+ return function (s, i)
+ for j = 1, #fs do
+ i = rules[fs[j]](s, i)
+ if not i then
+ return nil
+ end
+ end
+
+ return i
+ end
+end
+
+function chain(f, g)
+ return function (s, i)
+ j = rules[f](s, i)
+ if j then
+ return rules[g](s, j)
+ else
+ return nil
+ end
+ end
+end
+
+function make_chain(rule)
+ space_index = rule:find(' ')
+ if space_index then
+ return chain2({rule:sub(1, space_index - 1), rule:sub(space_index + 1, -1)})
+ else
+ return function (s, i)
+ return rules[rule](s, i)
+ end
+ end
+end
+
+function make_function(rule)
+ if rule:sub(1, 1) == '"' then
+ return char(rule:sub(2, 2))
+ end
+ pipe_index = rule:find('|')
+ if pipe_index then
+ left = make_chain(rule:sub(1, pipe_index - 2))
+ right = make_chain(rule:sub(pipe_index + 2, #rule))
+ return pick(left, right)
+ else
+ return make_chain(rule)
+ end
+end
+
+function parse_rule(rule)
+ colon_index = rule:find(':')
+ if colon_index then
+ rule_number = rule:sub(1, colon_index - 1)
+ rhs = rule:sub(colon_index + 2, -1)
+ rules[rule_number] = make_function(rhs)
+ return true
+ else
+ return false
+ end
+end
+
+lines = io.lines('input.txt')
+
+for line in lines do
+ if not parse_rule(line) then
+ break
+ end
+end
+
+correct = 0
+for line in lines do
+ j = rules['0'](line, 1)
+ if j == #line + 1 then
+ correct = correct + 1
+ end
+end
+
+print(correct)
diff --git a/19/b.sh b/19/b.sh
new file mode 100644
index 0000000..c3125e6
--- /dev/null
+++ b/19/b.sh
@@ -0,0 +1,367 @@
+cd b
+make main &>/dev/null
+
+N=0
+function test() {
+ if echo $1 | ./main > /dev/null; then
+ N=$((N+1))
+ fi
+}
+
+test abbbbabaaababbbbbbabbbbb
+test ababbabbbbabbaaaabbabbabababaaba
+test baabbaaaaaaaabbaaaababaa
+test abababbaaababbaaaabaaabb
+test babaababbaaabaaababaabaabbbabbaabbbbabab
+test aaabbbbbaaaabbaaaabbaabb
+test abbbbabaaaaababababbbbbb
+test bbbbabbabbbbbabbaaaaaaab
+test bababbbaabaabaabbaabbaab
+test aababaabaaabbbbbbbaabbabbabaabbabbbaabbb
+test aabbbabbabababbaabaaaaba
+test babbbbbaababaaaaabbbbbaabaaaaabbbbaaabab
+test abbbabbbbaabaaaaaaabbaaaaabaabbb
+test abbaaaaababbbbbaaabbbaba
+test aababbaaabaabaaaababaabb
+test babaabaaababbbbabbbababaabbabbabaabbbaaabbabbbbabbbbaaba
+test bbabaabababbababaaabbaba
+test bbbbbabababbabaaaaaaabaaaaaaabbabababbbabbbaaaabababaabb
+test aababbbabbabaaabbbababaaaaaaaabbbabbbabaaabaabab
+test baababbbabbabaaaaaabaabbbaaaaabbbbbbababbaaabbaa
+test abbbbabaaabbbbbaaaaaaabb
+test baaaababbbaaaabbababbbbaaaaababaaaaaabaabbaaabbabbbbbaaa
+test abaabaabbbaaabbbaabbaabaaaabbbbb
+test abbbbaaabababaabaaabaaaaabbbbbbaabbbbaab
+test abbaabaaabbbbbababbaaabb
+test aaaaabbaabbbabbbaababbbbbabbbaababbabaaa
+test abbaaaaabaabaaabbbaabbbb
+test aaaabbbabbabaaabbbaababa
+test baaaabbaababaaaabaabbabbabbaababaaababaa
+test bababbababaaaaaaababbaaa
+test aabbaababaabbababbbabbba
+test aabbabbaabaaaaaabbabbabbbaaaabaababbbbbaaabababb
+test bbaaabaababbaababaabaaaaabbabbbaabbbabaa
+test bbabbabbbababababaabbababbbababbbbaaaaba
+test ababbaabbbabbbabbababbbb
+test baabaaababababaaaaaaabbabbaaaaabaabbaabaaaaaaaab
+test ababbbbababaaaabbabaaaaa
+test aaaaababaababbababbbabab
+test baabbababaababbbaabbabaa
+test bbaabbaabbaabaabababbbab
+test bababaaaaabbaabaaaabaaba
+test babbaababbbababaaaaabaaa
+test bbbabaaababaabaabababbbb
+test baaaaabaabbaaaaaaaaabbbb
+test aabbbabbaaaabbaabbbabaabaabbbaba
+test aababababaaaaaaabbbaaabb
+test babbababbbabbbabbaababba
+test bababababaaaaaaabaaaaabababbaabbbbbababb
+test aababaabbbaabbaabbbababb
+test bbaaaaabbbbbaaabbaabababaabbaababbbaababbabbbabbaabbbaabbaaabbaaabbbaaaa
+test aabaababbabbabaabbaaaaba
+test bbaabaaababbbaababbbbbbabaaaaaaaabbabaabbababbbb
+test aaaaabaababbbbaaabbaaabb
+test bbaabbaaabbaababbababbbaabbaabbb
+test bbbbbbbbbabbababbbabaaabaabbbbaaabbaaaba
+test bbabaabbbbaabaaaaabaabaa
+test baaaabaababaabbaaabaabababaaaabbabbaaaba
+test abaababababaabaaababbaba
+test abbabbabbbaabaabbabbaabb
+test babababaabbaabaaabbbaaaa
+test babbaababaaaaababaaabbaaabbaaaba
+test baaaaabbabbaababaaaaabaaababbbbbaabbbaba
+test babbbbaabaaaabbaabbaaaab
+test babbbaaababbbaaaabbaaabb
+test abaababaaabbaababbbbbaab
+test babbbaabaaaababaabaababbaabbaababbabaabbbbbbbaabaabbaaaabaababaa
+test aaaabababaaababbabbbbabaaabbbaba
+test aaabbbbbaababaabababbbaa
+test aabababaaabaaaabbaaaaaaabbabaabbabbbaabaaaaabaabbbabbbaa
+test abababaabbababbabbbbabab
+test bbaabbabaabaababaaaaabbbaaabbaab
+test bbabaaabbababaabbaaaabaabaaababa
+test aabbabbaabababbaaaabaaaaababbbaa
+test aaaaabbbbabbbababaaabbbb
+test baabbabbababaaaabbbbaaaa
+test babbbbbaaaaaabababbbabab
+test bbbaababbaaababbaaabbbaa
+test abbabbabbaaaabbababbaaab
+test aabaabababbabbbbabaababaabababbaaababbabbbbaabaabbbbabbabbabbababbbabbab
+test abaabbabaabbababbbabaaababaaabab
+test baaabaaabbbabaaaabaaaaba
+test babaabaababaabbabbabaaabbabbabbaabaaabba
+test abbbbbaabbbaababbaababba
+test ababbbbaaaababbbbabbabbb
+test baaaaaaababbbaababaaabab
+test aabaaaabaabbaaabaababaaa
+test ababababaaababaababbbabaaabbabbabbbaabbb
+test abbbaaabbabbbabbaabaaabb
+test aaabbbabbbbaaaababbabbba
+test abbbbaaabaaaabbbaaaabaaa
+test abaabbabbbbbbababbbbbbaabaabbbab
+test bbabaabaabbbabbabbbaaaba
+test abbbaaabaabbababaaabaabb
+test aaaabbaabbaabbaababaababbbababbb
+test aababbbaaaaababbabaaabba
+test bbababbabbbbabbabaababba
+test bbbababaaaaabbaaabaabaaabababbaaaaabaaba
+test babaaaabbbaaaabbaaabbaaa
+test bbaaabbbbabbbabaaaaababababababaaabbbaba
+test aaaaabbababbbaabbbaaaaaaabbabbbb
+test baaaabababbbbababbbaaabb
+test aaaababbabaabaabbaaaababbbbabaaababbaaaaabaaabbbaaabaabbaabaaabb
+test abaaaaabbabbaabaaaaaabbaaabaababbbabaaabaabababb
+test aabbaabababaabbabbababbabaaabbab
+test abbbbbaabbbbbabaaabbbaaa
+test bbaabbabababbbbabbabbaaabbaaaaaaabaaaaaaabbbbbaabbabaaaa
+test abbaabababbbbabbbbbababaabaabaaaabaabbabbbaabaabaaaabaab
+test baabbaaabaabbaaaabbaaaaaaabbbababaabaabaabbbabaaabbabbaaaaabaaabbbaaabba
+test bbaaabaaabababbaaaababababbaaaba
+test baaaababbbababbaaaabbabb
+test bbbbbabbabaabbabbbbaabba
+test abbababbbbbbabbbaaaaabaa
+test aababbabbaabbabaaabaabbb
+test babbbabbbbbbbbbbbbababbaababbbbb
+test abababbabaaaaabababbbbab
+test babbaabaaabaababbaaabbaa
+test baabbbaaaababbbbaabbaaabbabbaababbbabbba
+test baaaabbaabaabaabaababbabbbbbaaaa
+test babbaabababbbbaaabbababa
+test abaabbbaabbbbbbababbbabaabbbabaa
+test baabababaabbbbaabbabbaaa
+test babbaabaaabbbaababababbb
+test babaabbaaababbbbaaababbbabbbaaba
+test baaaaababbbbbbababaabaabaabbaaababbaabbaabbbaaaa
+test aaaaababbbbbbabbbaaaabaaaaaabbaa
+test bbaabaababbbaaabaababbbbabababbababaababbbabbababbabbbba
+test babaababbaaaaaaaabbabbaa
+test baabababbbbbbababaabbbab
+test abbbbbabababaaaababbbbab
+test abbaababbbbababaabbabbaa
+test bbbaaabbabaaabaaaaababababbbbbabababbaabbbaaabbababbbbabbaaaababaaaaabbbbabbbbbbbaabbaba
+test baabaaabbabbbbbaabbbbaab
+test baabaaababaaaaaabaabaaba
+test bbaaabbbbabbbbbabbbabbab
+test aabbbbaaaabbbaabababbbaa
+test bbabbbbbaaaaabbbababbbbaaababbbaabbaabab
+test bbbbbbaaaabaababaababaaa
+test bababbaabaaaaababbbaaaaa
+test aabaabaabaabbabbbbbaaaabbaabbbba
+test bbbabbbbbbabbbbaaaaabaaaaaaabbab
+test baabbbabbbbabbbbbbabbbbaabbababa
+test abababaaabbaaaaaaabbababbabaaaabaabaaaabbbbaabbbaaabbabaaaababbaabbabbbb
+test bbaabaaaabbbbabbbbbabbab
+test abaaaaaaabaabaabaabbabaa
+test babbabaaaababaabbbaababa
+test aabbaaabaabbbabbabbbbaab
+test abbaaaaabbabbaaabababbabbbaaabbaababbaba
+test babbababbbbbbbbbabaabbbb
+test bbbaaaababbbabbaabaaaaaabababbbabaaaabbababaabaabaababaa
+test ababbabbbbabbaaaaaababba
+test babbaaaabababbabababbabbbbabaabbaabaabbbabbaabbbbbbaaaaa
+test bbabbaaaaababbaababbaaababbabbaa
+test aabbabbabababaababbbbbbabaabbbbbbbbbbaaa
+test bbaaaaabbaabaabbabababbb
+test aabbaabbabbbbbaabbbabbaa
+test aaaababbbbabaaabaabaabaa
+test aabbbabbbbaaaaaaabbbaabb
+test babbbabaaabbaababbabbbaa
+test abbbbababbbabaaabbbaaabb
+test baabbbaabbaabaaaabbabbbb
+test abbbbaaabbbbbabaaaabbabb
+test aaaababbbaaababbbbabaaaa
+test bbaaaabbbabbbabbabaaaabb
+test babbabaababbbbbaaabaaaabaaababbbabaaababaaababbabaaabbbb
+test bababbababaabaaaababbbab
+test bbbbbbbbabbbabbaababaabb
+test abbbbabababaaabbaabbbbbb
+test bbbbabbbbbbabaaaabbaaabb
+test bbabbbabbbaabaaaabaabaaaaabaababbabaaababbabbaababbaabba
+test baabbaaaaaababbbabaabbbb
+test aaaaaaabbbbbbbaabbbbabbabbbabaabaaababbbbbbbbbaabbaabaaa
+test babbbaabbaaaabbbbabbaaab
+test bbaabbbbabbbbaababababab
+test aaabbbabaaaaabbbbaaabbaa
+test baabaaabaabbabbaababbaaa
+test abbbbbabbaaaaabaaaaababbbbbbbbbbaababbbaabbabababaaabbbb
+test abbbbbaababaaabbabbaaaaaabbbbaabbbbbbaaa
+test baababababbbbabaabaaabbb
+test baaaabbaaababbaaabababbb
+test bbaabbababbbbbbaabbbabab
+test bbaaaaabaababbabbabbbaaabbaabbaaababbaaabbbbbaaa
+test babbbabbbaabbbaaaaaaaaaa
+test baabababbaababbbaabaaabb
+test bababaababaabbabbaabbbbb
+test bbaabaabbbabbabbbbaaabba
+test bbaabbababbaabaabaabbbab
+test babbbbaabaabbabbaabbabaa
+test aabbbbbabaaaabbbbbaaaabbbaaabaaabbbaaaabbbbabbaabbbbbaaaaaabaabbbaabbbab
+test babbbbaaaaababbbbbaabaaaaababaab
+test aaaaababababbabaabbabababaaababbabaaabba
+test bbaaabaabaaaaaababbbbbbb
+test aabababaabbbaabaaaabbabbbaabbbbb
+test bbbbbbabababaabbaaababaabaaaaababbbbbaabababaaaababbbaabaaaaabbabbabbbbbbbabbbbababaaaaababaaabb
+test bbbbabbbaabbbbaaaabbbbaaabbaabaabbaabbba
+test bbbabaaabbbbbabbbbbabbab
+test bbbbabbbbbbbbabbbbaaabaaaabbabbb
+test bbbabaaabbbbabbababbaabb
+test aabbabbabbabbabbabaaabab
+test baaaabbbbaabaaaaababbaaa
+test bbbababbbababaaaaabaaaaaabaaaaababbbbbaabbababababbbaaababaababbaaaaaaba
+test babbbbaaaaaabababbbbabbbaaabbbabaabbabaabbaababb
+test abbbbaaaababaabbababbbbbbaabbabbbbababbbbbbbbaaaaabaaaaaaaabaabaabaabbabbbbaabaaaabaaaab
+test bbaabaabaababbbaabbbabbaaaaabaab
+test abbaababababbbbaabbaaabb
+test baabababbbaaaaabaaabbaaa
+test baaaabababbbbbabaaabaaab
+test abbbbbabbaabbabaabaaabaa
+test baabbbbabbaaaaaabbababaa
+test babbbbbaaaabbbabaababbaabababaabbbaabbbb
+test bbaaaabbbababbaaabababaaababbabb
+test bbbbbababababbbaaaaabbaabbabaababbabbabbaabaabababbbbaabbbabbbba
+test abbbbbabaaabababbaabbbab
+test bbbbbabbaabaababababbbaa
+test babbabaaaaaababbbaababaa
+test aabbbbaaabbbbbaaabaababbbbbabaaabbabbbba
+test bbaaabbbaabaababbbaabbbb
+test abbbbbabbaaaabbbaaabbabb
+test baabaabbbababbbaaabbbaaa
+test bbaabaaaaaaaabababbbabbbbaaabbaa
+test bbababbababbbaabbbababbaabbbaaabababbbab
+test babbbaaababbaaaaaaabbabb
+test abaabaaabababaaabbbaaaabaabbbababbbbaaaabababaaabaaabaab
+test baabaaaaaaabaaaabbaaabab
+test abaabaabbabbbababaaaabbaabbaaaab
+test baabaaaabbaabaaabbbbbbba
+test aaabbbbbbaaaaababbbbaaba
+test aabbababbbaabbababbbbababaaaabbaabaaaaababbbaaaa
+test abbabbbbbbbaaabbbbbaabaaabaaabbbbbbaabaabbbabbbb
+test babbbbbabababbbabbbbbaaa
+test bababaaaaaaabababaaaaaaaaaabbabaaabbbaaabaaabbaababaaaaa
+test abaabaaaaaaaabbabbbbbbaaaabbaababbabbbba
+test abababbaabbbbabaabaabbbb
+test bbabbbabaaaaabbbbbbaabbabababbaabbaaaaabaababbaaaaaaababaaaabbababaaabba
+test baaaaabbaaaabbbaaaabaabb
+test baabaaaabaaaabbbaabbbbbb
+test babaaabbababbabbaaaaaaaa
+test abbabbabbabbababaaaaaaaa
+test baabaaaababbbabababbaabb
+test abbbabbbbaabaabbbabbababaabbaabaaaabbbaa
+test bbabbbabbabbbbbabbabbbaabababbba
+test baaaaabbabaaaaababbababa
+test aaabbbbbbaaabaaabbbaabaa
+test ababbabbaaababbbbabbbbbb
+test bababbabbabbabbaaabbabbbbbabaababbbabbaabbbabaabbabbaaaabbaaaaabbbbabaabaaaabbbabaababbb
+test aaabaaaaabbbbbaabbaabaababbabbabbbababbb
+test bbbbabbabaaaaabbaabbabbb
+test abbaaaaabaaabaaaaabaabba
+test aaaabbaaabbbbabbbbbbbbab
+test ababaaaaaaaabbbaaabbabbabbbababaabbababbaaaabaabababaaabbaaabbba
+test bbbaaaabbabbbbaaabaabaaaabaabbabaaabaaaaaaaabaab
+test aabbbaabbaabaabbbbaabbba
+test babbbbaaabbabbabaabbbaabbaaaaaabbbaaabbbabbabbaa
+test baabaabbbbbabaabababbbaa
+test bbabaaabbabaaabbaaaabaab
+test baabbbaabababbbabbbaaaaaaabbbaba
+test abbbbabaabaabaababbbbbaaabaababbbbaaaaaabaaabbaa
+test babbabbaabbaababaabaabba
+test baaaabbabbbbabbbbbababab
+test baaaabbaababbbbaaaaabbaaaababbaaaabbaabbababbbaaaabbabbb
+test aaaabababaabaaaabaabbbbb
+test aaabababbbbbbbbbabbabbaa
+test bbaabbaaaabbaababbaaabaaababbbaabbabbaba
+test abaaaaabaaabababbaaaabbaabbbbaba
+test bbbbbabbbaaaaaababababababbbabaa
+test bbbabababbaaaaabbbbabbba
+test bbabbbababbaaababbabaababbabbabbabbbababaaabbbaaabbaaaaaabbaaaababaabbab
+test abbbbabaabbbabbaabbaababbabaaaba
+test baaaaabbaaabbbababbabbba
+test bbbababaabbbbaaabbaabbba
+test aabbabbababbbaaaaaaaaaaa
+test abaabbbaaaaaabbaabbbbbbb
+test babbbabbaabaababaaaaaaaa
+test bbabaaabbbbaabbbbbbaaaabbbaababa
+test baaaababaabaaabababbbbaabbaaabbbaaaaaaab
+test aabbaabaaabbabbababbabbb
+test bbbaababaabaaabaaaababaa
+test aaabaaaabbbabaaababaabbababbbbbbbaaabaab
+test babbbbaaabbbaaabbaaaababbababaaabaabaaaababbbabbbbbbaaabbbbbaabb
+test bbaabbaababbbaaaaababbbbaaabbbaaaaaaaaab
+test babababaabaaaaabbaaabbbb
+test baabaababbaababbaaaabaabbbbaaabbabaaabaa
+test aaaaabbbbabbbabbaabbababbababbaa
+test bbbbbabbbababbbabaaabbab
+test babbabababbbaaabbaaababbbababaabbbaaaaba
+test bbababbabbbaabbbabaaaababbbaababbaaaabbaaabbbbabbababaaaaaaabbbabbaaaababaaababb
+test abbbbabbbababbaaababbaaa
+test babbabaaaabbbbbaabbbaaba
+test baaabaaabbbbabbaaabbbbab
+test bbaaaabbbbbababababbbbbababbaabaabaaaabaaaaaaaaa
+test baabbbbabababbaaaaabaaab
+test bbaaaabbabbaabaaaabababaabbaabababbabbabbbabababaaaabaaa
+test abbbbbababbbbabbbbaababb
+test aabbabbabaaaaaabaabbaabaabaaabaaabbabaaaaabbbbbb
+test aaabababaaabaaaabbbaaaabaabbbbbaabbbaaba
+test aababbabbabaababaaabbbaa
+test baaaaaaabbaabbaababbbbab
+test bababbbaaabbbbaabbababaa
+test aabbaaababbbbabbababbaaa
+test bbbaabababbbabbababaabbb
+test aaaababababaabababbbaaaa
+test babbbbbaabababbabbaaabab
+test abbbabbaabaaaaaaababaaaababaaaababbbbbabbaaabbbb
+test babaabaabaaaabaaaabbbaabaabaaababababbaaabbbababbbaababbabbabaab
+test bbbabaaabbbaabbaabaabbbbababbbbaabaaaababbaaabaaabbaaaaaaaabbabb
+test bababbabbabaabbaabbabbaa
+test bbbbabbbbbaaabaaabbabbbb
+test bbababbaaababbbabbbaaaaa
+test babaaabbaababbabaabbbaaa
+test aababbbababbbabbbbaabbbb
+test baaaabbbbaaaababbbbbbabbaabababaaabbbbaabbbaabaabbbbaaabaaababaaaaabbbba
+test babbaaaababbbaaaabbbbaab
+test bababbaabaababaaabaabbbaabbabbbabaabbbabaabababbbbabbabbaabaaabbbaabbbbabaabaaab
+test aabbabbaaabbbaabaabbbbbb
+test abaababababbbbaabbaaaaba
+test bbbabaabaaaabbaabbbbaabb
+test bababbabaabbababaaaababaaaabbbaa
+test aabbbaabbaabbaaabbbbaaaa
+test aababbaabbbbbbaabaabbbbaaabaabba
+test baababbbababbbbaabbbbaab
+test babbaabaaabbaaabbaaaabbabaaaabba
+test abbabbabbaabaabbabbbbaab
+test abababaaabaaaaaaabbbbaaaabbababbaabaabbababbaaab
+test abbbbabbaaabababaaaabaab
+test bbbbbabbbbbaababbaaababa
+test aabbaabbbaaaabbaaabbabbb
+test aaabaaabbbaaaababaabbbabbaabababaaababaabbababaabbabbabbaababaaabbabbbababbbbbbaaaababaa
+test aaaaabbabababbaabaabaaabbababababbabbaabaabbbaaa
+test bababaaababbbbbaaaabababbbabbbba
+test bbbabaaabbbabababababbaaabbbaaabbbbbaaab
+test bbbabababaabbbaaabbbaabb
+test aaabbbbbbabaabababbbbbbb
+test babbaabaaaaaababbbbaaabb
+test baaaaaababaabaabbaabaaba
+test bababbaaaababbbbabbbaaabbabbaaaabbabaabbaabaabaa
+test aabababaababbaabaabbbaba
+test bbabbbabaabbbbaaabbaaaaaababbbbaaaababaa
+test abaabbbababaabbaabbaabbb
+test babaababbbaaaabbaaabbbabaaaabaaa
+test aabababaabbbbbbaaabbbaaa
+test babaababbbabaabbbaabbabaaaabaaababbbbaab
+test aaaaabbbbabbbaabbbabbaba
+test aaaababbbbbbbbaaaaaabaab
+test aabbbbaabbbaababbabababb
+test babbbaabaabbababbabbabbaaaabaabb
+test aaabaaaaabababaabaabaaaabaabbbabbbaabaaaaabaabbabaaaaabbaabbbbbbbaaababb
+test aaabbbabaabbbbbaabbabaab
+test abaaaaababbaabaabbabbbaa
+test bbbbbbaababbaaaabbbabbaa
+test abbababbbabbabaabbbaaaaa
+test baaaaaaaaababbbbababbbab
+test aaababbabbabbabbbaababbabbabaaabbaabbbbbaaabaaabaabbabab
+test aabbbbbababbaaaaaaaaabaaababbaaabbbabbbb
+test bbabbabbaaabaaaabbababab
+test baaaaaaaabbbabbaaaaaaaaa
+test abbbbabbbaabaaaaaaabbbaaaaaabaab
+
+echo $N
diff --git a/19/b/Makefile b/19/b/Makefile
new file mode 100644
index 0000000..9d6a59c
--- /dev/null
+++ b/19/b/Makefile
@@ -0,0 +1,23 @@
+main: main.o mixins.o lex.yy.o grammar.tab.o
+ gcc -o main main.o mixins.o lex.yy.o grammar.tab.o
+
+grammar.tab.h grammar.tab.c: grammar.y
+ bison -d grammar.y
+
+lex.yy.c: grammar.tab.h
+ flex grammar.l
+
+grammar.tab.o: grammar.tab.c
+ gcc -c -o grammar.tab.o grammar.tab.c
+
+lex.yy.o: lex.yy.c
+ gcc -c -o lex.yy.o lex.yy.c
+
+main.o: grammar.tab.h main.c
+ gcc -c -o main.o main.c
+
+mixins.o: mixins.c
+ gcc -c -o mixins.o mixins.c
+
+clean:
+ rm -rf *.o lex.yy.c grammar.tab.h grammar.tab.c main
diff --git a/19/b/grammar.l b/19/b/grammar.l
new file mode 100644
index 0000000..6237a66
--- /dev/null
+++ b/19/b/grammar.l
@@ -0,0 +1,11 @@
+%{
+#include "grammar.tab.h"
+%}
+
+%%
+
+a return A;
+b return B;
+\n return EOL;
+
+%%
diff --git a/19/b/grammar.y b/19/b/grammar.y
new file mode 100644
index 0000000..c347751
--- /dev/null
+++ b/19/b/grammar.y
@@ -0,0 +1,146 @@
+%{
+%}
+
+%token A
+%token B
+%token EOL
+
+%glr-parser
+
+%%
+
+r0: r8 r11 EOL
+r1: r113 r125 | r68 r121
+r2: r117 r125 | r51 r121
+r3: r109 r121 | r12 r125
+r4: r96 r125 | r124 r121
+r5: r125 r74 | r121 r127
+r6: r48 r64
+r7: r125 r52 | r121 r131
+r8: r42 | r42 r8
+r9: r121 r124 | r125 r46
+r10: r125 r102 | r121 r88
+r11: r42 r31 | r42 r11 r31
+r12: r125 r51 | r121 r44
+r13: r70 r121 | r47 r125
+r14: r83 r125 | r130 r121
+r15: r104 r121 | r95 r125
+r16: r121 r99 | r125 r98
+r17: r48 r113
+r18: r125 r111 | r121 r66
+r19: r125 r90 | r121 r3
+r20: r35 r121 | r27 r125
+r21: r125 r44 | r121 r96
+r22: r125 r125 | r48 r121
+r23: r121 r84
+r24: r125 r78 | r121 r5
+r25: r121 r56 | r125 r44
+r26: r121 r77 | r125 r129
+r27: r44 r121 | r127 r125
+r28: r124 r121 | r74 r125
+r29: r56 r121
+r30: r125 r116
+r31: r121 r120 | r125 r126
+r32: r82 r121 | r29 r125
+r33: r74 r125 | r68 r121
+r34: r50 r121 | r105 r125
+r35: r121 r85 | r125 r56
+r36: r125 r19 | r121 r43
+r37: r68 r121 | r56 r125
+r38: r24 r125 | r7 r121
+r39: r46 r121 | r44 r125
+r40: r125 r92 | r121 r6
+r41: r125 r113 | r121 r124
+r42: r125 r34 | r121 r103
+r43: r121 r49 | r125 r114
+r44: r125 r125 | r121 r125
+r45: r127 r125 | r74 r121
+r46: r121 r121 | r121 r125
+r47: r59 r125 | r69 r121
+r48: r121 | r125
+r49: r82 r121 | r21 r125
+r50: r125 r93 | r121 r14
+r51: r48 r125 | r125 r121
+r52: r121 r124
+r53: r121 r22 | r125 r127
+r54: r121 r125 | r125 r121
+r55: r118 r121 | r69 r125
+r56: r125 r125
+r57: r22 r121 | r51 r125
+r58: r121 r17 | r125 r77
+r59: r48 r127
+r60: r124 r121 | r54 r125
+r61: r46 r125 | r85 r121
+r62: r132 r125 | r75 r121
+r63: r121 r61 | r125 r53
+r64: r121 r117 | r125 r85
+r65: r125 r45 | r121 r25
+r66: r121 r68 | r125 r85
+r67: r121 r54 | r125 r22
+r68: r125 r125 | r125 r121
+r69: r22 r125 | r96 r121
+r70: r121 r87 | r125 r1
+r71: r122 r121 | r73 r125
+r72: r125 r9 | r121 r107
+r73: r125 r72 | r121 r18
+r74: r125 r125 | r121 r121
+r75: r121 r127 | r125 r117
+r76: r121 r13 | r125 r38
+r77: r96 r121 | r46 r125
+r78: r54 r121 | r74 r125
+r79: r46 r48
+r80: r91 r125 | r112 r121
+r81: r121 r46 | r125 r68
+r82: r48 r44
+r83: r125 r2 | r121 r81
+r84: r121 r46
+r85: r121 r125
+r86: r85 r125 | r54 r121
+r87: r121 r51 | r125 r96
+r88: r125 r94 | r121 r30
+r89: r86 r125 | r39 r121
+r90: r28 r121 | r41 r125
+r91: r108 r125 | r39 r121
+r92: r121 r41 | r125 r100
+r93: r121 r58 | r125 r16
+r94: r37 r125 | r61 r121
+r95: r32 r125 | r55 r121
+r96: r125 r121
+r97: r89 r125 | r62 r121
+r98: r56 r121 | r54 r125
+r99: r96 r125 | r96 r121
+r100: r96 r125 | r54 r121
+r101: r79 r121 | r35 r125
+r102: r23 r121 | r65 r125
+r103: r125 r15 | r121 r71
+r104: r20 r125 | r115 r121
+r105: r125 r80 | r121 r40
+r106: r127 r121 | r117 r125
+r107: r121 r113 | r125 r22
+r108: r74 r121 | r56 r125
+r109: r127 r48
+r110: r33 r125 | r60 r121
+r111: r48 r68
+r112: r9 r121 | r77 r125
+r113: r121 r121 | r125 r121
+r114: r121 r123 | r125 r67
+r115: r121 r4 | r125 r81
+r116: r125 r117 | r121 r54
+r117: r48 r48
+r118: r121 r127 | r125 r96
+r119: r97 r121 | r128 r125
+r120: r125 r76 | r121 r119
+r121: A
+r122: r63 r125 | r26 r121
+r123: r113 r121 | r68 r125
+r124: r121 r125 | r48 r121
+r125: B
+r126: r121 r10 | r125 r36
+r127: r125 r125 | r121 r48
+r128: r101 r121 | r110 r125
+r129: r125 r56 | r121 r56
+r130: r106 r121 | r57 r125
+r131: r68 r121 | r117 r125
+r132: r121 r68 | r125 r113
+
+%%
diff --git a/19/b/main.c b/19/b/main.c
new file mode 100644
index 0000000..dc10700
--- /dev/null
+++ b/19/b/main.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+#include "grammar.tab.h"
+
+int main() {
+ int result = 0;
+ int count = 0;
+ return yyparse();
+}
diff --git a/19/b/mixins.c b/19/b/mixins.c
new file mode 100644
index 0000000..9c2ae9e
--- /dev/null
+++ b/19/b/mixins.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int yyerror(char *s) {
+ printf("%s\n", s);
+}
+
+int yywrap() {
+}