Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am pifst on github.
* I am csfields (https://keybase.io/csfields) on keybase.
* I have a public key whose fingerprint is 21FA 2B46 409A 4BB0 5CA7 9505 F3CD C9C7 1B64 9BBC
To claim this, I am signing this object:
@pifst
pifst / blackjack.rb
Created October 21, 2013 01:59
Given a string ex. "7 10 7 3 4 7', find the optimal cards to play in blackjack, return in same form.
def format_input(input)
array = input.split(" ")
royals = {"10"=>0, "J"=>0, "Q"=>0, "K"=>0}
i = 0
begin
royals[royals.keys[i]] = array.count(royals.keys[i]) unless array.count(royals.keys[i]).zero?
array.map!{ |x| x == royals.keys[i] ? "10" : x }
i += 1
end while i <= royals.length
#puts "#{royals}"
@pifst
pifst / web_ranking.rb
Created August 11, 2013 00:05
Convert coding challenge to website.
require 'sinatra'
def get_memory_usage
`ps -o rss= -p #{Process.pid}`.to_i
end
def clean_string(input)
input.strip # removes accidental whitepsace
end
def fact(m) # Create factorial from input
(1..m).inject {|s,i| s *= i}
@pifst
pifst / gist:24307bab238a40e6fef6
Created August 5, 2013 20:06
Output of Ranking.RB
mbr:christopher_fields_coding_challenge Chris$ ruby ranking.rb ABAB
The input 'ABAB' is ranked # 2
---------------------------------------
Time elapsed 5.186 milliseconds, memory used: 116KB
---------------------------------------
mbr:christopher_fields_coding_challenge Chris$ ruby ranking.rb AAAB
The input 'AAAB' is ranked # 1