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
macro break_if_enough divisible, divisor, to_return = nil | |
q, r = {{divisible}}.divmod {{divisor}} | |
{% if to_return %} | |
return false if r == 0 | |
return true if q <= {{divisor}} | |
{% else %} | |
break false if r == 0 | |
break true if q <= {{divisor}} | |
{% end %} | |
end |
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
macro break_if_enough divisible, divisor, to_return = nil | |
q, r = {{divisible}}.divmod {{divisor}} | |
{% if to_return %} | |
return false if r == 0 | |
return true if q <= {{divisor}} | |
{% else %} | |
break false if r == 0 | |
break true if q <= {{divisor}} | |
{% end %} | |
end |
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
a=*$<.map{|s|s.scan /[a-z]+/i} | |
a[0]+=x=[i=0] | |
a.map{n=*x | |
a.map{|b|(b&x)[0]&&n+=b} | |
exit p i if(["Erdos"]&x=n)[0] | |
i+=1} | |
puts"Inf" |
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
require"io/console" | |
_=[[_]*4]*4 | |
t=->{_=_.transpose} | |
r=->{_.map! &:reverse} | |
f=->{_=_.map{|_|_=(_*?\s).gsub(/\b(\d+) +\1\b/){|_|_.to_i*2}.split;_[3]||=p;_}} | |
f[] | |
loop{(0while _[i=rand(4)][j=rand(4)];_[i][j]=[*[?2]*9,?4].sample)if$n!=_*?_ | |
system"clear" | |
_.map{|_|puts"%5s"*4%_} | |
(c=STDIN.getch)[?q]|0 |
NewerOlder