Activity for Zakkâ
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Answer | — |
A: Can you give me half? Lua 5.4, 3 unique characters ``` lua #'#'/#'##' ``` Try it online! > [...] scoring is done in terms of number of unique characters used in the submission. 1. Hashtag # 2. Single quote ' 3. Slash / (more) |
— | over 2 years ago |
Edit | Post #286329 | Initial revision | — | over 2 years ago |
Answer | — |
A: The Pell Numbers C (gcc), 35 bytes ``` C f(n){return n<2?n:f(n-1)2+f(n-2);} ``` Try it online! (more) |
— | over 2 years ago |
Edit | Post #286328 | Initial revision | — | over 2 years ago |
Answer | — |
A: The Pell Numbers Lua 5.4.4, 51 bytes ``` lua function f(n)return n<2 and n or f(n-1)2+f(n-2)end ``` Try it online! (more) |
— | over 2 years ago |
Edit | Post #286324 | Initial revision | — | over 2 years ago |
Answer | — |
A: Write a Deadfish Interpreter JavaScript (V8), 78 bytes ``` javascript f=s=>s.map(c=>(==256||<0?=0:0)||c=='i'?++:c=='d'?--:c=='s'?=:v+=+' ') ``` Try it online! (more) |
— | over 2 years ago |
Edit | Post #286321 | Initial revision | — | over 2 years ago |
Answer | — |
A: Write a Deadfish Interpreter C (gcc), 98 bytes ``` c =0;f(chars){for(;s;++s)==256||<0?=0:1,s=='i'?++:s=='d'?--:s=='s'?=:printf("%d ",);} ``` Try it online! (more) |
— | over 2 years ago |
Comment | Post #286311 |
Though both of `s:gsub` and `for..in` versions are equal in length, the former can be one byte shorter, because sticking an `s` to `0` doesn't make the Lua interpreter unhappy, contrary to sticking an `f` to `0`.
```
_=0s:gsub('.',function(c)_=({d=_-1,i=_+1;s=_*_})[c]or print(_)or _ _=({[256]=0,[... (more) |
— | over 2 years ago |
Edit | Post #286311 |
Post edited: shortened the code (thanks to orthoplex) |
— | over 2 years ago |
Comment | Post #286311 |
> ```_=(_==256or _<0)and 0or _```
You are right.
> Tables to the rescue ^^
Man! That's just brilliant! Again, thanks for pointing this out.
Btw, I am really curious about how much experience you have with Lua. (more) |
— | over 2 years ago |
Edit | Post #286301 |
Post edited: shortened the code (thanks to orthoplex) |
— | over 2 years ago |
Comment | Post #286301 |
Clever solution! Thanks! (more) |
— | over 2 years ago |
Edit | Post #286311 | Initial revision | — | over 2 years ago |
Answer | — |
A: Write a Deadfish Interpreter Lua 5.4.4, 99 bytes ``` =0s:gsub('.',function(c)=({d=-1,i=+1;s=})[c]or print()or =({[256]=0,[-1]=0})[]or end) ``` Try it online! Thanks to @orthoplex for more shortening. (more) |
— | over 2 years ago |
Edit | Post #286301 |
Post edited: shortened the code (thanks to orthoplex) |
— | over 2 years ago |
Comment | Post #286301 |
> If your function never runs, then clearly it won't have a runtime error :)
@#53196 So calling `f()` is not necessary... If so, I will remove it. (more) |
— | over 2 years ago |
Comment | Post #286301 |
@#56271 You are right! It can be shortened (and it prints `nil nil`). Strange how I missed this one out. Anyways, thanks (once more) for pointing this out! (more) |
— | over 2 years ago |
Edit | Post #286301 |
Post edited: shortened the code (thanks to orthoplex) |
— | over 2 years ago |
Comment | Post #286301 |
> You can shorten your for-loop
No, I can't. Shortening it the way you did results in omitting the `in` keyword. This obviously goes against the rule of including **all** language keywords.
> and save a few spaces on the numerical constants
Yes, that's true. I will edit my answer. Thanks (ag... (more) |
— | over 2 years ago |
Edit | Post #286300 |
Post edited: shortened the code (thanks to orthoplex) |
— | over 2 years ago |
Comment | Post #286300 |
Thanks! I will edit the code. (more) |
— | over 2 years ago |
Edit | Post #286301 | Initial revision | — | over 2 years ago |
Answer | — |
A: Keyword golfing Lua 5.4.4, 147 bytes ``` local function f()goto l::l::return end for in f do end if true and false then elseif""then else end repeat until""or not nil while""do break end ``` Try it online! Check the list of keywords. Thanks to @orthoplex for more shortening. (more) |
— | over 2 years ago |
Edit | Post #286300 |
Post edited: Provided a link to try it online. |
— | over 2 years ago |
Edit | Post #286300 | Initial revision | — | over 2 years ago |
Answer | — |
A: Looping counter Lua, 31 bytes ``` =''::::=..''print()goto ``` Try it online! (more) |
— | over 2 years ago |
- ← Previous
- 1
- 2
- Next →