Skip to content

Commit bceda48

Browse files
committed
Determine the angle between hour and minute hand.
1 parent 690b596 commit bceda48

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Given a clock time in hh:mm format, determine, to the nearest degree,
2+
# the angle between the hour and the minute hands.
3+
4+
p 'Enter time:'
5+
time = ARGV[0] #STDIN.gets.chomp
6+
if(time)
7+
h, m = time.split(':').collect(&:to_i)
8+
mins_deg = m * 6
9+
p mins_deg
10+
hour_deg = h * 30 + 30 * (m/60.0)
11+
p hour_deg
12+
angle = mins_deg - hour_deg
13+
p angle.abs
14+
end

0 commit comments

Comments
 (0)