New answers tagged

0

Fortran, 193 bytes A horribly mangled version of the Rosetta Code example. It prints 505 digits. Try it Online... integer,dimension(3350)::v integer::o,a,m,k,l,n;o=0;v=2 do n=1,101;a=0;do l=3350,1,-1 m=100000*v(l)+a*l;a=m/(2*l-1);v(l)=m-a*(2*l-1);enddo k=a/100000;write(*,"(I5.5)")o+k;o=a-k*100000;enddo end


0

05AB1E, 20 bytes ₄°·D.ΓN>*N·3+÷}O+₄;£ Port of my Java answer (with the 503 replaced with 1000 - anything \$\geq503\$ is fine to output the first 500 digits accurately with this approach). Try it online or verify it's equal to the first 500 digits of PI using the builtin žs. Explanation: ₄° # Push 10**1000 · # Double it to ...


0

Java 10, 208 207 206 bytes n->{var t=java.math.BigInteger.TEN;var p=t=t.pow(503).multiply(t.valueOf(2));for(int i=1;t.compareTo(t.ZERO)>0;p=p.add(t))t=t.multiply(t.valueOf(i)).divide(t.valueOf(i-~i++));return(p+"").substring(0,500);} -1 byte thanks to @ceilingcat. Try it online. Or as full program (255 bytes): interface M{static void main(...


3

Husk, 28 25 24 bytes i*!500İ⁰ΣG*2mṠ/o!İ1→ḣ□70 Try it online! Calculates the value of pi as a rational number using the first 5000 terms of the infinite series 2 + 1/3*(2 + 2/5*(2 + 3/7*(2 + 4/9*(2 + ...)))), and then extracts the first 500 digits. The code to calculate the value of pi from a specified number of terms is only 13 bytes (ΣG*2mṠ/o!İ1→ḣ): ΣG*2mṠ/...


3

><>, 95 bytes "ra7+2*>o< !#$%&'(),-./01345689:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`bcdefghijklmnpqstuvwxyz{|}~ Try it online! Simple ><> quine, with extra chars added. "ra7+2*>o< !#$%&'(),-./01345689:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`bcdefghijklmnpqstuvwxyz{|}~ " Begin string mode ra7+2... ...


1

Ruby, 99 98 bytes p"<({[CODE G0Lf_FTW!)}]>,.QmAkX/hlP5xwRc6&vZ-:?$Msq*UNb7%IKn'd|B8eYt=rg3S1yi9`z\\j4a2o;@^JVp~#+uH" Try it online! I'd love to see a shorter Ruby version but I don't know how it could be built. I tried to use a regex in order to save one or two characters, but there needs to be a space between p and /, and \ needs to be ...


4

Haskell, 101 bytes main=putStr[' '.."#$%&()*+,-/01234689:;<>?@ABCDEFGHIJKLMNOPQRTUVWXYZ\\^_`bcdefghjkloqsvwxyz{|}~"!!75] Try it online!


2

Assembly (NASM, 32-bit, Linux), 175 bytes mov ecx,y mov edx,z mov ebx,1 mov eax,4 int 128 section .data y db" !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~",34 z equ $-y Try it online!


9

Self-modifying Brainfuck, 95 bytes +[.<] !"#$%&'()*,-/0123456789:;=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\^_`abcdefghijklmnopqrstuvwxyz{|}~ Try it online! The + in the beginning is just to enter the loop, [.<] prints the source code backwards.


1

GolfScript, 96 bytes {" !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz|~"} Try it online! The extra byte is because the " has to be paired. The block is outputted as it was written in the source code followed by a newline.


10

Husk, 95 95 bytes Edit: adjusted to fix bug pointed-out by Neil. Same bytes mcW=2`R\.5+46L" !#$%&'()*,-/013789:;<=?@ABCDEFGHIJKMNOPQSTUVXYZ[]^_abdefghijklnopqrstuvwxyz{|}~ Try it online! Well, 96 bytes in Husk is trivial as a literal string, but 95 bytes was much more tricky. The strategy that I've used is to (1) output all 95 printable ASCII ...


4

PHP, 95 bytes !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Try it online! I'm not sure If we're allowed not to open the <?php tag in the header.. If not, that's only 2 bytes more, the simpler it just to close it: PHP, 97 bytes ?> !"#$%&'()*+,-./0123456789:;<=>?@...


3

MathGolf, 99 97 bytes '"" !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~\ Try it online. Explanation: '" # Push the character '"' "... # Push a string with all printable ASCII characters, except for '"' # (NOTE: The `\` is at the end so we won't have to ...


1

05AB1E, 96 bytes “ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Try it online. Explanation: “ # Start a dictionary string ... # Push all printable ASCII characters, which are used as is in dictionary string # (after which this string is output implicitly as result) See this ...


3

Python 2, 101 bytes print[(' !"#$%&*+-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{\|}~',)] Try it online!


1

Keg, 101 bytes 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`!"#$%&\'()*+,-./:<=>?@[\\]^_\`{|}~ `\; Try it online! The joys of auto pushing everything


8

Python 3, 105 bytes print(' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~') ;) Try it online!


1

Batch, 102 bytes @echo " !#$&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~%% Command execution in Batch is a little odd. There are four stages: Environment variable expansion Parsing a line into individual commands that are piped or chained Expanding for variables Delayed environment variable ...


1

Retina 0.8.2, 96 bytes !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Try it online! Explanation: Simply replaces the empty input with the desired output.


6

Text, 95 bytes !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Text programs always print their contents.


3

Gaia, 96 bytes !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"” Try it online! Alternately (same byte count): “ !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" Try it online!


2

C (gcc), 112 110 111 bytes Saved 2 bytes thanks to Nahuel Fouilleul!!! Added a byte to fix a bug kindly pointed out by Neil. f(){puts(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");} Try it online! Straight up print those characters, nothing fancy here.


7

R & likely polyglot, 97 bytes " !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" Try it online! 2 wasted characters: the second """ to close the string, and the need to use "\\" to escape the escaping function of the "\" character. This 'program' will ...


4

APL (Dyalog Unicode), 104 bytes ⎕←' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~' Try it online! Most APL interpreters would not require the ⎕←, and would thus require only 98 bytes; a quoted string evaluates to itself. The requirement for ⎕← is an artifact of TIO.


2

C (gcc), 111 107 bytes Thanks to Noodle9 and Nahuel Fouilleul for noticing the errors and the reductions! main(b){for(b=32;putchar(b++)<" !#$%&'*,-./014789:>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\^_`degjklqsvwxyz|~"[65];);} Try it online!


1

Wolfram Language (Mathematica), 14 15 functions Verify: with Re or with Ramp Mathematica only has so many ways to define a function, but there are still has a good number of built-ins up to the task. #&. A function that returns its first argument. $$. A function of one variable that returns that variable.  is U+F4A1. f_//f=f. Defines a function f ...


1

Elixir, 5 functions + abs round ceil &(&1) Well, unary + is technically an operator, but I think it should count, as it really quacks like a function in Elixir. For instance, it can be captured and passed as an argument to a higher-order function in the same way as a named function, and even the syntax for overriding unary operators is like defining ...


1

Rust, score 12 column![]/ //the column macro expands to the column it was invoked in, then divided by self column![] //Newlines used to make sure they are aligned properly 2 3 4 1<<1<<1|1 //one bit shifted left twice, then bitwise or with one 6 7 8 9 5+5 0x0b //byte literal 'L' as isize % '@' as isize //character literals cast into unicode ...


0

Neim, 4 2 bytes χρ Try it online! Push 20, push 14 and print the entire stack


0

MAWP 2.0, score 12, 40 bytes : Outputs the 1 on stack 2 ------| 3 | 4 | 5 | 6 > Number literals 7 | 8 | 9 | 10 ------| __________ Pushes length of stack 10 ...


4

Husk, 1 program + 24 functions 8 functions by @Zgarb! 4 functions by @Razetime Programs: ḟ=⁰N - Find an element that equals the last command-line argument in the infinite list of natural numbers. Try it online Functions: I - the identity function +0 - Add 0 *1 - Multiply by 1 D½ - Double and then halve ĠK - Scan right without an initial value. The K ...


1

Befunge-98 (PyFunge), 13 bytes, turn 5 (turn 4 was an implicit farkle) "PDPF"4(~FP@ This answer is far from winning, but I'm including some characters an average program in this language will likely need, and keeping the challenge alive. Try it online! Previous answer Rules: Programs may not accomplish the end goal (last turn) Minimum program length is 10 ...


0

Vyxal, 14 13 12 10 bytes Ĥij*dij+⨥⨥⨥⨥ -1 thanks to @JoKing -2 thanks to using a different approach Explained (Old) Ĥij*dij+⨥⨥⨥⨥ Ĥ # Push 100. STACK = ⟨100⟩ ij # Push 10. STACK = ⟨100|10⟩ * # Multiply the two together. STACK = ⟨1000⟩ d # Double the top of stack. STACK = ⟨2000⟩ ij+ # Add 10 to the top of stack. ...


0

Rockstar, 8 bytes Probably the only time Rockstar will ever come close to being competitive! rOCKSTAR Try it here (Code will need to be pasted in)


0

MAWP 2.1, 15 bytes !+!:!!-:!!$:!+: Try it online lol.


1

MAWP, 30 28 bytes !!+!!!!++!*+/!+!!+!+!!++++*: Try it! This will be fun to golf. This is longer than @Lyxal 's answer, but outputs only one time as one number.


2

Labyrinth, 12 bytes ))!!)!))))!@ Try it online! ))))_#!!#!!@ Try it online! ))_#" ) !!@ Try it online! ))!" ) )#!!@ Try it online! I tried both linear and complex layouts, but I can't figure out how to remove a single byte from any of these programs.


0

brainfuck, 1445 bytes ->-[------->+<]>-.-[->+++++<]>++.+++++++..+++.[->+++++<]>+++...++[--->++<]>.+[->+++<]>++.+++.----[->+++<]>.------------.--[->++++<]>-.+[->+++<]>.+++++++.--.[->+++++<]>-.---[->++++<]>-.-----------.+++++++.++++++.---------.--------.-[--->+<]&...


1

05AB1E, 76 73 bytes u”Ÿ™... ”“Ûß,£Ô‚© I g“«’‚™ˆÆ?’«,‘‚ï‘Qi“ºÆ,…Ü.‚ï.“ë“€¸.€Š€ˆn't€À I±….“}.ª, Try it online! -3 bytes thanks to @ovs. # (implicit) push STDIN to stack u # convert top of stack to uppercase ”Ÿ™... ”“Ûß,£Ô‚© I g“«’‚™ˆÆ?’« # push "Hello... eh, whom do I greet?" , ...


Top 50 recent answers are included