Skip to content

Instantly share code, notes, and snippets.

@pads
Created November 28, 2014 09:24
Show Gist options
  • Save pads/3a820ac7fcaf293dbb96 to your computer and use it in GitHub Desktop.
Save pads/3a820ac7fcaf293dbb96 to your computer and use it in GitHub Desktop.
WMRUG Code Golf Solutions
puts gets.to_i.to_s(2)
#
# Best solution found:
#
#puts"%b"%gets
#TODO: not working!
def fib(n)
return n if n == 1
fib(n-1) + fib(n-2)
end
r = gets.split(" ").map do |n|
fib(n.to_i)
end
puts r
#
# Best solution found:
#
#f=->x{x<2?x:f[x-1]+f[x-2]};puts (1..gets.to_i).map{|x|f[x]}*' '
puts gets.split(' ').uniq
#
# Best solution found:
#
#puts gets.split.uniq
c = Hash.new 0
gets.split.each{|n|c[n]+=1}
c.each{|k,v|puts"#{k} #{v}"}
#
# Best solution found:
#
#a=gets.split;a.uniq.map{|b|puts"#{b} #{a.count b}"}
#TODO: not working!
a = gets.split("\n")
puts a
s = a[0]
n = a[1]
r = a[2..2+n].map{|w| !(s.include? w)}
puts r.join(' ')
@pads
Copy link
Author

pads commented Nov 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment