Activity for CrSb0001
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #293759 |
Post edited: -2 bytes |
— | 6 days ago |
Edit | Post #293751 |
Post edited: -12 bytes |
— | 6 days ago |
Edit | Post #293712 |
Post edited: |
— | 6 days ago |
Edit | Post #293788 |
Post edited: |
— | 8 days ago |
Edit | Post #293788 |
Post edited: |
— | 8 days ago |
Edit | Post #293788 | Initial revision | — | 8 days ago |
Answer | — |
A: Cumulative Counts [Lean 4], 111 bytes ```lean def c(l:List Nat):List Nat:=((λx=>((l.reverse).drop x).count (l.reverse)[x]!)(List.range l.length)).reverse ``` [Try it online!] Given how verbose Lean syntax is, and how you can't really assign variables to keywords in a way that it saves bytes the vast majority ... (more) |
— | 8 days ago |
Edit | Post #293736 |
Post edited: -15 bytes |
— | 9 days ago |
Edit | Post #293785 | Initial revision | — | 9 days ago |
Answer | — |
A: Cumulative Counts Python 3, 50 bytes We can simply omit the lambda name since we don't refer to it anywhere in the lambda definition. ```python lambda l:[l[:i+1].count(j)for i,j in enumerate(l)] ``` Example usage in the terminal: ```python >>>(lambda l:[l[:i+1].count(j)for i,j in enumerate(l)])([1,1,2,2,2... (more) |
— | 9 days ago |
Edit | Post #293736 |
Post edited: -5 bytes |
— | 9 days ago |
Edit | Post #293750 |
Post edited: |
— | 10 days ago |
Comment | Post #293750 |
Sorry, I can change it to “a positive integer >= 0” (more) |
— | 10 days ago |
Comment | Post #293750 |
…isn’t that how integers are typically stored in computer memory? I don’t see what you’re trying to ask (more) |
— | 11 days ago |
Edit | Post #293759 | Initial revision | — | 11 days ago |
Answer | — |
A: Caesar shift cipher [Lean 4], 183 181 bytes ``` def c(t:String)(s:Nat):String:=t.map (λc=>if Char.isAlpha c then let b:=if Char.isLower c then 'a'else 'A';let h:=(Char.toNat c-Char.toNat b+s)%26+Char.toNat b;Char.ofNat h else c) ``` Try it online! Honestly it's surprising that 1) you can just throw everything o... (more) |
— | 11 days ago |
Edit | Post #293751 |
Post edited: -5 bytes |
— | 11 days ago |
Comment | Post #293750 |
@#53890 I'll keep the idea of first posting to the Sandbox in mind. (more) |
— | 12 days ago |
Comment | Post #293750 |
I've updated the ruleset in the question @#53890 @#77222 (more) |
— | 12 days ago |
Edit | Post #293750 |
Post edited: |
— | 12 days ago |
Edit | Post #293736 |
Post edited: Updated bytecount to take into account non-printable characters. |
— | 12 days ago |
Edit | Post #293751 |
Post edited: -3 bytes |
— | 12 days ago |
Comment | Post #293750 |
If it’s a builtin function that takes in a base 10 number and outputs a number in base 16 as a string or whatever, it is banned. So both `toHex` and `.toString(16)` would be banned.
As for xxd, I would say that it does not apply in the context of this challenge, as it is used primarily to create o... (more) |
— | 12 days ago |
Edit | Post #293751 | Initial revision | — | 12 days ago |
Answer | — |
A: Convert to Hexadecimal Lean 4, 103 100 95 83 bytes ```lean def h:=λi=>if iif i| 00000010 3c 31 36 74 68 65 6e 20 73 21 22 7b 22 30 31 32 |<16then s!"{"012| 00000020 33 34 35 36 37 38 39 41 42 43 44 45 46 22 2e 67 |3456789ABCDEF".g| 00000030 65 74 20 e2 9f a8 69 e2 9f a9 7d 22 65 6c 73 65 |et ...i...}"else| 00000... (more) |
— | 12 days ago |
Edit | Post #293750 | Initial revision | — | 12 days ago |
Question | — |
Convert to Hexadecimal Challenge Write a program that takes in a number greater than or equal to 0 and outputs its representation in hexadecimal (base 16). Examples ```none 0 => 0 1 => 1 10 => A 15 => F 16 => 10 107 => 6B 153 => 99 207 => CF 1000 => 3E8 10381 => 288D 48821 =>... (more) |
— | 12 days ago |
Edit | Post #293745 | Initial revision | — | 12 days ago |
Answer | — |
A: "Hello, {name}!" Lean 4, 39 bytes ```lean def x(i:String):String:=s!"Hello, {i}!" ``` Try it online! (Note that TIO only supports Lean 3, so I sadly am unable to use a link from there.) (more) |
— | 12 days ago |
Edit | Post #293736 |
Post edited: -6 bytes |
— | 13 days ago |
Edit | Post #293739 | Initial revision | — | 13 days ago |
Question | — |
Tips for golfing in Lean [Lean] is an interactive theorem prover and a functional programming language created in 2013. What tips do you have for golfing in Lean? Tips should be specific to Lean ("remove comments" is not an answer), and stick to one tip per answer. (more) |
— | 13 days ago |
Edit | Post #293736 | Initial revision | — | 13 days ago |
Answer | — |
A: Give the fool's fibonacci sequence [Lean 4], 115 109 104 89 bytes Note: had to update bytecount to take into account non-printable characters. For anyone who isn't familiar with Lean, it's basically an interactive theorem prover that can also be used for regular math computation. Those who are familiar with Haskell would pro... (more) |
— | 13 days ago |
Edit | Post #293713 |
Post edited: -13 bytes, -69 bytes total. |
— | 13 days ago |
Edit | Post #293713 |
Post edited: -56 bytes |
— | 14 days ago |
Edit | Post #293713 | Initial revision | — | 15 days ago |
Answer | — |
A: Give the fool's fibonacci sequence Python 3, 131 75 62 bytes ```python f=lambda n:n>0and 2+3f(n-1)+4f(n-2)+2sum(map(f,range(n-2))) ``` I know, a one-liner is boring. This is because I apparently didn't need a separate function/lambda to compute the sum of something. So there you have it, a 56 69 (nice) byte save in total. :D (more) |
— | 15 days ago |
Edit | Post #293712 | Initial revision | — | 15 days ago |
Answer | — |
A: Ratio limits of fibonacci-like series Python 3, 26 bytes ```python lambda n:(n+(nn+4).5)/2 ``` We can actually just compute this directly, although I could have taken an alternate path considering the fact that, given $Rn$ as the ratio between any two terms in the $n$-fibonacci sequence defined above (where $n\in\mathbb Z$), then... (more) |
— | 15 days ago |
Edit | Post #293689 | Initial revision | — | 19 days ago |
Answer | — |
A: "Hello, World!" [Emmental], 51 bytes ```none #72.#101.#108::..#111:.#44.#32.#87..#114..#100.#33. ``` [Try it online!] Basically what goes on is `#[num]` pushes the ASCII value of `num` onto the top of the stack, `:` duplicates the top of the stack, and `.` prints the top of the stack. Admittedly this i... (more) |
— | 19 days ago |
Edit | Post #293673 | Initial revision | — | 20 days ago |
Answer | — |
A: Tips for golfing in Python Assignment expressions (Python 3.8+) The assignment expression (aka the walrus operator) `:=` was introduced in Python 3.8 as a result of [PEP 572], which can be used inline to assign a variable as part of an expression, like so: ```python >>> (n:=2, n+5) (2, 7) ``` This can be used in a comp... (more) |
— | 20 days ago |
Edit | Post #293669 | Initial revision | — | 21 days ago |
Answer | — |
A: Print the modular multiplicative inverse / virtual fractions [Python 3.8], 44 bytes Uses a modulus of `216 == 48 == 65536`. ```python for i in range(1,98,2):print(pow(i,-1,48)) ``` How it works: ``` for i in # Iterator range(1,98,2): # Odd numbers below 98 ... (more) |
— | 21 days ago |
Edit | Post #293649 |
Post edited: 2 byte save on my current smallest submission, 21 bytes saved from the one that takes input from STDIN. |
— | 21 days ago |
Edit | Post #293649 | Initial revision | — | 22 days ago |
Answer | — |
A: Is it part of the mandelbrot set? Python 3.8, 57 bytes -2 bytes (`2025-04-02`) ```python def m(c): for in range(16):(z:=c)z+c return abs(z)85 84 64 byte program: ``` b=complex(input()) for in range(16):(z:=b)z+b print(abs(z)<2) ``` Should be pretty self explanatory as it's basically the exact same thing as the fu... (more) |
— | 22 days ago |
Edit | Post #293098 |
Post edited: |
— | 4 months ago |