New answers tagged code-golf
1
vote
Decipher a squashed sequence
Pyth, 13 bytes
ef!-.+T1sMM./
Try it online!
Accepts a string as input.
...
1
vote
Decipher a squashed sequence
JavaScript (ES6), 83 bytes
S=>[...S].some(c=>(k=s+=c,g=q=>q==S||S.match(q)&&g(q+k,o.push(k++)))(o=[]),s='')&&o
Try it online!
1
vote
Decipher a squashed sequence
Python 3, 127 bytes
lambda s:g(s)[0]
g=lambda s:s and[[int(s[:i])]+j for i in range(1,1+len(s))for j in g(s[i:])if j==[]or~-j[0]==int(s[:i])]or[[]]
Try it online!
1
vote
1
vote
Print all integers
Regenerate, 22 bytes
0|($2[0-9]!-?[1-9]())+
Attempt This Online!
Thanks to thejonymyster for the idea to use this language to answer this question.
In pretty-...
2
votes
Decipher a squashed sequence
R, 66 bytes
\(n)repeat for(i in 1:(T=T+1))if(n==Reduce(paste0,i:T))return(i:T)
Attempt This Online!
2
votes
Decipher a squashed sequence
Julia, 71 bytes
! =length
*(s,a=1,b=a,j=join(a:b))=!j<!s ? s*a*-~b : j!=s ? s*-~a : a:b
Attempt This Online!
Takes a string as input and returns a range (...
1
vote
Decipher a squashed sequence
J, 37 bytes
0{<((=<@;\"1)#&,<\"1@])".\<@":@+/i.@#
Try it online!
Not much in the way of golfiness (and it could surely be ...
2
votes
Decipher a squashed sequence
Python3, 142 bytes:
f=lambda x,l=[]:l if''==x else max(w,key=len)if(w:=[f(x[k+1:],l+[int(x[:k+1])])for k,_ in enumerate(x)if l==[]or int(x[:k+1])==l[-1]+1])else w
...
6
votes
Decipher a squashed sequence
Brachylog, 8 bytes
~c.~⟦₂≠∧
Try it online!
Takes an integer as input, which makes it atrociously slow, as concatenation on integers computes constraints on the ...
3
votes
Decipher a squashed sequence
Vyxal, 10 8 bytes
øṖ⌊'ḣtṡ⁼
Try it Online!
Incredibly slow for some inputs, reasonable for others.
Explained
...
0
votes
4
votes
Nest some addition
Flurry, 28 bytes
({}){{}{}}[{}{<><<>(){}>}]{}
A language based on untyped lambda calculus is certainly the right tool here :)
Takes input in the ...
1
vote
Help me design an unfair laundry machine
Jelly, 20 bytes
Œṗf³$ƑƇoؽœ&/L
P!Ç€Ṁ
Try it online!
Unlike Vyxal, Jelly's multiset intersection appears to work properly.
This is roughly \$O\left(2^{\left(\...
1
vote
0
votes
Not-Roman-Numeral Addition
05AB1E, 24 bytes
₄500тD;T5X)D.X:.vO.XS.vJ
Try it online or verify all test cases.
Explanation:
...
3
votes
Nest some addition
PARI/GP, 47 bytes
x->[[a,b]=[t=c^b,t^a]|c<-x[^b=!a=0]];(x[1]+a)*b
Attempt This Online!
A port of my Haskell answer. Takes input as \$[x_0,x_1,\dots,x_n]\$.
3
votes
Doing a little trolling with the microwave timer
05AB1E, 12 bytes
[=Ð_#тÖ40*>-
I/O as integers. Outputs everything on a separated line to save bytes.
Try it online or verify all test cases.
Explanation:
...
3
votes
Print all integers
Vyxal, 5 bytes
{N…ꜝ…
Try it Online!
{ # Forever...
N # Negate
… # Print
ꜝ # ~
… # Print
3
votes
Nest some addition
Haskell, 54 bytes
x#y|(a,b)<-foldl(\(a,b)c->(c^b,(c^b)^a))(0,1)y=(x+a)*b
Attempt This Online!
Takes input as \$x_0 \# [x_1,\dots,x_a]\$.
Abusing the notation,...
1
vote
Fibonacci polynomials
Desmos, 62 41 bytes
L=[n...0]
f(n)=mod(L+n,2)nCr((n+L-1)/2,L)
Function f outputs a list of coefficients in descending order, ...
1
vote
Doing a little trolling with the microwave timer
Perl 5 -n, 48 bytes
do{say"@F";@F=("@F"-1,59)if!$F[1]--}while"@F">=0
Try it online!
Minutes ...
9
votes
Fix my FizzBuzz
Vyxal, 21 15 bytes
ṖÞ∞ƛ₍₃₅T∨;ÞS$↔h
Try it Online!
Why use clever mathematics when you can just generate infinite FizzBuzz?
-6 thanks to Steffan and emanresuA
...
1
vote
Doing a little trolling with the microwave timer
Pyth, 18 bytes
WsQQ=?eAQ,GtH,tG59
Try it online!
Doesn't include [0,0]
...
2
votes
5
votes
Fix my FizzBuzz
J, 54 bytes
(-:&(/:~)"1#])#]\1((,~{~0=])2-@#.0=5 3|])@+#i.@+9>.>./
Try it online!
_1, _2, _3 represent Fizz, Buzz, FizzBuzz.
Generate all integers ...
3
votes
Doing a little trolling with the microwave timer
Curry (PAKCS), 40 bytes
n#m=(n,r m)?(r$n-1,r 59)
r n=anyOf[0..n]
Try it online!
This is a non-deterministic function whose return values are the all the ouputs.
1
vote
ro1000an nu1000era50 en100o501ng
C (gcc), 150 159 152 137 bytes
+9 to handle either case
-7 thanks to emanresu A
-15 thanks to ceilingcat
Processes a string, looking for Roman numerals. If it finds one, the value is added to the ...
2
votes
Doing a little trolling with the microwave timer
Retina 0.8.2, 79 74 bytes
\d+
$*
\G1
1$'¶
1>`:.*
:59$*
%(r`1\G
¶$`1
O^`
(1*):(1{10})*(1*)
$.1:$#2$.3
Try it online! Takes input in ...
2
votes
Doing a little trolling with the microwave timer
J, 25 24 bytes
(,.i.,])(,,/)60,"0/&i.~[
Try it online!
7
votes
"Hello, World!"
Objective-Java*#++--Script.NETnotation.sh, 18 bytes.
Hello,\ World!.exe
Try it online!
How it works:
...
4
votes
2
votes
Doing a little trolling with the microwave timer
Javascript, 49 bytes
let g=a=>([b,c]=a,(b+c)?[g([b-!c,c?c-1:59]),a]:a)
A recursive function that takes in an array like ...
3
votes
3
votes
Doing a little trolling with the microwave timer
C (GCC), 78 bytes
main(h,m){for(scanf("%d%d",&h,&m);h+m;m?--m:--h&(m=59))printf("%d %d\n",h,m);}
Attempt This Online!
7
votes
1
vote
1
vote
Flood fill by distance
Julia, 97 bytes
h(X,r=1,c=1,d=0)=try d<X[r][c]&&(X[r][c]=d;for i=[5,7,1,3] h(X,r+i÷3-1,c+i%3-1,d+1)end)catch;end
Attempt This Online!
representation:
...
6
votes
Doing a little trolling with the microwave timer
C (gcc), 43 bytes
f(n){printf("%d ",n);n&&f(n%100?n-1:n-41);}
Try it online!
6
votes
Compress Jelly's code page
Python, 404 bytes
J="̇".join
A="abcdefghilmnoprstwxyz"
a=A.replace
I,x,y="ị̇"
c=a("w","uvw")
for r in"cfgpx":c=c.replace(r,"")
C=...
3
votes
Am I being run backwards?
Make, 14 15 bytes
x:#
#$@$#
#:y
Try it online!
Updated to add a trailing tab on the second line...
Here's another one that's not as short, but seems ...
3
votes
Doing a little trolling with the microwave timer
HBL, 15.5 bytes
1'.(?,('?.(-,)).('?(-.)(-'-*))?
Takes the minutes and seconds as separate arguments to the main program; outputs a list of two-number lists. Try it ...
1
vote
I reverse the source code, you negate the output!
HBL, 1 byte
+<
Run forwards, outputs 4:
+ Increment
< Three
Run backwards, ...
4
votes
2
votes
Compress Jelly's code page
Jelly (trivial), 2 bytes
ØJ
Try it online!
ØJ: Yield Jelly's codepage.
Community wiki
3
votes
Doing a little trolling with the microwave timer
Brainfuck, 36 bytes
,+>,+<[->[-<.>.]>----[<+>----]<---<]
Try it online!
There are no separators and output is just ...
1
vote
Am I being run backwards?
HBL, 1 byte
+2
Run forwards, outputs 3:
+ Increment
2 Two
Run backwards, outputs ...
1
vote
1
vote
Doing a little trolling with the microwave timer
Factor + math.unicode pair-rocket, 60 bytes
[ [ .s dup last 0 = 1 => -59 "\0"? v- dup Σ 0 > ] loop . ]
Try it ...
1
vote
ro1000an nu1000era50 en100o501ng
Python, 130 122 bytes
-8 bytes by porting Arnauld's formula
...
Top 50 recent answers are included
Related Tags
code-golf × 11152string × 1964
math × 1480
number × 1131
ascii-art × 1119
sequence × 776
array × 710
decision-problem × 655
kolmogorov-complexity × 602
arithmetic × 491
number-theory × 400
integer × 375
grid × 324
geometry × 314
random × 303
tips × 297
combinatorics × 289
primes × 274
matrix × 262
date × 259
graphical-output × 251
parsing × 221
game × 220
quine × 198
restricted-source × 197