増分ゲーム時間形式
ゴール
増分ゲームには、タスクが完了するまでの日、時間、分、秒を表すカウントダウンタイマーが含まれていることがよくあります。使用可能なスペースに応じて、次のようにフォーマットできます。
2d 13h
23h 59m 48s
14m
3h 0m 0s
このゴルフの目的は、このフォーマットを実行する関数またはプログラムを作成することです。
インプット
- 合計秒数。
- 出力するセグメントの最大数。
出力
- セグメントは次のとおりです。
- 0週間
- 0日
- 0時間
- 0分
- 0秒
- 各セグメントは単一のスペースで区切られます。
- 表示されるセグメントは連続している必要があります。たとえば、ゼロ分があっても、分を表示せずに時間と秒を表示しません。
- 1桁の値には先行ゼロはありませんが、ゼロの値はとして表示する必要があります
0
。 - 値は切り捨てられます。
- 表示される最初のセグメントは、最初のゼロ以外の値です。
テストケース
seconds segments output
0 1 0s
123 1 2m
123 2 2m 3s
123 3 2m 3s
82815 3 23h 0m 15s
307891 2 3d 13h
307891 4 3d 13h 31m 31s
604800 1 1w
604800 6 1w 0d 0h 0m 0s
勝ち
1週間で最も少ないバイト数のソリューションが「受け入れ」になります。
編集
- 例に示すように、どのセグメントが最初であるかを明確にしました。
- 要求ごとにテストケース4を追加しました。
3d
か?「表示される最初のセグメントは、最初の非ゼロ値です」
307891 1
何ですか?0w
または1w
。