This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"date":"2018-01-01","time":303,"errors":0},{"date":"2018-01-02","time":377,"errors":0},{"date":"2018-01-03","time":311,"errors":0},{"date":"2018-01-04","time":845,"errors":2},{"date":"2018-01-06","time":1102,"errors":1},{"date":"2018-01-07","time":1794,"errors":1},{"date":"2018-01-08","time":237,"errors":0},{"date":"2018-01-09","time":333,"errors":0},{"date":"2018-01-10","time":547,"errors":0},{"date":"2018-01-11","time":730,"errors":0},{"date":"2018-01-12","time":559,"errors":0},{"date":"2018-01-14","time":1786,"errors":1},{"date":"2018-01-15","time":283,"errors":0},{"date":"2018-01-16","time":339,"errors":0},{"date":"2018-01-17","time":748,"errors":0},{"date":"2018-01-18","time":638,"errors":2},{"date":"2018-01-21","time":1948,"errors":0},{"date":"2018-01-22","time":217,"errors":0},{"date":"2018-01-23","time":413,"errors":0},{"date":"2018-01-24","time":621,"errors":0},{"date":"2018-01-25","time":1036,"errors":0},{"date":"2018-01-26","time":550,"errors":0},{"date":"2018-01-27","time":1918,"errors":0},{"dat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "date" | |
require "strscan" | |
module QFX | |
Transaction = Struct.new(:type, :date, :amount, :fitid, :name, keyword_init: true) | |
class Parser | |
def initialize(raw) | |
@ss = StringScanner.new(raw) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "io/console" | |
require "capybara" | |
require "capybara/dsl" | |
require "selenium-webdriver" | |
require "pry" | |
print "Username: " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
def initialize(id, instructions, input, output) | |
@id, @instructions, @input, @output = id, instructions, input, output | |
@registers = Hash.new {|h,k| | |
if k =~ /[a-z]/ | |
h[k] = 0 | |
else | |
h[k] = k.to_i | |
end | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/Dropbox/src/github.com/kejadlen/advent_of_code/2017/rust master* ⇡ | |
❯ time cargo run --release < ../input/day_05.txt | |
Finished release [optimized] target(s) in 0.0 secs | |
Running `target/release/advent_of_code_2017` | |
25347697 | |
cargo run --release < ../input/day_05.txt 0.55s user 0.04s system 90% cpu 0.649 total | |
~/Dropbox/src/github.com/kejadlen/advent_of_code/2017/rust master* ⇡ | |
❯ time cargo run < ../input/day_05.txt | |
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "csv" | |
filename, column_name, replacement, output = *ARGV[0..3] | |
csv = begin | |
CSV.read(filename, headers: true) | |
rescue | |
puts "input file missing" | |
exit 1 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang typed/racket | |
(define num-update | |
(lambda (#:main [main : Number 0] #:reserve [reserve : Number 1]) | |
(list main reserve))) | |
(print (num-update)) | |
(print (num-update #:main 2)) | |
(print (num-update #:reserve 2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn deserialize_images<'de, D>(de: D) -> Result<Vec<Image>, D::Error> | |
where D: serde::Deserializer<'de> | |
{ | |
let value: serde_json::Value = serde::Deserialize::deserialize(de)?; | |
let object = value | |
.as_object() | |
.ok_or(serde::de::Error::custom("expected an object of images"))?; | |
let images = object | |
.iter() | |
.flat_map(|(k, v)| match (k.as_ref(), v) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
pairs xs = zip xs (tail xs) | |
repeatingPairs xs = filter (\(x,y) -> x == y) $ pairs xs | |
hasRepeatingPairs :: String -> Bool | |
hasRepeatingPairs xs = any (\pair -> length (elemIndices pair rps) >= 2) rps | |
where rps = repeatingPairs xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Turing | |
def initialize(file, tape=nil) | |
@tape = Hash.new('_') | |
@head = 0 | |
# initialize tape | |
tape.split(//).each_with_index {|c,i| @tape[i] = c } if tape | |
# read program instructions | |
@program = Hash[ |