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

Problem 29: How Many Distinct Values

An integer N is given on the first line, and N integers separated by half-width spaces are given on the second line. Print, on one line, how many distinct kinds of numbers there are among them. No matter how many times the same number appears, count it as one kind.

For example, for 1 2 2 3 3, there are 3 distinct kinds (1, 2, 3), so print 3.

Constraints

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

Input example 1

5
1 2 2 3 3

Output example 1

3

Input example 2

4
1 1 1 1

Output example 2

1

What you'll train

Cover the edge cases

What you get

  • Write how to handle duplicate elements
  • Write the case where all elements are identical
  • Convey the idea of a set

How to ask the AI

Tell the AI the condition that no matter how many times the same number appears, it should be counted as one kind. Showing the result for cases where all numbers are identical or all are different, with concrete examples, conveys your intent accurately.

If you ask vaguelyIf you only say "count the number of kinds," the AI may count the total number of elements without removing duplicates.

あなたのコード

実行しました

プレビュー

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

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

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