Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def char_type(character):
- if ord('0') <= character <= ord('9'):
- return 'number'
- if ord('A') <= character <= ord('Z'):
- return 'uppercase'
- if ord('a') <= character<= ord('z'):
- return 'lowercase'
- if character in {64, 42, 35, 38}:
- return 'special_case'
- def rule_to_char(rule):
- if rule == 'number':
- return '0'
- if rule == 'uppercase':
- return 'A'
- if rule == 'lowercase':
- return 'a'
- if rule == 'special_case':
- return '#'
- rules = {'number', 'uppercase', 'lowercase', 'special_case'}
- def new_password(L, old_password):
- requirement = set()
- for i in old_password:
- requirement.add(char_type(ord(i)))
- requirement_to_fill = rules - requirement
- if requirement_to_fill != '':
- for to_fill in requirement_to_fill:
- old_password += rule_to_char(to_fill)
- if len(old_password)<7:
- old_password += 'a' * (7-len(old_password))
- return old_password
- testcase = int(input())
- for test in range(testcase):
- L = int(input())
- old_password = input()
- answer = new_password(L, old_password)
- print(f'Case # {test +1}: {answer}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement