diff options
Diffstat (limited to '2023/ocaml/day2/_build')
25 files changed, 70 insertions, 0 deletions
diff --git a/2023/ocaml/day2/_build/.db b/2023/ocaml/day2/_build/.db Binary files differnew file mode 100644 index 0000000..9629230 --- /dev/null +++ b/2023/ocaml/day2/_build/.db diff --git a/2023/ocaml/day2/_build/.digest-db b/2023/ocaml/day2/_build/.digest-db Binary files differnew file mode 100644 index 0000000..0c7bdb2 --- /dev/null +++ b/2023/ocaml/day2/_build/.digest-db diff --git a/2023/ocaml/day2/_build/.filesystem-clock b/2023/ocaml/day2/_build/.filesystem-clock new file mode 100644 index 0000000..c61f4a7 --- /dev/null +++ b/2023/ocaml/day2/_build/.filesystem-clock @@ -0,0 +1 @@ +<dummy>
\ No newline at end of file diff --git a/2023/ocaml/day2/_build/.lock b/2023/ocaml/day2/_build/.lock new file mode 100644 index 0000000..5f977d9 --- /dev/null +++ b/2023/ocaml/day2/_build/.lock @@ -0,0 +1 @@ +12823
\ No newline at end of file diff --git a/2023/ocaml/day2/_build/default/.dune/configurator b/2023/ocaml/day2/_build/default/.dune/configurator new file mode 100644 index 0000000..2df6f9a --- /dev/null +++ b/2023/ocaml/day2/_build/default/.dune/configurator @@ -0,0 +1,2 @@ +(ocamlc /home/santo/.opam/default/bin/ocamlc.opt) +(ocaml_config_vars (afl_instrument false) (architecture amd64) (asm as) (asm_cfi_supported true) (ast_impl_magic_number Caml1999M033) (ast_intf_magic_number Caml1999N033) (bytecomp_c_compiler "gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -D_FILE_OFFSET_BITS=64 ") (bytecomp_c_libraries " -lm -lpthread") (c_compiler gcc) (ccomp_type cc) (cma_magic_number Caml1999A033) (cmi_magic_number Caml1999I033) (cmo_magic_number Caml1999O033) (cmt_magic_number Caml1999T033) (cmx_magic_number Caml1999Y033) (cmxa_magic_number Caml1999Z033) (cmxs_magic_number Caml1999D033) (compression_supported false) (default_executable_name a.out) (default_safe_string true) (exec_magic_number Caml1999X033) (ext_asm .s) (ext_dll .so) (ext_exe "") (ext_lib .a) (ext_obj .o) (flambda false) (flat_float_array true) (function_sections true) (host x86_64-pc-linux-gnu) (int_size 63) (linear_magic_number Caml1999L033) (model default) (naked_pointers false) (native_c_compiler "gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -D_FILE_OFFSET_BITS=64 ") (native_c_libraries " -lm -lpthread") (native_compiler true) (native_dynlink true) (native_pack_linker "ld -r -o ") (ocamlc_cflags "-O2 -fno-strict-aliasing -fwrapv -pthread -fPIC ") (ocamlc_cppflags " -D_FILE_OFFSET_BITS=64 ") (ocamlopt_cflags "-O2 -fno-strict-aliasing -fwrapv -pthread -fPIC ") (ocamlopt_cppflags " -D_FILE_OFFSET_BITS=64 ") (os_type Unix) (safe_string true) (standard_library /home/santo/.opam/default/lib/ocaml) (standard_library_default /home/santo/.opam/default/lib/ocaml) (supports_shared_libraries true) (system linux) (systhread_supported true) (target x86_64-pc-linux-gnu) (version 5.1.0) (windows_unicode false) (with_frame_pointers false) (word_size 64)) diff --git a/2023/ocaml/day2/_build/default/.dune/configurator.v2 b/2023/ocaml/day2/_build/default/.dune/configurator.v2 new file mode 100644 index 0000000..3edd1f2 --- /dev/null +++ b/2023/ocaml/day2/_build/default/.dune/configurator.v2 @@ -0,0 +1 @@ +((6:ocamlc40:/home/santo/.opam/default/bin/ocamlc.opt)(17:ocaml_config_vars((14:afl_instrument5:false)(12:architecture5:amd64)(3:asm2:as)(17:asm_cfi_supported4:true)(21:ast_impl_magic_number12:Caml1999M033)(21:ast_intf_magic_number12:Caml1999N033)(19:bytecomp_c_compiler77:gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -D_FILE_OFFSET_BITS=64 )(20:bytecomp_c_libraries15: -lm -lpthread)(10:c_compiler3:gcc)(10:ccomp_type2:cc)(16:cma_magic_number12:Caml1999A033)(16:cmi_magic_number12:Caml1999I033)(16:cmo_magic_number12:Caml1999O033)(16:cmt_magic_number12:Caml1999T033)(16:cmx_magic_number12:Caml1999Y033)(17:cmxa_magic_number12:Caml1999Z033)(17:cmxs_magic_number12:Caml1999D033)(21:compression_supported5:false)(23:default_executable_name5:a.out)(19:default_safe_string4:true)(17:exec_magic_number12:Caml1999X033)(7:ext_asm2:.s)(7:ext_dll3:.so)(7:ext_exe0:)(7:ext_lib2:.a)(7:ext_obj2:.o)(7:flambda5:false)(16:flat_float_array4:true)(17:function_sections4:true)(4:host19:x86_64-pc-linux-gnu)(8:int_size2:63)(19:linear_magic_number12:Caml1999L033)(5:model7:default)(14:naked_pointers5:false)(17:native_c_compiler77:gcc -O2 -fno-strict-aliasing -fwrapv -pthread -fPIC -D_FILE_OFFSET_BITS=64 )(18:native_c_libraries15: -lm -lpthread)(15:native_compiler4:true)(14:native_dynlink4:true)(18:native_pack_linker9:ld -r -o )(13:ocamlc_cflags48:-O2 -fno-strict-aliasing -fwrapv -pthread -fPIC )(15:ocamlc_cppflags24: -D_FILE_OFFSET_BITS=64 )(15:ocamlopt_cflags48:-O2 -fno-strict-aliasing -fwrapv -pthread -fPIC )(17:ocamlopt_cppflags24: -D_FILE_OFFSET_BITS=64 )(7:os_type4:Unix)(11:safe_string4:true)(16:standard_library35:/home/santo/.opam/default/lib/ocaml)(24:standard_library_default35:/home/santo/.opam/default/lib/ocaml)(25:supports_shared_libraries4:true)(6:system5:linux)(19:systhread_supported4:true)(6:target19:x86_64-pc-linux-gnu)(7:version5:5.1.0)(15:windows_unicode5:false)(19:with_frame_pointers5:false)(9:word_size2:64))))
\ No newline at end of file diff --git a/2023/ocaml/day2/_build/default/bin/.main.eobjs/byte/dune__exe__Main.cmi b/2023/ocaml/day2/_build/default/bin/.main.eobjs/byte/dune__exe__Main.cmi Binary files differnew file mode 100644 index 0000000..1886df9 --- /dev/null +++ b/2023/ocaml/day2/_build/default/bin/.main.eobjs/byte/dune__exe__Main.cmi diff --git a/2023/ocaml/day2/_build/default/bin/.main.eobjs/byte/dune__exe__Main.cmti b/2023/ocaml/day2/_build/default/bin/.main.eobjs/byte/dune__exe__Main.cmti Binary files differnew file mode 100644 index 0000000..87d60ff --- /dev/null +++ b/2023/ocaml/day2/_build/default/bin/.main.eobjs/byte/dune__exe__Main.cmti diff --git a/2023/ocaml/day2/_build/default/bin/.main.eobjs/native/dune__exe__Main.cmx b/2023/ocaml/day2/_build/default/bin/.main.eobjs/native/dune__exe__Main.cmx Binary files differnew file mode 100644 index 0000000..fdc4cf6 --- /dev/null +++ b/2023/ocaml/day2/_build/default/bin/.main.eobjs/native/dune__exe__Main.cmx diff --git a/2023/ocaml/day2/_build/default/bin/.main.eobjs/native/dune__exe__Main.o b/2023/ocaml/day2/_build/default/bin/.main.eobjs/native/dune__exe__Main.o Binary files differnew file mode 100644 index 0000000..7bbc169 --- /dev/null +++ b/2023/ocaml/day2/_build/default/bin/.main.eobjs/native/dune__exe__Main.o diff --git a/2023/ocaml/day2/_build/default/bin/.merlin-conf/exe-main b/2023/ocaml/day2/_build/default/bin/.merlin-conf/exe-main Binary files differnew file mode 100644 index 0000000..647fe64 --- /dev/null +++ b/2023/ocaml/day2/_build/default/bin/.merlin-conf/exe-main diff --git a/2023/ocaml/day2/_build/default/bin/main.exe b/2023/ocaml/day2/_build/default/bin/main.exe Binary files differnew file mode 100755 index 0000000..1b3c926 --- /dev/null +++ b/2023/ocaml/day2/_build/default/bin/main.exe diff --git a/2023/ocaml/day2/_build/default/bin/main.ml b/2023/ocaml/day2/_build/default/bin/main.ml new file mode 100644 index 0000000..6dba854 --- /dev/null +++ b/2023/ocaml/day2/_build/default/bin/main.ml @@ -0,0 +1,39 @@ +let input_file = "input.txt" + +let read_file f = + let ic = open_in f in + try + let lines = really_input_string ic (in_channel_length ic) in + let lines = String.trim lines in + close_in ic ; + lines + with e -> + close_in_noerr ic; + raise e + +let rec parse ?(result=0) body = + match body with + | [] -> result + | x :: tail -> + let plays = String.split_on_char ':' x + |> List.rev + |> List.hd + |> String.split_on_char ';' + |> List.map (String.split_on_char ',') + |> List.map (List.map @@ String.trim) + |> List.map (List.map (fun x -> (List.hd (String.split_on_char ' ' x) |> int_of_string, String.get (List.nth (String.split_on_char ' ' x) 1 ) 0))) + in + + + let points = List.map (List.map (fun (p,c) -> if (c = 'r' && p > 12) || (c = 'g' && p > 13) || (c = 'b' && p > 14) then 0 else 1)) plays in + let add = if List.length (List.filter (fun x -> List.length x > 0) @@ List.map (List.filter (fun x -> x = 0)) points) = 0 then + String.split_on_char ':' x |> List.hd |> String.split_on_char ' ' |> List.rev |> List.hd |> int_of_string + else + 0 in + + parse tail ~result:(result+add) + + +let () = + let result = parse (String.split_on_char '\n' (read_file input_file)) in + Printf.printf "%d" result diff --git a/2023/ocaml/day2/_build/default/bin/main.mli b/2023/ocaml/day2/_build/default/bin/main.mli new file mode 100644 index 0000000..335ae1f --- /dev/null +++ b/2023/ocaml/day2/_build/default/bin/main.mli @@ -0,0 +1 @@ +(* Auto-generated by Dune *)
\ No newline at end of file diff --git a/2023/ocaml/day2/_build/default/lib/.day2.objs/byte/day2.cmi b/2023/ocaml/day2/_build/default/lib/.day2.objs/byte/day2.cmi Binary files differnew file mode 100644 index 0000000..7806bc1 --- /dev/null +++ b/2023/ocaml/day2/_build/default/lib/.day2.objs/byte/day2.cmi diff --git a/2023/ocaml/day2/_build/default/lib/.day2.objs/byte/day2.cmo b/2023/ocaml/day2/_build/default/lib/.day2.objs/byte/day2.cmo Binary files differnew file mode 100644 index 0000000..72a7297 --- /dev/null +++ b/2023/ocaml/day2/_build/default/lib/.day2.objs/byte/day2.cmo diff --git a/2023/ocaml/day2/_build/default/lib/.day2.objs/byte/day2.cmt b/2023/ocaml/day2/_build/default/lib/.day2.objs/byte/day2.cmt Binary files differnew file mode 100644 index 0000000..ead5d30 --- /dev/null +++ b/2023/ocaml/day2/_build/default/lib/.day2.objs/byte/day2.cmt diff --git a/2023/ocaml/day2/_build/default/lib/.day2.objs/native/day2.cmx b/2023/ocaml/day2/_build/default/lib/.day2.objs/native/day2.cmx Binary files differnew file mode 100644 index 0000000..23b029c --- /dev/null +++ b/2023/ocaml/day2/_build/default/lib/.day2.objs/native/day2.cmx diff --git a/2023/ocaml/day2/_build/default/lib/.day2.objs/native/day2.o b/2023/ocaml/day2/_build/default/lib/.day2.objs/native/day2.o Binary files differnew file mode 100644 index 0000000..59dab7d --- /dev/null +++ b/2023/ocaml/day2/_build/default/lib/.day2.objs/native/day2.o diff --git a/2023/ocaml/day2/_build/default/lib/.merlin-conf/lib-day2 b/2023/ocaml/day2/_build/default/lib/.merlin-conf/lib-day2 Binary files differnew file mode 100644 index 0000000..df37a97 --- /dev/null +++ b/2023/ocaml/day2/_build/default/lib/.merlin-conf/lib-day2 diff --git a/2023/ocaml/day2/_build/default/lib/day2.a b/2023/ocaml/day2/_build/default/lib/day2.a Binary files differnew file mode 100644 index 0000000..b7e4559 --- /dev/null +++ b/2023/ocaml/day2/_build/default/lib/day2.a diff --git a/2023/ocaml/day2/_build/default/lib/day2.cmxa b/2023/ocaml/day2/_build/default/lib/day2.cmxa Binary files differnew file mode 100644 index 0000000..b2af724 --- /dev/null +++ b/2023/ocaml/day2/_build/default/lib/day2.cmxa diff --git a/2023/ocaml/day2/_build/default/lib/day2.ml-gen b/2023/ocaml/day2/_build/default/lib/day2.ml-gen new file mode 100644 index 0000000..71d4a7c --- /dev/null +++ b/2023/ocaml/day2/_build/default/lib/day2.ml-gen @@ -0,0 +1 @@ +(* generated by dune *) diff --git a/2023/ocaml/day2/_build/install/default/bin/day2 b/2023/ocaml/day2/_build/install/default/bin/day2 new file mode 120000 index 0000000..9cc466a --- /dev/null +++ b/2023/ocaml/day2/_build/install/default/bin/day2 @@ -0,0 +1 @@ +../../../default/bin/main.exe
\ No newline at end of file diff --git a/2023/ocaml/day2/_build/log b/2023/ocaml/day2/_build/log new file mode 100644 index 0000000..142f06e --- /dev/null +++ b/2023/ocaml/day2/_build/log @@ -0,0 +1,23 @@ +# dune exec day2 +# OCAMLPARAM: unset +# Shared cache: disabled +# Shared cache location: /home/santo/.cache/dune/db +# Workspace root: /home/santo/code/aoc/2023/ocaml/day2 +# Auto-detected concurrency: 8 +# Dune context: +# { name = "default" +# ; kind = "default" +# ; profile = Dev +# ; merlin = true +# ; fdo_target_exe = None +# ; build_dir = In_build_dir "default" +# ; installed_env = +# map +# { "INSIDE_DUNE" : +# "/home/santo/code/aoc/2023/ocaml/day2/_build/default" +# ; "OCAML_COLOR" : "always" +# ; "OPAMCOLOR" : "always" +# } +# ; instrument_with = [] +# } +$ /home/santo/.opam/default/bin/ocamlc.opt -config > /tmp/dune_e1b366_output |