Skip to content

Instantly share code, notes, and snippets.

@masui
Last active December 29, 2015 19:19
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 masui/7716812 to your computer and use it in GitHub Desktop.
Save masui/7716812 to your computer and use it in GitHub Desktop.
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