Skip to content

Instantly share code, notes, and snippets.

@Grissess
Created May 20, 2017 02:56
Show Gist options
  • Save Grissess/84bf949bd83197d988fcf89dd057d1c5 to your computer and use it in GitHub Desktop.
Save Grissess/84bf949bd83197d988fcf89dd057d1c5 to your computer and use it in GitHub Desktop.
(lambda y, mc: (lambda md, fd, pr, w, wt: [pr(i) for i in y(fd, y(md, w, wt))])( (lambda ju, ml: lambda f, w, wt: () if not w else (y(ju, y(ml, (), w, wt)[0], wt),) + f(f, y(ml, (), w, wt)[1], wt))( (lambda sp: lambda f, w, wt: '' if (not w) or wt == 0 else (w[0] if len(w) == 1 else w[0] + ' ' * sp(w, wt) + f(f, w[1:], wt - len(w[0]) - sp(w, wt))))( (lambda w, wt: int(mc((wt - sum(len(i) for i in w)) / float(len(w) - 1)))),), lambda f, c, r, wt: (c, r) if (not r) or sum(len(i) for i in c) + len(c) + len(r[0]) > wt else f(f, c + (r[0],), r[1:], wt),), (lambda f, l: (l[0],) + f(f, l[1:]) if len(l) > 1 else (' '.join(l[0].split()),)), (lambda *a: __import__('sys').stdout.write(' '.join(a)+'\n')), __import__('sys').stdin.read().split(), 20,))(lambda f, *a: f(f, *a), __import__('math').ceil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment