You are given a moment. You must decode the time and space of each moment to determine if it is in the past, present, or future.
Moments are given as a string of 8 characters (e.g. "11:01 pm").
Time is the sum of characters that increase time (i.e. numbers in range ['1'..'9']).
Space is the number of characters which do not increase time (i.e. all characters excluding those that increase time).
Your method should return an array of three elements representing [past, present, and future]. Two elements will be false, and one will be true. The true value should be at whichever index corresponds to the proper moment in time.
Past, present, or future is determined as follows:
- If time is greater than space, then the moment is from the future.
- If time is less than space, then the moment is from the past.
- Otherwise, it is the present moment.
moment = "01:00 pm"
Time equals 1
0 | 1 | : | 0 | 0 | p | m | |
---|---|---|---|---|---|---|---|
+ |
Space equals 7
0 | 1 | : | 0 | 0 | p | m | |
---|---|---|---|---|---|---|---|
+ | + | + | + | + | + | + |
Time < Space, so the moment is from the past. The output should be [true, false, false].