1
ryd994 2018-03-11 02:49:09 +08:00 via Android 1
"\n".join([
" ".join([ str(i*j) for j in range(1, i+1) ]) for i in range(1,10) ]) |
2
xpresslink 2018-03-11 13:20:52 +08:00 1
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information. >>> from itertools import groupby as gb, combinations_with_replacement as cwr >>> from operator import mul, itemgetter as ig >>> double_nine=lambda right: '\n'.join(map(lambda x: (lambda l: l.ljust(26) if right else l.rjust(26))(' '.join(map(lambda t: str(mul(*t)).rjust(2), ig(1)(x)))), (lambda r: gb(sorted(cwr(range(1,10),2), key=r), r))(ig(right)))) >>> >>> print(double_nine(right=True)) 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 6 12 18 24 30 36 7 14 21 28 35 42 49 8 16 24 32 40 48 56 64 9 18 27 36 45 54 63 72 81 >>> print(double_nine(right=False)) 1 2 3 4 5 6 7 8 9 4 6 8 10 12 14 16 18 9 12 15 18 21 24 27 16 20 24 28 32 36 25 30 35 40 45 36 42 48 54 49 56 63 64 72 81 >>> |