Created
November 28, 2014 09:24
-
-
Save pads/3a820ac7fcaf293dbb96 to your computer and use it in GitHub Desktop.
WMRUG Code Golf Solutions
This file contains hidden or 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
puts gets.to_i.to_s(2) | |
# | |
# Best solution found: | |
# | |
#puts"%b"%gets |
This file contains hidden or 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
#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]}*' ' |
This file contains hidden or 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
puts gets.split(' ').uniq | |
# | |
# Best solution found: | |
# | |
#puts gets.split.uniq |
This file contains hidden or 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
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}"} |
This file contains hidden or 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
#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(' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Game can be found at https://github.com/omarqureshi/codegolf