From 5ea278ad409872c6dd5bc798a9a28f68abde2c7a Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Wed, 23 Aug 2017 10:42:33 +0200 Subject: [PATCH] Solve community dance dance --- community_dance_dance.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 community_dance_dance.py diff --git a/community_dance_dance.py b/community_dance_dance.py new file mode 100644 index 0000000..d88641e --- /dev/null +++ b/community_dance_dance.py @@ -0,0 +1,33 @@ +def main(): + l = int(input()) + n = int(input()) + frequencies = {} + for i in range(n): + pattern, tempo = input().split() + tempo = int(tempo) + frequencies[tempo] = pattern + + card = [] + for i in range(1, l + 1): + line = '0000' + for tempo, pattern in frequencies.items(): + if i % tempo == 0: + line = add_lines(line, pattern) + card.append(line) + + for line in card[::-1]: + print(line) + + +def add_lines(current_line, new_line): + line = '' + for cc, cl in zip(current_line, new_line): + if cc == 'X' or cl == 'X': + line += 'X' + else: + line += '0' + + return line + +if __name__ == '__main__': + main()