This file contains 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
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 ">" |
This file contains 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 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 | |
# |
This file contains 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 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" |
This file contains 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
❯ 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 |
This file contains 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
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] |
OlderNewer