Skip to content

Instantly share code, notes, and snippets.

@masui

masui/時計の針

Last active Dec 29, 2015
Embed
What would you like to do?
def int(x)
x.to_i
end
def frac(x)
x.to_f - int(x)
end
def ts(x)
"#{x.to_i}時#{frac(x)*60.0}分"
end
(0..12).each { |i|
(0..12).each { |j|
x = (144.0 * i + 12.0 * j) / 143.0
y = frac(x) * 12.0
if i <= x && x < i+1 && j <= y && y < j+1 then
puts "#{ts(x)} と #{ts(y)} の針位置は一致"
end
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.