Activity for orthoplex
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Comment | Post #285929 |
You can eliminate the plus sign via `a+b` → `a-(-b)`. (more) |
— | almost 2 years ago |
Comment | Post #286668 |
You can eliminate the init-loop by or-ing the lookup with 0.
Using `pairs` also seems a bit overkill since you're not using `k` anywhere.
`function(t)r={}for i=1,#t do r[t[i]]=1+(r[t[i]]or 0)end return r end` (more) |
— | almost 2 years ago |
Comment | Post #286637 |
Actually, `set(x)` → `x` works just fine in this case.
I also found a set-of-pairs solution that is equally as long:
`lambda x:{*zip(x,map(x.count,x))}` (more) |
— | almost 2 years ago |
Comment | Post #286311 |
At first, I thought you were cheesing the test cases, but you're right, -1 is the only negative number you can possibly get. Clever!
The penultimate line should then be
```lua
_=(_==256or _<0)and 0or _
``` (more) |
— | about 2 years ago |
Comment | Post #286311 |
Tables to the rescue ^^
```lua
_=0
for c in s:gmatch'.'do
_=({d=_-1,i=_+1;s=_*_})[c]or print(_)or _
_=({[256]=0,[-1]=0})[_]or _
end
``` (more) |
— | about 2 years ago |
Comment | Post #286301 |
How about we use our own function to shorten the for-loop even more? This should also relieve your discomfort with not calling `f`.
```lua
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
``` (more) |
— | about 2 years ago |
Comment | Post #286301 |
Oh oops, you're right, I completely overlooked `in`. Still, the for-loop could be shortened to something sneaky like
```lua
for x in print do end
``` (more) |
— | about 2 years ago |
Comment | Post #286301 |
You can shorten your for-loop and save a few spaces on the numerical constants. Also, I don't think the rules require you to call your function in the end.
```lua
local function f()if true then for v=0,0 do while false do break end repeat until""and""or not nil end elseif""then else end goto l::l::... (more) |
— | about 2 years ago |
Comment | Post #286300 |
You can shorten your loop by using goto. As a bonus, this makes your code look even more cryptic (:
```lua
_=''::_::_=_..'*'print(_)goto _
``` (more) |
— | about 2 years ago |
Comment | Post #286295 |
oh sweet, we have a 35 then ^^
```haskell
main=mapM putStrLn$iterate('*':)"*"
``` (more) |
— | about 2 years ago |
Comment | Post #286295 |
Neat solution, but that import is quite expensive. Maybe try something like
```haskell
x="*":map('*':)x
main=mapM putStrLn x
``` (more) |
— | about 2 years ago |
Comment | Post #285903 |
`%#_ _` has 4 unique bytes, no? (more) |
— | over 2 years ago |