CodeDrill
day_streak: --
← 問題一覧に戻る
Python ・ Standard I/O

Problem 49: Sorting Words by Length

Words separated by single spaces are given on one line. Sort them in order of shortest length first, and output them on one line separated by single spaces. Words with the same length should keep the order in which they appeared in the input.

Constraints

There are 1 to 20 words, each word consists only of lowercase letters and is 1 to 20 characters long

Input example 1

banana apple fig

Output example 1

fig apple banana

Input example 2

aa bb c

Output example 2

c aa bb

What you'll train

State the constraints

What you get

  • Specify the sort key
  • Require stability
  • Express handling of equal values

How to ask the AI

In addition to sorting by length, tell the AI that this should be a stable sort, meaning words of the same length must keep the order in which they appeared in the input.

If you ask vaguelyWhen there are multiple words of the same length, the input order may not be preserved, breaking the stability of the sort.

あなたのコード

実行しました

プレビュー

AIレビュー(プロンプト練習)

コードはChatGPTやClaudeに出させたものを貼って構いません。
ここでの本番は「次にAIへ出す指示」です。評価軸は1つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。

先にコードを実行し、テストを1つ以上通してください。