Skip to content

Instantly share code, notes, and snippets.

@kupp1
Last active July 31, 2018 09:17
Show Gist options
  • Save kupp1/cb6371ea64b9a6bc07595d2203a13691 to your computer and use it in GitHub Desktop.
Save kupp1/cb6371ea64b9a6bc07595d2203a13691 to your computer and use it in GitHub Desktop.
Addition table
(lambda x, max_len: [[print('%{}d'.format(max_len) % (i + j) if i + j != 0 else ' ' * max_len, end=' ' if j < x else '\n') for j in range(0, x + 1)] for i in range(0, x + 1)])(9, 2)
# Output:
# 1 2 3 4 5 6 7 8 9
# 1 2 3 4 5 6 7 8 9 10
# 2 3 4 5 6 7 8 9 10 11
# 3 4 5 6 7 8 9 10 11 12
# 4 5 6 7 8 9 10 11 12 13
# 5 6 7 8 9 10 11 12 13 14
# 6 7 8 9 10 11 12 13 14 15
# 7 8 9 10 11 12 13 14 15 16
# 8 9 10 11 12 13 14 15 16 17
# 9 10 11 12 13 14 15 16 17 18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment