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

Problem 36: How Many of a Given Number

On the first line, integers N and X are given separated by a single space. On the second line, N integers are given separated by single spaces. Output, on one line, how many times X appears among them. If it doesn't appear at all, output 0.

Constraints

1 ≤ N ≤ 100, 0 ≤ X ≤ 1000, 0 ≤ each element ≤ 1000

Input example 1

5 2
1 2 2 3 2

Output example 1

3

Input example 2

3 9
1 2 3

Output example 2

0

What you'll train

Cover the edge cases

What you get

  • Indicate the case where there is no match
  • Show the input structure
  • Specify the output format

How to ask the AI

Tell the AI that if the specified number X doesn't appear anywhere in the sequence, it should output 0. It's also reassuring to clearly convey the input format, where N and X are given on the first line separated by a space.

If you ask vaguelyThe AI may not account for the case where X is not found at all, resulting in code that produces an empty result or an error.

あなたのコード

実行しました

プレビュー

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

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

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