Skip to content

Instantly share code, notes, and snippets.

@Reagent992
Created July 7, 2023 18:44
Show Gist options
  • Save Reagent992/8ead40fe2b51c8c3cdbc0404eb713cd5 to your computer and use it in GitHub Desktop.
Save Reagent992/8ead40fe2b51c8c3cdbc0404eb713cd5 to your computer and use it in GitHub Desktop.
Вариант решения задачи B. Комбинации из Яндекс Контест
# 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