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
### 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: |
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
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}" |
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
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} |
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
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 |