Activity for Arpad Horvath
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #290206 | Initial revision | — | over 1 year ago |
Answer | — |
A: Is it part of the mandelbrot set? Haskell, 66 bytes -7 bytes thanks to Razetime ``` import Data.Complex (\c->(zz+c)c)!!16) ``` I use the fact, that if the result is bigger than 2, it will be forever then, so I don't need to check this relation in each iterations. It is enough to check it in the end. `iterate(\z->zz+c... (more) |
— | over 1 year ago |
Comment | Post #290106 |
Why should you be sorry? Somebody reads my code in a language not known for him, trying to understand it. And even you found out how to test it. (more) |
— | over 1 year ago |
Comment | Post #290200 |
We don't count import in the result, do we? (more) |
— | over 1 year ago |
Edit | Post #290200 |
Post edited: |
— | over 1 year ago |
Edit | Post #290200 |
Post edited: standard format |
— | over 1 year ago |
Edit | Post #290200 | Initial revision | — | over 1 year ago |
Answer | — |
A: How many umbrellas to cover the beach? Python 3.8+, 219 bytes Short version: ```python from itertools import combinations as c def m(w): for k in range(n:=len(w)): for y in c(range(n),k+1): s=[0]n for x in y: for r in range(w[x]): s[max(0,x-r)]=s[min(n-1,x+r)]=1 if all(s):return k+1 ``` Longer versi... (more) |
— | over 1 year ago |
Edit | Post #290104 |
Post edited: Thanks |
— | over 1 year ago |
Comment | Post #290104 |
The problem is fixed, and thanks to the walrus operator I can still use the lambda function. And it is even shorter than the wrong version. (more) |
— | over 1 year ago |
Edit | Post #290104 |
Post edited: More readable version |
— | over 1 year ago |
Comment | Post #290106 |
I can do
f=(\n->(scanl(*)1$cycle[5,2])!!(length$takeWhile(/=n)"IVXLCDM"))
but without the parenthesis it failes. You use the parenthesis after the map, and Haskell don't need a parenthesis after the function name just to call the function. It is needed to show what exactly is the first argumen... (more) |
— | over 1 year ago |
Edit | Post #290104 |
Post edited: Comment |
— | over 1 year ago |
Edit | Post #290104 |
Post edited: walrus to be able to use lambda |
— | over 1 year ago |
Comment | Post #290104 |
I've changed both. I made lambda functions from both expressions. Is this enough? (more) |
— | over 1 year ago |
Edit | Post #290106 |
Post edited: |
— | over 1 year ago |
Edit | Post #290104 |
Post edited: |
— | over 1 year ago |
Edit | Post #290106 |
Post edited: |
— | over 1 year ago |
Edit | Post #290106 |
Post edited: |
— | over 1 year ago |
Edit | Post #290106 |
Post edited: |
— | over 1 year ago |
Edit | Post #290106 | Initial revision | — | over 1 year ago |
Answer | — |
A: Single digit Roman numeral Haskell, 62 bytes ``` (\n->(scanl()1$cycle[5,2])!!(length$takeWhile(/=n)"IVXLCDM")) ``` No import needed. It just uses standard Prelude functions. ``` scanl()1$cycle[5,2] ``` will give you the infinite list of [1,5,10,50...]. With ``` length$takeWhile(/=n)"IVXLCDM" ``` you ... (more) |
— | over 1 year ago |
Edit | Post #290104 | Initial revision | — | over 1 year ago |
Answer | — |
A: Single digit Roman numeral Python 3.8+, 51 byte ```python lambda n:((i:="IVXLCDM".index(n))%24+1)10(i//2) ``` Testing the code: ```python f=lambda n:((i:="IVXLCDM".index(n))%24+1)10(i//2) for s in "IVXLCDM": print(s, f(s)) ``` The walrus operator stores the index in the variable `i`, that is used in the... (more) |
— | over 1 year ago |
- ← Previous
- 1
- 2
- Next →