Problem 2432. Equation Times (of the day)
Many times throughout the day can represent mathematical equations. In this problem, we focus on times that include the four basic operations (+,-,*,/). For example, 6:17 can be written as 6=1+7. Write a function that determines if the given time (restricted to three digits in 12-hour time, 1:00 to 9:59) is an equation time, and if so, which basic operation it uses. There are also four types of equations 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:35, 2+3=5)
- equation written forward, "=" does coincide with ":" -- > add 100 to output (e.g., 2:53, 2=5-3)
- equation written backward, "=" doesn't coincide with ":" --> add 10 to output (e.g., 3:26, 6=2*3)
- equation written backward, "=" does coincide with ":" --> add 1000 to output (e.g., 4:28, 8/2=4)
Note that some of these combinations are tied to each other due to the commutative nature of + and * and the inverse relation of +,- and ,/. The output should be a 4x2 matrix with 0s or 1s in the first column dependent on whether each operation (+,-,*,/) is applicable to a given time and the totals in the second column. Examples include:
4:22 | out = [1 1100; 1 1; 1 1100; 1 1]; since 4=2+2, 2+2=4; 4-2=2; 4=2*2, 2*2=4; 4/2=2.
5:15 | out = [0 0; 0 0; 1 1111; 1 1001]; since 5*1=5, 5=1*5, 5*1=5, 5=1*5; 5/1=5, 5/1=5.
This problem is related to Problem 2431 and Problem 2433.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers71
Suggested Problems
-
932 Solvers
-
237 Solvers
-
213 Solvers
-
1265 Solvers
-
A Simple Tide Gauge with MATLAB
378 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!