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

Problem 62: Run-Length Encoding

A string S consisting only of lowercase English letters is given on one line. Replace each run of the same consecutive character with "character + number of consecutive occurrences" and output the result.

For example, aaabcc becomes a3b1c2.

Constraints

1 ≤ length of S ≤ 1000

Input example 1

aaabcc

Output example 1

a3b1c2

Input example 2

z

Output example 2

z1

What you'll train

Specify the output

What you get

  • Specify the output format precisely
  • Illustrate with a concrete example
  • Specify how digit counts are handled

How to ask the AI

Clearly tell the AI that the output format concatenates each character and its count directly, as in "aaabcc" → "a3b1c2". It also helps to clarify how digits should be written when the count reaches 10 or more.

If you ask vaguelyThe AI tends to insert delimiters or spaces around the counts, or mishandle the digit representation when the run length is two digits.

あなたのコード

実行しました

プレビュー

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

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

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