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

Problem 38: Longest Run of the Same Character

A string S is given on a single line from standard input. Output, on one line, the length of the longest run of the same character in a row within S.

For example, in aabbbcc, bbb is the longest with 3 characters, so output 3. If no character repeats consecutively at all, the answer is 1.

Constraints

1 ≤ length of S ≤ 100 (S consists only of lowercase English letters)

Input example 1

aabbbcc

Output example 1

3

Input example 2

abc

Output example 2

1

What you'll train

Cover the edge cases

What you get

  • Indicate the condition for detecting a run
  • Check boundary values
  • Specify the output format

How to ask the AI

Tell the AI that if no character repeats consecutively, the answer should be 1. It's also reassuring to specifically explain the expected behavior when the string has only one character, or when all characters are the same.

If you ask vaguelyThe AI may not account for the case where the string length is 1, resulting in code that errors out or returns 0.

あなたのコード

実行しました

プレビュー

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

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

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