Skip to content

Instantly share code, notes, and snippets.

View nudded's full-sized avatar

Toon Willems nudded

View GitHub Profile
@nudded
nudded / day8.rb
Created December 8, 2017 21:44
day8.rb
input = File.readlines('inputs/day8.in')
REGISTERS = Hash.new {|h,k| h[k] = Register.new(k, 0,0)}
class Register < Struct.new(:name, :value, :highest_value); end
class Condition < Struct.new(:register, :condition, :value)
def check
case condition
when ">"
#!/usr/bin/env bash
###
# Usage:
# Add the following set of commands to the setup of a build in the Project Settings
#
# sudo apt-get purge -y postgresql-client-* postgresql-* postgresql-contrib-* postgresql-server-dev-* libpq-dev
# sudo apt-get update
# wget https://gist.githubusercontent.com/mimimalizam/b9ee28d74e1a59d58719916f42c18226/raw/pg_semaphore.sh && bash pg_semaphore.sh
#
#! /usr/bin/env bash
. /home/runner/.bash_profile
ruby_version=${1:-"2.3.1"}
ruby_archive="$ruby_version.tar.gz"
ruby_install_path="/home/runner/.rbenv/versions/$ruby_version"
echo "*****************************************"
echo "Setting up Ruby $ruby_version"
❯ rbenv local 2.6.5
~
❯ ruby test.rb
true
Rehearsal -------------------------------------------
answer1 0.892859 0.026647 0.919506 ( 0.921522)
answer2 0.890985 0.035343 0.926328 ( 0.927158)
---------------------------------- total: 1.845834sec
list = 10000000.times.map {rand(10)}
def answer(list)
amount_of_zeros = 0
index = list.size - 1
while index >= 0
if list[index].zero?
amount_of_zeros += 1
elsif amount_of_zeros > 0
list[index], list[index+amount_of_zeros] = list[index+amount_of_zeros], list[index]