From 2abf92183468946c18b2c40baa16c239a1c38c41 Mon Sep 17 00:00:00 2001 From: "A .Rahimzadeh" <78742866+Abolfazl-rahimzadeh@users.noreply.github.com> Date: Tue, 18 Mar 2025 17:57:24 +0330 Subject: [PATCH] alfi.py --- math/111-999-two-digits-no-zero/alfi.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 math/111-999-two-digits-no-zero/alfi.py diff --git a/math/111-999-two-digits-no-zero/alfi.py b/math/111-999-two-digits-no-zero/alfi.py new file mode 100644 index 0000000..a55fa7f --- /dev/null +++ b/math/111-999-two-digits-no-zero/alfi.py @@ -0,0 +1,21 @@ +number = 111 +mynumbers = [] + +while number <= 999: + Snumber = str(number) # Convert the number to a string + tmp = [] + + # Loop through each digit in the number + for digit in Snumber: + tmp.append(int(digit)) # Append each digit (as an integer) to tmp + + # Check for exactly two identical digits and no zeros + if tmp.count(tmp[0]) == 2 or tmp.count(tmp[1]) == 2 or tmp.count(tmp[2]) == 2: + if 0 not in tmp: # Ensure no zeros are present + mynumbers.append(number) # Append the number to mynumbers + + number += 1 # Increment the number + +# Print the result +print("Numbers between 111 and 999 with exactly two identical digits and no zeros:") +print(mynumbers)