Activity for Arpad Horvathâ€
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #290104 |
Post edited: Thanks |
— | about 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) |
— | about 1 year ago |
Edit | Post #290104 |
Post edited: More readable version |
— | about 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) |
— | about 1 year ago |
Edit | Post #290104 |
Post edited: Comment |
— | about 1 year ago |
Edit | Post #290104 |
Post edited: walrus to be able to use lambda |
— | about 1 year ago |
Comment | Post #290104 |
I've changed both. I made lambda functions from both expressions. Is this enough? (more) |
— | about 1 year ago |
Edit | Post #290106 |
Post edited: |
— | about 1 year ago |
Edit | Post #290104 |
Post edited: |
— | about 1 year ago |
Edit | Post #290106 |
Post edited: |
— | about 1 year ago |
Edit | Post #290106 |
Post edited: |
— | about 1 year ago |
Edit | Post #290106 |
Post edited: |
— | about 1 year ago |
Edit | Post #290106 | Initial revision | — | about 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) |
— | about 1 year ago |
Edit | Post #290104 | Initial revision | — | about 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) |
— | about 1 year ago |
- ← Previous
- 1
- 2
- Next →