Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 2 characters in body
Source Link
Jonah
  • 34.1k
  • 4
  • 41
  • 95

J, 59 58 bytes

(e.*1+i.~)&([:/:~@,"%.10 10&#:)(+1+[:i.1440-])&.(24 60&#.)

Try it online!

  • (+1+[:i.1440-])&.(24 60&#.) Calculates every absolute minute of the day (0 to 1439 scale), starting at the current hour and up, and then converts back to hh:mm form.
  • ...&([:/:~@,"%.10 10&#:) Converting both the input and the candidate list from the previous step into sortsorted lists of digits...
  • (e.*1+i.~) Is the input an element of the candidate list (returns 0 or 1) times one plus its index within the candidate list. This returns 0 for no match, and the number of minutes we have to wait otherwise.

J, 59 58 bytes

(e.*1+i.~)&([:/:~@,"%.10 10&#:)(+1+[:i.1440-])&.(24 60&#.)

Try it online!

  • (+1+[:i.1440-])&.(24 60&#.) Calculates every absolute minute of the day (0 to 1439 scale), starting at the current hour and up, and then converts back to hh:mm form.
  • ...&([:/:~@,"%.10 10&#:) Converting both the input and the candidate list from the previous step into sort lists of digits...
  • (e.*1+i.~) Is the input an element of the candidate list (returns 0 or 1) times one plus its index within the candidate list. This returns 0 for no match, and the number of minutes we have to wait otherwise.

J, 59 58 bytes

(e.*1+i.~)&([:/:~@,"%.10 10&#:)(+1+[:i.1440-])&.(24 60&#.)

Try it online!

  • (+1+[:i.1440-])&.(24 60&#.) Calculates every absolute minute of the day (0 to 1439 scale), starting at the current hour and up, and then converts back to hh:mm form.
  • ...&([:/:~@,"%.10 10&#:) Converting both the input and the candidate list from the previous step into sorted lists of digits...
  • (e.*1+i.~) Is the input an element of the candidate list (returns 0 or 1) times one plus its index within the candidate list. This returns 0 for no match, and the number of minutes we have to wait otherwise.
added 533 characters in body
Source Link
Jonah
  • 34.1k
  • 4
  • 41
  • 95

J, 5959 58 bytes

(e.*1+i.~)&:([:/:~@,"%.10 10&#:)(+1+[:i.1440-])&.(24 60&#.)

Try it online! Try it online!

  • (+1+[:i.1440-])&.(24 60&#.) Calculates every absolute minute of the day (0 to 1439 scale), starting at the current hour and up, and then converts back to hh:mm form.
  • ...&([:/:~@,"%.10 10&#:) Converting both the input and the candidate list from the previous step into sort lists of digits...
  • (e.*1+i.~) Is the input an element of the candidate list (returns 0 or 1) times one plus its index within the candidate list. This returns 0 for no match, and the number of minutes we have to wait otherwise.

J, 59 bytes

(e.*1+i.~)&:([:/:~@,"%.10 10&#:)(+1+[:i.1440-])&.(24 60&#.)

Try it online!

J, 59 58 bytes

(e.*1+i.~)&([:/:~@,"%.10 10&#:)(+1+[:i.1440-])&.(24 60&#.)

Try it online!

  • (+1+[:i.1440-])&.(24 60&#.) Calculates every absolute minute of the day (0 to 1439 scale), starting at the current hour and up, and then converts back to hh:mm form.
  • ...&([:/:~@,"%.10 10&#:) Converting both the input and the candidate list from the previous step into sort lists of digits...
  • (e.*1+i.~) Is the input an element of the candidate list (returns 0 or 1) times one plus its index within the candidate list. This returns 0 for no match, and the number of minutes we have to wait otherwise.
Source Link
Jonah
  • 34.1k
  • 4
  • 41
  • 95

J, 59 bytes

(e.*1+i.~)&:([:/:~@,"%.10 10&#:)(+1+[:i.1440-])&.(24 60&#.)

Try it online!

AltStyle によって変換されたページ (->オリジナル) /