Problem 2431. Power Times (of the day)
Many times throughout the day can represent mathematical equations. In this problem, we focus on times that represent powers. For example, 8:23 can be written as 8=2^3. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is a power time. There are four types that are categorized here, and a given time can fit more than one category:
- equation written forward, "=" doesn't coincide with ":" --> add 1 to output (e.g., 2:38)
- equation written forward, "=" does coincide with ":" -- > add 100 to output (e.g., 8:23)
- equation written backward, "=" doesn't coincide with ":" --> add 10 to output (e.g., 3:28)
- equation written backward, "=" does coincide with ":" --> add 1000 to output (e.g., 9:23)
Examples of combination times include 4:22 (1100 since 4=2^2 and 2^2=4) and 1:31 (1001 since 1^3=1 and 1^3=1).
This problem is related to Problem 2432 and Problem 2433.
Solution Stats
Problem Comments
-
7 Comments
The explanation and/or test cases are lacking...
Can anybody explain the terms forward and backward ?
As best as I can tell, they refer to how you should read the equation (equivalently, the time): forward (left-to-right, i.e. as usual) or backward (right-to-left). For example, 3:28, when read forward, would give "3^2=8" or "3=2^8", neither of which is true, but read backward you get "8=2^3" (true) and "8^2=3" (not true).
Christian, thanks for your reply.
This problem should now be a piece of cake !
Carl, you're welcome!
Note : the backward of time '3:28' is '82:3', not '8:23' !
So the backward of a time is not a time between 1:00 and 9:59 !
carl, reading a time backwards (right to left) does not need to result in a valid time. For such cases, you discard the colon to assess the numbers as an equation as Christian explained.
Solution Comments
Show commentsProblem Recent Solvers88
Suggested Problems
-
Find the peak 3n+1 sequence value
2493 Solvers
-
Lychrel Number Test (Inspired by Project Euler Problem 55)
97 Solvers
-
BULLSEYE Part 2: Reference Problem 18 BULLSEYE
122 Solvers
-
306 Solvers
-
9019 Solvers
More from this Author139
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!