This is python code (Python 3). You can run it on https://sagecell.sagemath.org/ if you don't have python installed on your computer. Just make sure you choose python from the drop down list of languages.
import itertools
def switch_list(dig): #single digit as string
a = ["0","1","5","8","9"]
b = ["2","3","4","6","7"]
if dig in a:
return b
elif dig in b:
return a
else:
return "error"
def generate_new_numbers(str): #3- or 4-digit string
list_of_lists = []
for i in range(len(str)):
list_of_lists.append(switch_list(str[i]))
if "error" not in list_of_lists:
new_list1 = list(itertools.product(*list_of_lists))
new_list2 = []
for t in new_list1:
t = "".join(t)
new_list2.append(t)
print(new_list2)
else:
print("error")
generate_new_numbers("123")
Outputs this for "123":
['200', '201', '205', '208', '209', '210', '211', '215', '218', '219', '250', '251', '255', '258', '259', '280', '281', '285', '288', '289', '290', '291', '295', '298', '299', '300', '301', '305', '308', '309', '310', '311', '315', '318', '319', '350', '351', '355', '358', '359', '380', '381', '385', '388', '389', '390', '391', '395', '398', '399', '400', '401', '405', '408', '409', '410', '411', '415', '418', '419', '450', '451', '455', '458', '459', '480', '481', '485', '488', '489', '490', '491', '495', '498', '499', '600', '601', '605', '608', '609', '610', '611', '615', '618', '619', '650', '651', '655', '658', '659', '680', '681', '685', '688', '689', '690', '691', '695', '698', '699', '700', '701', '705', '708', '709', '710', '711', '715', '718', '719', '750', '751', '755', '758', '759', '780', '781', '785', '788', '789',
'790', '791', '795', '798', '799']
If you input a 4-digit number like "7445" it will output a list of 625 new numbers.