Skip to main content

New answers tagged

0 votes

Golf you a quine for great good!

AutoHotkey (v2), 59 bytes Looks like the first AHK answer! MsgBox Format(s:="MsgBox Format(s:={:c}{}{1:c},34,s)",34,s)
Xuesong Peng's user avatar
1 vote

Interval Placement

Retina 0.8.2, 50 bytes \d+ $* (1+),\1 ^(.)(1+)(.),(.1\2|(\1|\[)\2(\3|])) Try it online! Link includes test cases. Explanation: ...
Neil's user avatar
  • 177k
0 votes

Longest bitonic subarray

Jelly, 19 18 bytes IṠo@\IŻ=2ÄkµÐƤẈÞṪḢ Try it online! -1 by remembering that by the time I need to bandaid the sort order I'm just in truthiness land Probably loses ...
Unrelated String's user avatar
0 votes

Cell`s Life #1: Simulate a plant cell

AutoHotkey (v2), input from stdin, output to stdout, 265 bytes Since it should be a cat ...
Xuesong Peng's user avatar
0 votes

The struggling college student's GPA Calculator

JavaScript (Node.js), 70 bytes f=([c,d,...s],a=b=0)=>c?f(s,a+(b-=d,'0x'+c-14.5|0)*d):(a/b).toFixed(2) Try it online! From Arnauld's but ...
l4m2's user avatar
  • 28.4k
3 votes

Longest bitonic subarray

JavaScript (Node.js), 92 bytes x=>(g=i=>(e=x.slice(i,n+i||1/0)).some(t=u=c=>t?u>(u=c)&&++t:u<(u=c))?g(n+i?i+1:!--n):e)(n=0) Try it online!
l4m2's user avatar
  • 28.4k
3 votes

Longest bitonic subarray

R, 150 bytes ...
Eonema's user avatar
  • 331
0 votes

Output the nth rational number according to the Stern-Brocot sequence

Desmos, 212 bytes Try it online! (link 1) Try it online! (link 2) (just please note that due to Desmos' max recursion limit, you'll have to wait quite some time just to get the function to even load ...
CrSb0001's user avatar
  • 489
1 vote

Decode the constant/variable

C (gcc), 45 bytes f(char*x){*x=*x-48|x[1]%46<1?*x-46?*x:36:45;} Try it online!
matteo_c's user avatar
  • 6,950
0 votes

Implement division

Japt, 4 bytes *VpJ Try it here
Shaggy's user avatar
  • 43.5k
0 votes

Implement division

Perl 5 -pl, 26 + 2 = 28 bytes / /;$_=1x$_;$_=()=/.{$'}/g Try it online! Implements unary division.
Xcali's user avatar
  • 16.2k
0 votes

Implement division

wow, there's a lot of python answers on here. julia's pretty similar, I wonder if it wins? Julia, 38 bytes vs @gnibbler, 73 a\b=floor(Int,1e-5+exp(log(a)-log(b))) ...
guest4308's user avatar
  • 1,458
0 votes

Swap the parity

Raku (Perl 6) (rakudo), 18 bytes f($x){$x-(-1)**$x} Attempt This Online!
xrs's user avatar
  • 579
0 votes

How much code would a codegolf golf if a codegolf could golf code?

Raku (Perl 6) (rakudo), 74 bytes my ($a,$b)=@*ARGS;say "How much $a would a $a$b $b if a $a$b could $b $a?"
xrs's user avatar
  • 579
0 votes

Find all unique quintuplets in an array that sum to a given target

APL, 63 chars {⍺{⍵/⍨(⍺∘=+/∧5∘=∘≢)¨⍵}{0=≢⍵:1⍴⊂⍬⋄⊃,/(⊃⍵){(⊂⍵),⊂⍵,1⍴⍺}¨(∇1↓⍵)}⍵} Takes the target on the left and the list of numbers on the right. Explanation, ...
Aaron's user avatar
  • 211
0 votes

What's the day today (or other dates)?

ARM64 (AArch64), 435 without comments For comedic effect, fun & profit, here is an arm64 assembly language implementation. This relies on the kefalonian constant ...
fgeorgatos's user avatar
2 votes

Longest bitonic subarray

Charcoal, 50 bytes ≔⟦⟧θFA«⊞θιW№⭆EΦθμ⁻λ§θμ⎇λ‹λ⁰ω10≔Φθμθ¿›LθLυ≔⮌⮌θυ»⭆¹υ Try it online! Link is to verbose version of code. Explanation: ...
Neil's user avatar
  • 177k
0 votes

Catalan Numbers

Raku (Perl 6) (rakudo), 63 bytes my $n=@*ARGS[0];say ([*] 1..(2*$n))/([*] 1..($n+1))/([*] 1..$n) AWK, 67 bytes ...
xrs's user avatar
  • 579
1 vote

Longest bitonic subarray

JavaScript (ES6), 101 bytes a=>(g=n=>a.some((m,i)=>!(b=a.slice(i,i+n)).some(p=v=>(m=p<m?m:p)>p&p<(p=v)))/b[--n]?b:g(n))(a.length) Try it ...
Arnauld's user avatar
  • 198k
0 votes

Draw a big slash X

jbasher2, 1002 bytes ...
madeforlosers's user avatar
0 votes

Fibonacci function or sequence

jbasher2, 155 bytes ...
madeforlosers's user avatar
0 votes

Additive Persistence

Raku (Perl 6) (rakudo), 62 bytes my ($n,$i)=@*ARGS[0],0;while $n>9 {$i++;$n=[+] $n.comb};say $i AWK, 63 bytes ...
xrs's user avatar
  • 579
4 votes

Longest bitonic subarray

Python 2, 87 bytes def f(a,*p):i=iter(map(cmp,a[1:],a));return a*((-1in i)>(1in i))or f(*p+(a[:-1],a[1:])) Try it online! Notice that this answer is in Python ...
tsh's user avatar
  • 35.6k
1 vote

Write a program that prints a program that's almost quine

AutoHotkey (v2), 70 bytes a:=(r:=(n)=>n?"a" r(n-1):"")(A_Args[1]) MsgBox a ":=0,MsgBox('" a "')" Output when arg is <...
Xuesong Peng's user avatar
1 vote

Digits in their lanes

Zsh, 50 bytes for i;{for j (\- {0..9})printf ${j/[^$i]/\ };echo} Try it online!
roblogic's user avatar
  • 4,012
4 votes

Find a fraction's parent in the Stern-Brocot tree

Wolfram Language (Mathematica), 48 bytes (r=ResourceFunction@"SternBrocot")@Floor[r@#/2]& ... yeah, there's a builtin (Mathematica has to load the ...
Greg Martin's user avatar
  • 16.2k
0 votes

Write the shortest self-identifying program (a quine variant)

AutoHotkey (v2), input as arguments, output to MsgBox, 91 93 87 bytes Case insensitive comparison. It's OK since function & var names and strings are all case ...
Xuesong Peng's user avatar
4 votes

Longest bitonic subarray

05AB1E, 15 bytes ŒRéR.ΔÔ¬š¥dÔJR! (Don't) try it online (it's too slow to even handle the example test case). Verify all test cases with a small addition of ...
Kevin Cruijssen's user avatar
3 votes

Find a fraction's parent in the Stern-Brocot tree

R, 168 bytes ...
Eonema's user avatar
  • 331
0 votes

Tips for golfing in Python

Use slicing when try to return single element list with-in and & or We all known that following two statements are the same. ...
tsh's user avatar
  • 35.6k
2 votes

Find a fraction's parent in the Stern-Brocot tree

Python3, 146 bytes ...
Ajax1234's user avatar
  • 7,711
2 votes

Find a fraction's parent in the Stern-Brocot tree

Charcoal, 52 49 bytes ≔E²NθW¬№υθ≔⊞OEυ⟦§κ¹⁻Σκ⊗﹪§κ⁰§κ¹⟧E²¦¹υI§υ±⍘Φ⍘Lυ²⊖κ² Try it online! Link is to verbose version of code. Explanation: Works by generating the ...
Neil's user avatar
  • 177k
0 votes

10 PRINT CHR$(205.5+RND(1)); : GOTO 10 in PHP (or anything else, for that matter)

Perl 5, 28 bytes 1while print.5>rand?'/':'\\' Try it online!
Xcali's user avatar
  • 16.2k
11 votes

Find a fraction's parent in the Stern-Brocot tree

JavaScript (ES11), 48 bytes -2 thanks to @Shaggy Expects (n,d) as BigInts and returns [n',d']. ...
Arnauld's user avatar
  • 198k
0 votes

What's the day today (or other dates)?

python2 -- 98 bytes This improves upon the existing python3 answer: ...
fgeorgatos's user avatar
0 votes

Find all unique quintuplets in an array that sum to a given target

R, 52 bytes \(x,n)unique(t(combn(x,5,sort)[,combn(x,5,sum)==n])) Attempt This Online! Returns quintuplets as rows of a matrix.
pajonk's user avatar
  • 18.3k
0 votes

Is it a leap year?

Hatchback, 179 bytes ...
madeforlosers's user avatar
0 votes

"Graphing" calculator

Raku (Perl 6) (rakudo), 45 bytes my ($m,$c,$p)=@*ARGS;for 1..$p {say $m*$_+$c} Attempt This Online!
xrs's user avatar
  • 579
2 votes

Can't see the forest for the keys

JavaScript (V8), 157 156 bytes ...
WeirdGlyphs's user avatar
0 votes

Shortest code to produce infinite output

Raku (Perl 6) (rakudo), 14 bytes .say for 1 xx* Attempt This Online!
xrs's user avatar
  • 579
0 votes

Fibonacci function or sequence

Hatchback, 57 45 32 bytes 0 0 1 2 1 0 17 0 1 1 0 0 65281 0 since Hatchback has an integer limit of 0xFFFF, it stops at 9227465 and errors out. it doesnt need ...
madeforlosers's user avatar
0 votes

Implement a Truth-Machine

Hatchback, 32 bytes 0 0 0 16 0 1 0 6 0 65281 1 65535 asks for input, prints, checks if its 1 and if it is continue printing.
madeforlosers's user avatar
0 votes

Fibonacci function or sequence

Raku (Perl 6) (rakudo), 22 bytes .say for (1,1,*+*...*) Attempt This Online!
xrs's user avatar
  • 579
0 votes

All code and no play makes 31415 a dull boy

Raku (Perl 6) (rakudo), 142 bytes ...
xrs's user avatar
  • 579
0 votes

Output your Score!

Raku (Perl 6) (rakudo), 16 bytes say 8+8~' bytes' Attempt This Online! Not too exciting, still new to Raku.
xrs's user avatar
  • 579
1 vote

Output your Score!

x86 16-bit machine code + DOS, 23 bytes Hexdump: b4 09 20 42 59 54 45 53 24 00 81 36 00 01 86 3a ba 00 01 cd 21 cd 20 Doesn't contain the characters ...
anatolyg's user avatar
  • 13.9k
1 vote

Find all unique quintuplets in an array that sum to a given target

05AB1E, 8 bytes {5.ÆÙʒOQ Inputs in the order \$array,target\$. Outputs [] if there is no valid result. Try it online or verify ...
Kevin Cruijssen's user avatar
1 vote

Find all unique quintuplets in an array that sum to a given target

JavaScript (V8), 91 bytes f=([v,...a],n,o=q=[])=>o[4]?n||q[o.sort()]||print(q[o]=o):v+1&&f(a,n-v,[...o,[v]])|f(a,n,o) Try it online! Commented ...
Arnauld's user avatar
  • 198k
4 votes

Find all unique quintuplets in an array that sum to a given target

Python 3, 95 bytes f=lambda t,a,*p:[p][t*t:len(p)==5]or{i for v in[*a]for i in f(t-a.pop(0),[*a],*sorted([*p,v]))} Try it online! Input target value and the array ...
tsh's user avatar
  • 35.6k
1 vote

Golf you a quine for great good!

Hatchback, 97 85 71 bytes 0 0 255 0 1 1 0 3 65534 2 3 1 11 2 0 1 2 2 0 1 14 2 3 6 2 65281 8 65535 This is half-cheating(?) as it's technically not reading the ...
madeforlosers's user avatar

Top 50 recent answers are included