Skip to content

Instantly share code, notes, and snippets.

@cubiic
Created October 3, 2011 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cubiic/1258199 to your computer and use it in GitHub Desktop.
Save cubiic/1258199 to your computer and use it in GitHub Desktop.
Applicake Quezz
class Decode
def initialize(code)
@@code = code.split(",")
end
def start
result = []
pos = 0
@@code.each{ |x|
is_numeric?(x) ? ((pos+=x.to_i) && next) : ((result[pos-1]=x) && (pos=0))
}
result.to_s
end
private
def is_numeric?(s)
!!Float(s) rescue false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment