Skip to content

Instantly share code, notes, and snippets.

Avatar

Isaiah Fischer Rodel30

View GitHub Profile
View Day01.rb
inp = '572762743879445378236526261778533844111463253844949359244543366119531191736381916713262548326248415934216676834743491546681777434377459654616786366318635414628935476168779149146623588363654211985162633359265447163318141252957125811583993213726837427734236262866697594159593913747442145956827958186155326738778684241969264977311443197364451417281233229625472885724345641784927536818422448883685424238322282111728424562312757381827642322659336251193125981611921932148989492677654174683489351346189646831271943917961653681455488144731298576979893226213687447256851833468253332478667347358944933952187814643469517778739298989613587962748898268945295996454426574234385624238532475436215654688197999315987547534675938323281474393415861252627337371283869615963947281597192927875974268989451987882114178546629483584227294713124564377789787497539272514316775335757523124474883371569562174519656434544453297583271299666571893328249691414485386819796326111993858969659468497254219781377533662524599149136378587831467354697587167
@Rodel30
Rodel30 / summation_sets.rb
Created Apr 20, 2017
"Friday" Puzzle 2017-04-19
View summation_sets.rb
# Full on brute force
def f(r,s)
(1..r.size).reduce([]){|c,n| c + r.combination(n).select{|c| c.reduce(&:+) == s }}.sort_by{|c| c.size }
end
# Minor optimization for very large arrays of small numbers seeking a sum that is small
# via limiting the combination sizes we consider based on min and max numbers necessary
# to reach the sum from either end of the spectrum. Probably a cleaner way to find the
# min and max n, but couldn't be bothered.
def f(r,s)
@Rodel30
Rodel30 / day01_challenge1.rb
Last active Dec 21, 2016
Advent of Code 2016
View day01_challenge1.rb
def calc_distance(instruction_block)
instructions = instruction_block.split(', ')
location = { x: 0, y: 0 }
directions = [ [ :y, :+ ], [ :x, :+ ], [ :y, :- ], [ :x, :- ] ]
direction = 0
instructions.each do |i|
turn = i[0]
distance = i[1..-1].to_i
direction = turn == 'L' ? direction.pred : direction.next
@Rodel30
Rodel30 / ranks.rb
Created Nov 4, 2016
Ruby solution for CFML Slack Friday Puzzle
View ranks.rb
require 'open-uri'
require 'json'
data = JSON.load(open("https://gist.githubusercontent.com/ryanguill/036a35ad8cc07bf600b25212eacc3ced/raw/4c5f67ecc4993c09f5776c8b0144020beda798e6/karma.json"))
counts_by_user = data.each_with_object(Hash.new(0)){|k,counts| counts[k['user']] += 1 }
users_by_score = counts_by_user.group_by{|k,v| v }
top_scores = users_by_score.keys.sort.reverse.first(10)
@Rodel30
Rodel30 / php_deserialize.cfc
Last active Aug 22, 2016
Basic attempt at a php deserializer in CFML
View php_deserialize.cfc
component {
public any function run(required string data){
variables.data = arguments.data;
variables.position = 1;
variables.bytebuffer = CreateObject("java", "java.nio.ByteBuffer");
return deserializeItem();
}
private any function deserializeItem(){
@Rodel30
Rodel30 / quiz.rb
Created Aug 12, 2016
A simple solution to the code quiz, via Ruby
View quiz.rb
%w(a at cat scat catch).detect{|w| w =~ /.+at/ }
View keybase.md

Keybase proof

I hereby claim:

  • I am Rodel30 on github.
  • I am rodel30 (https://keybase.io/rodel30) on keybase.
  • I have a public key whose fingerprint is 8712 8F74 6356 3AC0 52B6 9377 E2F8 A94D 24C4 10E7

To claim this, I am signing this object: