Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_pins(observed):
- nums = []
- keypad = [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9'], ['', '0', '']]
- for elem in observed:
- for number_list in keypad:
- if elem in number_list:
- keys = ''
- keys += (''.join([number_list[i] for i in range(len(number_list))
- if i in range(number_list.index(elem)- 1, number_list.index(elem) + 2)]))
- keys +=(''.join([number_list_[number_list.index(elem)] for number_list_ in keypad
- if keypad.index(number_list_) in range(keypad.index(number_list) - 1, keypad.index(number_list) + 2) ]))
- nums.append(keys)
- for i in range (len(nums)):
- for elem in nums[i]:
- if nums[i].count(elem) >= 2:
- nums[i] = nums[i].replace(elem, '', nums.count(elem) - (nums.count(elem)- 1))
- result = []
- if len(nums) == 1:
- return [x for x in nums[0]]
- else:
- for num in nums[0]:
- result_ = []
- result_.append(num)
- for i in range(1, len(nums)):
- result_ = ([num + x for num in result_ for x in nums[i]])
- result.extend(result_)
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement