Skip to content

Instantly share code, notes, and snippets.

View zindel's full-sized avatar

Oleksiy Golovko zindel

  • Prague, The Czech Republic
View GitHub Profile
" {{{ Plugins
call plug#begin('~/.vim/plugged2')
Plug 'altercation/vim-colors-solarized'
Plug 'editorconfig/editorconfig-vim'
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
Plug 'zindel/vim-reasonml'
Plug 'let-def/ocp-indent-vim'
Plug 'tpope/vim-commentary'
Plug 'dense-analysis/ale'
" {{{ Plugins
call plug#begin('~/.vim/plugged2')
Plug 'altercation/vim-colors-solarized'
Plug 'editorconfig/editorconfig-vim'
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
Plug 'zindel/vim-reasonml'
let run tiles program =
let tiles = ref tiles in
let score = ref 0L in
let prev_ball = ref (find Ball !tiles) in
let x_pad_desired, y_pad = find HPaddle !tiles in
let x_pad_desired = ref x_pad_desired in
let update_ball_line (x2, y2) =
let (x1, y1) = !prev_ball in
printf "BALL: (%Ld, %Ld) => (%Ld, %Ld)\n" x1 y1 x2 y2;
printf "(Y = %Ld) XPAD: %Ld => " y_pad !x_pad_desired;
1102,34463338,34463338,63,1007,63,34463338,63,1005,63,53,1101,3,0,1000,109,988,209,12,9,1000,209,6,209,3,203,0,1008,1000,1,63,1005,63,65,1008,1000,2,63,1005,63,904,1008,1000,0,63,1005,63,58,4,25,104,0,99,4,0,104,0,99,4,17,104,0,99,0,0,1102,35,1,1010,1102,1,33,1013,1101,0,715,1022,1102,1,20,1004,1102,1,24,1012,1101,36,0,1005,1101,0,655,1024,1102,32,1,1014,1101,0,499,1026,1102,1,242,1029,1101,0,25,1002,1101,0,27,1017,1101,708,0,1023,1101,0,21,1016,1101,0,28,1000,1101,0,492,1027,1102,34,1,1015,1102,29,1,1007,1102,247,1,1028,1101,0,39,1011,1102,1,31,1018,1102,1,0,1020,1102,1,37,1006,1101,1,0,1021,1102,26,1,1009,1102,1,38,1008,1101,30,0,1019,1102,1,23,1001,1102,650,1,1025,1101,22,0,1003,109,7,2101,0,-7,63,1008,63,29,63,1005,63,205,1001,64,1,64,1105,1,207,4,187,1002,64,2,64,109,-1,1202,-1,1,63,1008,63,35,63,1005,63,227,1106,0,233,4,213,1001,64,1,64,1002,64,2,64,109,17,2106,0,5,4,239,1105,1,251,1001,64,1,64,1002,64,2,64,109,-1,21108,40,39,-4,1005,1018,271,1001,64,1,64,1106,0,273,4,257,1002,64,2,64,109,-9,1206,8,285,
module Int64 = Z
let i0 = Z.of_int 0
let i1 = Z.of_int 1
let i2 = Z.of_int 2
let i3 = Z.of_int 3
let i4 = Z.of_int 4
module Intcode = struct
let (+) = Int64.add
module Intcode = struct
type t = {
program: int array;
mutable pos: int;
inputs: int Queue.t;
mutable outputs: int list;
mutable last_op: op
}
and op = | Halt | Input | Output | Other
let solve lines =
let graph = Hashtbl.create 5000 in
let cache = Hashtbl.create 5000 in
lines |> List.iter (fun s ->
match CCString.split_on_char ')' s with
| to_ :: from :: [] ->
begin match Hashtbl.find graph from with
| exception Not_found ->
Hashtbl.replace graph from to_;
| found ->
let solve lines =
let program =
lines
|> List.hd
|> CCString.split_on_char ','
|> List.map int_of_string
in
let access () =
let program = Array.of_list program in
let get = Array.get program in
let solve lines =
let program =
lines
|> List.hd
|> CCString.split_on_char ','
|> List.map int_of_string
in
let access () =
let program = Array.of_list program in
let get = Array.get program in
let solve lines =
let fuel = fun n -> n / 3 - 2 in
let sum = List.fold_left (+) 0 in
let nums =
lines
|> List.map int_of_string
in
nums
|> List.map fuel
|> sum