Activity for Peter Taylorâ€
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Comment | Post #291538 |
Actually some of those optimisations might not work because the brackets appear to be doing weird things. (more) |
— | 4 months ago |
Comment | Post #291538 |
Consider test case `"XCCD"`. The correct output is `XCC` but this regex matches `XCCD`. Fixing the bug actually helps to golf the regex. (FWIW there is further golfing which is possible by combining cases. I'm not sure what the optimum is, but `(.)\1{3}` knocks out `IIII|MMMM|XXXX|CCCC`, and the vari... (more) |
— | 4 months ago |
Comment | Post #286920 |
I'm used to a culture of code golf which is collaborative. (more) |
— | about 2 years 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) |
— | about 2 years 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) |
— | almost 3 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) |
— | almost 3 years ago |
Edit | Post #284209 |
Post edited: Improve MathJax formatting |
— | about 3 years ago |
Edit | Post #284209 | Initial revision | — | about 3 years ago |
Answer | — |
A: Compute the determinant CJam, 45 bytes {:A,{1$,,.=:+\)/:CAffA@zf{\f.::+}..-}/;C} This implementation is an anonymous block (function). Online test suite%2F%3ACAffA%40zf%7B%5Cf.%3A%3A%2B%7D..-%7D%2F%3BC%7D%0A%0A%3AD%3B%0A%5B%5B1%200%5D%5B0%201%5D%5D%20Dp%0A%5B%5B1.5%202%5D%5B-3%204.5%5D%5D%20Dp%0A%5B%5B3%207%5D... (more) |
— | about 3 years ago |