Skip to content

Instantly share code, notes, and snippets.

@brennacodes
Last active April 21, 2022 17:51
Show Gist options
  • Save brennacodes/6220beca398d5569572b7c00ec6a962c to your computer and use it in GitHub Desktop.
Save brennacodes/6220beca398d5569572b7c00ec6a962c to your computer and use it in GitHub Desktop.
Recommended instruction updates for kata "Simple Fun #193: Moment Of Time In Space"

Task

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.

Example

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].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment