次のいずれかの形式の文字列として入力時間を指定すると、課題は単純化されます。
hh
、hh:mm
またはhh:mm:ss
で0 ≤ hh ≤ 23
、0 ≤ mm ≤ 59
そして0 ≤ ss ≤ 59
。
次の記号を使用して、現在の時刻を出力します。
AA LABEL FOR CHARACTER CODE POINT HEXADECIMAL
== ==================== ========== ===========
🕐 Clock Face 01 Oclock 128336 0x1F550
🕑 Clock Face 02 Oclock 128337 0x1F551
🕒 Clock Face 03 Oclock 128338 0x1F552
🕓 Clock Face 04 Oclock 128339 0x1F553
🕔 Clock Face 05 Oclock 128340 0x1F554
🕕 Clock Face 06 Oclock 128341 0x1F555
🕖 Clock Face 07 Oclock 128342 0x1F556
🕗 Clock Face 08 Oclock 128343 0x1F557
🕘 Clock Face 09 Oclock 128344 0x1F558
🕙 Clock Face 10 Oclock 128345 0x1F559
🕚 Clock Face 11 Oclock 128346 0x1F55A
🕛 Clock Face 12 Oclock 128347 0x1F55B
次の形式で:
It is currently {Clock Face 1} with {mm} minutes and {ss} seconds until {Clock Face 2}.
例(すべてのフリンジケースを含む):
時間だけのケース...
f("12") = "It is currently 🕛."
時間と分があるケース...
f("12:30") = "It is currently 🕛 with 30 minutes until 🕐."
時間のみのケースですが、分は00として含まれています...
f("12:00") = "It is currently 🕛."
時間、分、秒のケース...
f("12:30:30") = "It is currently 🕛 with 29 minutes and 30 seconds until 🕐."
時間と分があるが、秒が00として含まれているケース...
f("12:30:00") = "It is currently 🕛 with 30 minutes until 🕐."
次の1時間まで1分未満で、時間と分があるケース...
f("12:59:59") = "It is currently 🕛 with 1 seconds until 🕐."
複数から単数に変更する必要はありません。
次の1時間までの時間と分があるケース...
f("12:59") = "It is currently 🕛 with 1 minutes until 🕐."
複数から単数に変更する必要はありません。
ミリタリータイムを使用する場合(はい、これを処理する必要があります)
f("23:30:30") = "It is currently 🕚 with 29 minutes and 30 seconds until 🕛."
無効なケース...
f("PPCG") = This cannot occur, you are guaranteed a valid format by the definition of the problem.
f(66:66:66) = This cannot occur, you are guaranteed valid numbers by the definition of the problem.
f(24:60:60) = This cannot occur, you are guaranteed valid numbers by the definition of the problem.
無効なケースについては、出力のスタイルに準拠する必要はありません。エラーは問題ありません。
全体として、この挑戦はかなり単純化されていますが、私の意見では楽しくなるほど十分に動的であるように思われました。コードの長さ以外の変数の側面はあまりないので、ここで最も短いコードが勝者です。
0 < hh < 24
、0 < mm < 60
そして0 < ss < 60
、あなたが意味し0 ≤ hh ≤ 23
、0 ≤ mm ≤ 59
そして0 ≤ ss ≤ 59
。
AM
必要がありPM
ますか?