Solve community dance dance
This commit is contained in:
parent
b8099bd8e3
commit
5ea278ad40
1 changed files with 33 additions and 0 deletions
33
community_dance_dance.py
Normal file
33
community_dance_dance.py
Normal file
|
@ -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()
|
Loading…
Reference in a new issue