summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/day1.ml25
-rw-r--r--lib/day10.ml7
-rw-r--r--lib/day11.ml7
-rw-r--r--lib/day12.ml7
-rw-r--r--lib/day13.ml7
-rw-r--r--lib/day14.ml7
-rw-r--r--lib/day15.ml7
-rw-r--r--lib/day16.ml7
-rw-r--r--lib/day17.ml7
-rw-r--r--lib/day18.ml7
-rw-r--r--lib/day19.ml7
-rw-r--r--lib/day2.ml7
-rw-r--r--lib/day20.ml7
-rw-r--r--lib/day21.ml7
-rw-r--r--lib/day22.ml7
-rw-r--r--lib/day23.ml7
-rw-r--r--lib/day24.ml7
-rw-r--r--lib/day25.ml7
-rw-r--r--lib/day3.ml7
-rw-r--r--lib/day4.ml7
-rw-r--r--lib/day5.ml7
-rw-r--r--lib/day6.ml7
-rw-r--r--lib/day7.ml7
-rw-r--r--lib/day8.ml7
-rw-r--r--lib/day9.ml7
-rw-r--r--lib/dune3
26 files changed, 195 insertions, 1 deletions
diff --git a/lib/day1.ml b/lib/day1.ml
new file mode 100644
index 0000000..748b529
--- /dev/null
+++ b/lib/day1.ml
@@ -0,0 +1,25 @@
+open Core
+
+(* Take text input from file and process accordingly *)
+let process_input input = String.split_lines input |> List.map ~f:int_of_string
+
+(* Fill in solutions for each part *)
+let part_1 input =
+  let freq_changes = process_input input in
+  List.fold freq_changes ~init:0 ~f:(+)
+
+let part_2 input =
+  let freq_changes = process_input input |> Sequence.cycle_list_exn in
+  let counter = Hashtbl.create (module Int) in
+  let increment key = Hashtbl.update_and_return counter key 
+    ~f:(function
+        | Some num -> num + 1
+        | None -> 1) in
+  Sequence.fold_until freq_changes ~init:0 
+    ~f:(fun sum freq ->
+      if (increment (sum + freq)) = 2
+      then
+        Stop (sum + freq)
+      else
+        Continue (sum + freq))
+    ~finish:(fun sum -> sum)
\ No newline at end of file
diff --git a/lib/day10.ml b/lib/day10.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day10.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day11.ml b/lib/day11.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day11.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day12.ml b/lib/day12.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day12.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day13.ml b/lib/day13.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day13.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day14.ml b/lib/day14.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day14.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day15.ml b/lib/day15.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day15.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day16.ml b/lib/day16.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day16.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day17.ml b/lib/day17.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day17.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day18.ml b/lib/day18.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day18.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day19.ml b/lib/day19.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day19.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day2.ml b/lib/day2.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day2.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day20.ml b/lib/day20.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day20.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day21.ml b/lib/day21.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day21.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day22.ml b/lib/day22.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day22.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day23.ml b/lib/day23.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day23.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day24.ml b/lib/day24.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day24.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day25.ml b/lib/day25.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day25.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day3.ml b/lib/day3.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day3.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day4.ml b/lib/day4.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day4.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day5.ml b/lib/day5.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day5.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day6.ml b/lib/day6.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day6.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day7.ml b/lib/day7.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day7.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day8.ml b/lib/day8.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day8.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/day9.ml b/lib/day9.ml
new file mode 100644
index 0000000..7c5e310
--- /dev/null
+++ b/lib/day9.ml
@@ -0,0 +1,7 @@
+(* Take text input from file and process accordingly *)
+let process_input _input = ()
+
+(* Fill in solutions for each part *)
+let part_1 _input = ()
+
+let part_2 _input = ()
diff --git a/lib/dune b/lib/dune
index 050d705..932cc41 100644
--- a/lib/dune
+++ b/lib/dune
@@ -1,2 +1,3 @@
 (library
- (name AoC2018))
+ (name AoC2018)
+ (libraries stdio core))
\ No newline at end of file