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

Problem 22: Difference Between Two Numbers

Two integers A and B, separated by a half-width space, are given on one line from standard input. Print the difference between A and B. However, make sure the answer is always 0 or greater.

For example, if A is 3 and B is 8, the answer is 5.

Constraints

1 ≤ A, B ≤ 1000

Input example 1

3 8

Output example 1

5

Input example 2

10 4

Output example 2

6

What you'll train

State the constraints

What you get

  • Write the condition for absolute value
  • Specify how to handle the sign
  • Confirm the output format

How to ask the AI

Clearly tell the AI the condition that "even if A-B becomes negative, the answer must always be 0 or greater." Rather than leaving it up to the AI whether to use abs or a comparison, spelling out the condition clearly leads to code that matches your intent.

If you ask vaguelyIf you only ask it to "print the difference," the AI may simply compute A-B and print the negative value as-is.

あなたのコード

実行しました

プレビュー

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

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

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