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
aabbbccOutput example 1
3Input example 2
abcOutput example 2
1What you'll train
Cover the edge cases
What you get
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つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。