Skip to main content

New answers tagged

0 votes

Find the weight of five apples

Husk, 6 bytes m≠/4Σ¹ Try it online! The same logic as in other answers as well as my Pyth answer. Commented: ...
int 21h Glory to Ukraine's user avatar
0 votes

Find the weight of five apples

Pyth, 6 bytes m-/sQ4 Try it online! Takes a list of partial sums and outputs the list of the individual apples' weights. The solution is pretty basic: sum up the ...
int 21h Glory to Ukraine's user avatar
0 votes

Sum every second digit in a number

Red, 57 bytes func[n][s: 0 foreach[_ e]form n[s: s - 48 + any[e#"0"]]s] Try it online!
Galen Ivanov's user avatar
  • 21.1k
0 votes

Print the ASCII Code page

Zsh +coreutils, 25 bytes jot -c 95 32 \~|rs -eg0 6 Try it online! Beats the other Zsh solution by 1 byte!
roblogic's user avatar
  • 3,352
1 vote

Sum every second digit in a number

bc, 40 bytes for(i=length(a);i>=0;i-=2)b+=a/10^i%10;b Try it online! 42b Based on my similar bc solution, but iterating from ...
roblogic's user avatar
  • 3,352
1 vote

Add two numbers

Qdeql, 37 bytes Input in bytes rather than ASCII. Although Qdeql is limited to bytes, this would work with any (arbitrarily large) finite cell size. ...
Bbrk24's user avatar
  • 3,123
0 votes

Shortest infinite loop producing no output

Qdeql, 8 bytes -\=\/\// ...
Bbrk24's user avatar
  • 3,123
0 votes

Expand a C array

Uiua, 69 bytes ⊂⊃(□$"_ _[_];"|⍚$"_[_] = _;"¤⋅⊙⊓⇡∘)⊙⊙(⊸⧻⊜□≥@0.)°$"_ _[] = {_};" Try it!
nyxbird's user avatar
  • 475
0 votes

Help Sam understand chess

Uiua, 45 bytes ⊡⊗:"QRBNK":⍜≡⊡⊸↥:+@.[↥,,⊃(/↥=0|/=|=2/×|=1/↥)]⌵-°⍉⇡8_8⟜¤ Try it! ...
nyxbird's user avatar
  • 475
1 vote

Sum every second digit in a number

Husk, 6 bytes Σ→TC2d Try it online! A function that takes in a number and returns the sum of its even digits. Commented: ...
int 21h Glory to Ukraine's user avatar
1 vote

Sing Happy Birthday to your favourite programming language

Setanta, 68 bytes le i idir(-2,2)scriobh("Happy Birthday",(i&"to You")|"Dear Setanta") try-setanta.ie link
bb94's user avatar
  • 3,638
0 votes

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

Setanta, 89 bytes ...
bb94's user avatar
  • 3,638
0 votes

Divmod continuously until the remainder is 1 or 0, then get the remainder

Setanta, 43 bytes gniomh f(a,b){ma b>1 b=f(a//b,a%b)toradh b} try-setanta.ie link Non-recursive solution, 51 bytes ...
bb94's user avatar
  • 3,638
0 votes

Summing the Digits of a Number

Setanta, 57 bytes gniomh(n){s:=0le i idir(0,fad@n)s+=go_uimh(n[i])toradh s} try-setanta.ie link Version for native number type (up to \$2^{53}\$), 35 bytes ...
bb94's user avatar
  • 3,638
0 votes

Prime counting function

Ruby -rprime, 33 bytes ->n{Prime.take_while{_1<=n}.size} Attempt This Online!
Jordan's user avatar
  • 10.5k
2 votes

Implement a Truth-Machine

Qdeql, 678 bytes ...
Bbrk24's user avatar
  • 3,123
0 votes

Prime counting function

Husk, 3 bytes #ṗḣ Try it online! A very simple solution. Commented: ...
int 21h Glory to Ukraine's user avatar
1 vote

Tips for golfing in x86/x64 machine code

LOOP according to ECX This is the famously slow instruction that decrements CX/ECX/RCX as a counter, then short jumps if not zero, all in 2 bytes! ...
qwr's user avatar
  • 12.2k
0 votes

Filter out and add up

Swift 6, 68 bytes let p={($0+"").split(separator:#/[^\d]/#).map{Int($0)!}.reduce(0,+)}
macOSisthebestOS's user avatar
0 votes

Print the ASCII Code page

Ruby, 34 bytes puts [*" "..?~].join.scan /.{,16}/ Attempt This Online!
Jordan's user avatar
  • 10.5k
0 votes

Print the ASCII Code page

Swift 6, 84 bytes (2...7).map{n in(0...15).map{n*16+$0}}.map{print(String($0.map{.init(.init($0)!)}))}
macOSisthebestOS's user avatar
0 votes

Is my triangle right?

Swift 6, 65 bytes let r={{a in a[0]*a[0]+0+a[1]*a[1]==a[2]*a[2]}(($0+[]).sorted())} r takes an ...
macOSisthebestOS's user avatar
0 votes

Implement the hyperfactorial

Swift 6, 69 bytes import Foundation let h={(1...$0).map{pow(.init($0),$0)}.reduce(1,*)}
macOSisthebestOS's user avatar
1 vote

Is my triangle right?

Husk, 7 bytes Ẋo=+m□O Try it online! Takes a list of side lengths and outputs a 1-element list: [1] if true, ...
int 21h Glory to Ukraine's user avatar
0 votes

Print the ASCII Code page

Vyxal 3 j, 4 bytes kP₁Ẇ Try it Online! cool
pacman256's user avatar
  • 4,225
0 votes

Recreate the ASCII-table as an ASCII-table

C (clang), 164 bytes ...
jdt's user avatar
  • 3,817
4 votes

Turing-Complete Language Interpreter

Trilangle interpreting Qdeql, 990 bytes ...
Bbrk24's user avatar
  • 3,123
1 vote

Tips for golfing in x86/x64 machine code

Use 32-bit x86 instead of 64-bit x86-64, if you can This is a bit silly, but many code golf challenges only require 32-bit inputs, and 32-bit programs execute just fine on x86-64 processors (almost ...
qwr's user avatar
  • 12.2k
0 votes

Divmod continuously until the remainder is 1 or 0, then get the remainder

Ruby, 25 bytes F=->a,b{b>1?F[a/b,a%b]:b} Attempt This Online!
Jordan's user avatar
  • 10.5k
0 votes

Parse Minecraft's VarInt

x86, 24 23 22 bytes Couldn't figure out any tricks to get rid of shift, so it's a straight-forward do-while loop, checking the byte's sign bit. Input in esi, output ...
qwr's user avatar
  • 12.2k
1 vote

Draw a big slash X

K (ngn/k), 19 18 bytes -1 byte from @att "X\\/"@2/~|:\=1+2* Try it online! Thanks to @tubular. 1+2* multiply the (...
coltim's user avatar
  • 6,033
2 votes

Minimum excluded number

Husk, 6 bytes ▼-⁰ŀ21 Try it online! This is my first solution in Husk. I have picked up an easy challenge for starters. Commented: ...
int 21h Glory to Ukraine's user avatar
1 vote

Sylvester primes

Python, 185 bytes ...
TheLittlePeace's user avatar
1 vote

Sums of X*Y chunks of the nonnegative integers

Python, 131 bytes import numpy lambda a,b,c,n:numpy.arange(b*c*n).reshape((-1,b,c)).transpose((0,2,1)).reshape((-1,a,b)).sum(axis=(1,2)).flatten()[n] TIO. Unlike ...
NikoNyrh's user avatar
  • 2,681
0 votes

Filter out and add up

JavaScript (Node.js), 34 bytes s=>eval(s.replace(/\D|$/g,' +')+0) Try it online! Like ETHproductions's answer but extra push is possible Not work as intended ...
l4m2's user avatar
  • 26k
1 vote

Sums of X*Y chunks of the nonnegative integers

Clojure, 87 bytes #(for[P[partition]p(P %2(P(quot %3 %1)(P %1(range))))r(apply map concat p)](apply + r)) TIO. Yay, Clojure is quite good with partitioning and &...
NikoNyrh's user avatar
  • 2,681
1 vote

Filter out and add up

Python 3.12, 53 bytes import re;lambda s:sum(map(int,re.findall(r'\d+',s))) Apologies if anything is incorrect with my submission, I've been lurking for a while ...
vqq's user avatar
  • 11
0 votes

Bloons TD 6 Ordered Upgrade Paths

Vyxal M, 143 bitsv2, 17.875 bytes 502fʀΠvṖÞfUµ₍G≬GḟN;Ṙ Try it Online! Bitstring: ...
pacman256's user avatar
  • 4,225
1 vote

Sing Happy Birthday to your favourite programming language

Chicken, 20550 bytes Program here The language I chose is ridiculously unsuitable for code golfing, you will know why when you see the program. However, there is an interesting feature in this ...
None1's user avatar
  • 1,135
0 votes

Shortest Error Message

Vyxal (online), 4 bytes 1ƛød Try it Online! Outputs . Vyxal's online mode has a weird quirk where, if an error occurs inside ...
emanresu A's user avatar
  • 41.6k
0 votes

Visually Explain the Pythagorean Theorem

Vyxal, 17 bytes ∆/J:\#*ε‛+=Y4IYf§ Try it Online! I thought I'd answer this with modern Vyxal. ...
emanresu A's user avatar
  • 41.6k
0 votes

Generate this number table

Clojure, 49 bytes #(for[R[(range 1(inc %))]r R](for[c R](max r c))) TIO. IMO the only interesting trick is to re-use the range value ...
NikoNyrh's user avatar
  • 2,681
0 votes

Calculate sum of self-exponentation

Clojure, 34 bytes #(apply +(for[i %](Math/pow i i))) The input must be a list.
NikoNyrh's user avatar
  • 2,681
0 votes

Recreate the ASCII-table as an ASCII-table

Zsh, 239 193 bytes ...
roblogic's user avatar
  • 3,352
0 votes

Create output twice the length of the code

///, 15 bytes /a/bbbbb/aaaaaa Try it online!
autumn's user avatar
  • 662
0 votes

Recreate the ASCII-table as an ASCII-table

ARBLE, 151 bytes ...
ATaco's user avatar
  • 10.9k
2 votes

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

Uiua, 52 50 bytes $"How much _ would a __ _ if a _ could _ _?"⊃∩.⊃⊂: Try it: Uiua pad Explanation: Each _ in the <...
noodle person's user avatar
0 votes

Recreate the ASCII-table as an ASCII-table

Uiua, 95 92 bytes J←$"_ | _" ≡&p⊂/J↯3"Dec Chr "⊂@-/≡J≡≡(⊂⬚@ ↙5°⋕)+32°△↙2⟜↯3_32_5↻1⬚@ (⊂"DEL"⊂"Space")+@!⇡¤94 Try it: ...
noodle person's user avatar
1 vote

Sing Happy Birthday to your favourite programming language

///, 51 bytes /@/Happy Birthday //#/to You / @#@#@Dear Slashes @# Try it online! I'm back! Slashes is a great language for these very repetitive tasks.
autumn's user avatar
  • 662
0 votes

Calculate sum of self-exponentation

Perl 5 -pa, 18 bytes map$\+=$_**$_,@F}{ Try it online!
Xcali's user avatar
  • 15.7k

Top 50 recent answers are included