Skip to content

alfi.py #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions math/111-999-two-digits-no-zero/alfi.py
Original file line number Diff line number Diff line change
@@ -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)