Created
July 7, 2023 18:44
-
-
Save Reagent992/8ead40fe2b51c8c3cdbc0404eb713cd5 to your computer and use it in GitHub Desktop.
Вариант решения задачи B. Комбинации из Яндекс Контест
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# B. Комбинации | |
# https://contest.yandex.ru/contest/24734/problems/B/ | |
# Ввод: "23" Вывод: "ad ae af bd be bf cd ce cf" | |
# Технически решение верное, но предполагалось решать через рекурсию. | |
from itertools import product | |
buttons = { | |
2: 'abc', | |
3: 'def', | |
4: 'ghi', | |
5: 'jkl', | |
6: 'mno', | |
7: 'pqrs', | |
8: 'tuv', | |
9: 'wxyz' | |
} | |
# Смешно и нечитаемо. | |
[print(''.join(item), end=' ') for item in | |
list(product(*[buttons[i] for i in list(map(int, input()))]))] | |
# Читаемый вариант: | |
# def main(n): | |
# f = list(product(*[combinations[i] for i in n])) | |
# for item in f: | |
# print(''.join(item), end=' ') | |
# | |
# | |
# if __name__ == '__main__': | |
# main(list(map(int, input()))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment