Activity for Peter Taylorâ€
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Comment | Post #286920 |
I'm used to a culture of code golf which is collaborative. (more) |
— | over 1 year ago |
Comment | Post #286920 |
The `sum(map(int` trick is shorter than I'd managed, but itertools is expensive. As a one-liner, a recursive lambda gets 76: `f=lambda n,i=1,a=[]:a if a[n-1:]else f(n,i+1,a+[i][i%sum(map(int,str(i))):])`. But if you don't insist on a list, the best I've found is an explicit loop for 73: `def f(n,i=0)... (more) |
— | over 1 year ago |
Comment | Post #285231 |
It's always sensible to remove bounds on the input so that hard-coding isn't a strategy and implementations have to actually tackle the problem rather than side-step it. (more) |
— | over 2 years ago |
Comment | Post #283796 |
You can save 9 bytes with base case the 0x0 matrix and 2 bytes with `enumerate`: it's long, but so is `range(len)`. For 95 bytes: `f=lambda m:sum((-1)**i*x*f([r[:i]+r[i+1:]for r in m[1:]])for i,x in enumerate(m[0]))if m else 1` (more) |
— | over 2 years ago |