Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def clockDigitsCount(startTime, finishTime)
- output_array = Array.new
- start_hour = startTime[0]
- start_minute = startTime[1]
- start_second = startTime[2]
- finish_hour = finishTime[0]
- finish_minute = finishTime[1]
- finish_second = finishTime[2]
- x = 0
- zero = 0
- one = 0
- two = 0
- three = 0
- four = 0
- five = 0
- six = 0
- seven = 0
- eight = 0
- nine = 0
- start_time = (startTime[0] * 3600) + (startTime[1] * 60) + startTime[2]
- finish_time = (finishTime[0] * 3600) + (finishTime[1] * 60) + finishTime[2]
- while (start_time <= finish_time)
- string = start_hour.to_s
- string_length = string.length
- if start_hour < 10 then
- zero = zero + 1
- end
- while (x < string_length)
- if string[x] == "0" then
- zero = zero + 1
- end
- if string[x] == "1" then
- one = one + 1
- end
- if string[x] == "2" then
- two = two + 1
- end
- if string[x] == "3" then
- three = three + 1
- end
- if string[x] == "4" then
- four = four + 1
- end
- if string[x] == "5" then
- five = five + 1
- end
- if string[x] == "6" then
- six = six + 1
- end
- if string[x] == "7" then
- seven = seven + 1
- end
- if string[x] == "8" then
- eight = eight + 1
- end
- if string[x] == "9" then
- nine = nine + 1
- end
- x = x + 1
- end
- x = 0
- string = start_minute.to_s
- string_length = string.length
- if start_minute < 10 then
- zero = zero + 1
- end
- while (x < string_length)
- if string[x] == "0" then
- zero = zero + 1
- end
- if string[x] == "1" then
- one = one + 1
- end
- if string[x] == "2" then
- two = two + 1
- end
- if string[x] == "3" then
- three = three + 1
- end
- if string[x] == "4" then
- four = four + 1
- end
- if string[x] == "5" then
- five = five + 1
- end
- if string[x] == "6" then
- six = six + 1
- end
- if string[x] == "7" then
- seven = seven + 1
- end
- if string[x] == "8" then
- eight = eight + 1
- end
- if string[x] == "9" then
- nine = nine + 1
- end
- x = x + 1
- end
- x = 0
- string = start_second.to_s
- string_length = string.length
- if start_second < 10 then
- zero = zero + 1
- end
- while (x < string_length)
- if string[x] == "0" then
- zero = zero + 1
- end
- if string[x] == "1" then
- one = one + 1
- end
- if string[x] == "2" then
- two = two + 1
- end
- if string[x] == "3" then
- three = three + 1
- end
- if string[x] == "4" then
- four = four + 1
- end
- if string[x] == "5" then
- five = five + 1
- end
- if string[x] == "6" then
- six = six + 1
- end
- if string[x] == "7" then
- seven = seven + 1
- end
- if string[x] == "8" then
- eight = eight + 1
- end
- if string[x] == "9" then
- nine = nine + 1
- end
- x = x + 1
- end
- x = 0
- start_second = start_second + 1
- if start_second == 60 then
- start_second = 0
- start_minute = start_minute + 1
- end
- if start_minute == 60 then
- start_minute = 0
- start_hour = start_hour + 1
- end
- if start_hour == 24 then
- start_hour = 0
- start_minute = 0
- start_second = 0
- end
- start_time = start_time + 1
- end
- output_array[0] = zero
- output_array[1] = one
- output_array[2] = two
- output_array[3] = three
- output_array[4] = four
- output_array[5] = five
- output_array[6] = six
- output_array[7] = seven
- output_array[8] = eight
- output_array[9] = nine
- return output_array
- end
Advertisement
Add Comment
Please, Sign In to add comment