New answers tagged

0

x86-16 machine code, 5 bytes Binary: 00000000: 4834 0140 c3 H4.@. Listing: 48 DEC AX ; decrement input (parity now inverted) 34 01 XOR AL, 1 ; if LSb is 0 (odd input) add 1, otherwise subtract 1 40 INC AX ; increment C3 RET ; return to caller Callable function, ...


0

Java (JDK), 43+1 bytes s->{int i=0,t=s;for(;++i<s;t*=s);return t;} Try it online! Overflows for 10, so all ints need to be changed to long a the cost of +1. This has been done for the TIO link. I didn't think I could beat the IntStream though!


1

Google Sheets, 24 Input A1. =DECIMAL(1&REPT(0,A1),A1 Is base conversion ok? If not, here's one at 26 (but it's really boring): =PRODUCT(SEQUENCE(A1,1,A1,


0

x86-16 machine code, PC DOS, 18 bytes Binary: 00000000: a082 002c 30a8 0191 b85c 0a74 02b0 2fcd ...,0....\.t../. 00000010: 10c3 .. Listing: A0 0082 MOV AL, BYTE PTR[82H] ; first char of command line into AL 2C 30 SUB AL, '0' ; ASCII convert input char A8 01 TEST AL, 1 ; set ZF ...


3

><>, 443 bytes e1r>i::1)$a-*?v{2v xys^p}+1$}:{:{< v0{^?)1p}1}+1:{0-< /rp130p120p210p110p100p00-f{p2 >01g1+11ge+g:0=' '$?$~:21g?v:'"'=$"'"=+?v :'.'=?v::'p'=$'g'=+?/79p02g1+12g8+. >03 v20~v?-g12 <1p12 <0p10p11~< ?! .!p20p21\1p v g 7a^ v<~< < 69. >001-^.98 1<78v//o!^10^~ 3^ 1....


0

Perl 5, 12 bytes $_+=$_%2||-1 Try it online!


0

Perl 5 + -p, 17 bytes $_=eval"$_*"x$_.1 Try it online!


0

Python 2, Perl 5, JavaScript (Node.js), Ruby, 524 characters 0//1;q=0;print"Hello, World!";'''/.__id__;puts STDIN.read.succ;%q[=;$_=q{print q@0//1;q=0;print"Hello, World!";'@.qq@''/.__id__;puts STDIN.read.succ;%q[=;\$_=q{$_};eval;q[\n@.q@for(x=99,z=(a=' on the wall\n')=>`${x||'No more'} bottle${1-x?'s':''} of beer`+a;x;)console.log(z()+...


0

Japt, 4 bytes aJpU Try it (includes all test cases) aJpU :Implicit input of integer U a :Absolute difference with J : -1 pU : Raised to the power of U


0

Javascript 50 bytes alert((305786-parseInt(prompt(),26)).toString(26))


2

Rust, 37 bytes |x|(|mut y|{for _ in 1..x{y*=x}y})(x) Try it online This might be able to be shortened once bindings_after_at stabilizes by using |mut y@x| instead.


0

Flurry, 14 bytes ([]{(){}{}}{}) Run example $ echo -n "?" | ./flurry -bnb -c "([]{(){}{}}{})" ? $ echo -n "Hello world" | ./flurry -bnb -c "([]{(){}{}}{})" d -bnb flag means "print stack as chars, print nothing for return value, and take stdin as chars". If the challenge were asking for "the last value ...


0

Befunge-98 (FBBI), 5 bytes 1-indexing. Input is the index, a space and the string. &k~,@ Try it online! This just reads index characters as input and prints the last one.


0

Integral, 2 Bytes Vn Try it! Explanation V Reverse the input n Head


1

Integral, 2 Bytes Integral doesn't have an a[n] built-in. Unfortunately it does have some slicing built-ins, which makes a 2-byter possible... rn Try it! Explanation r Last b n Head


0

MAWP, 2 bytes |; Outputs top of stack. Try it!


1

Retina, 10 bytes :`GoodBad Try it online! : swaps the input and the regex, so this computes 'GoodBad'.replace(input, '').


2

MAWP, 59 bytes %|~88W7MA{88W7M;99W65WM!;;25W25WW;}<88W2M;99W44WM;25W25WW;> Try it!


0

Flurry, 14 bytes (<>{}{({})}){} Adapted from this answer. One of the {} terms is replaced with {({})}, a function which pushes its argument to the stack. Thus the infinite loop grows the stack on every iteration.


1

MAWP, 19 bytes |[!1A]%_1A[%W_1A]~: Utilises this input/output consensus that numbers can be taken as ascii characters. MAWP, 19 bytes @[!1A]%_1A[%W_1A]~: Try it! If you want to enter normal numbers like normal people.


1

MAWP, 31 bytes %@<:.>!!1A[1A~!1A~]%1A[1A~W~]%: 125! takes around 11 seconds, so it fulfills the criteria. Try it!


0

Perl 5 -plF, 9 bytes $_=$F[<>] Try it online!


1

Java (JDK), 235 233 bytes int c(int[][]m,int x,int y,int b){int a=0,v;try{v=m[x][y];if(v*(b-=v)<0)v/=0;m[x][y]=-1;if(x==m.length-1&y==m[0].length-1)return 1;a=c(m,x+1,y,b)+c(m,x-1,y,b)+c(m,x,y+1,b)+c(m,x,y-1,b);if(a<1)m[x][y]=v;}catch(Exception e){}return a;} Try it online! Requires an int[][] with 0 as field and 1 as wall. Returns 0 on failure ...


0

Keg, -hr, 7 bytes :2%[;|⑨ Try it online!


1

MAWP, 18 bytes %@!!2P2WA{M:}<1A:> Try it!


0

Acc!!, 85 bytes N Count i while _/128^i/32 { _+128^(i+1)*N } Count j while N/48 { _/128 } Write _%128 Takes the string on one line of stdin and the 0-based index, in unary, on the following line. (I hope unary is okay. Decimal I/O is a pain in Acc!!) Try it online! Commented # Read printable ASCII characters into the accumulator, storing the first ...


0

Integral, 6 Bytes Outputs the list as individual stack elements joined by the newline. If built-ins weren't banned, it would be possible via ♫ (1 bytes). ◙v◙♦▼e Try it! Explanation ◙ Duplicate input, in order to get around the edge case 1 v◙ "◙": Create a copy of the operand, when evaluated ♦ Swap up a copy of the input ▼ ...


1

Pip, 5 bytes aR00i Takes a string of 0s and 1s. Try it online! Explanation Beating Jelly? Inconceivable! a Take the first command-line argument R and replace 00 00 (an integer literal, so it doesn't need quotes) i with i (variable preinitialized to 0) Autoprint


1

tinylisp, 38 bytes (load library (q((N)((i(odd? N)a s)N 1 Try it online! (Adds 4 bytes to bind the lambda function to a name for ease of testing.) Ungolfed (load library) (lambda (N) ((if (odd? N) add2 sub2) N 1)) Pretty straightforward implementation of the spec: if N is odd, add 1 to N; if not, subtract 1 from N. The main trick is that the if needs ...


0

MAWP, 38 bytes %@!!2P2WA{~[67W5M;1A].}~[99W25W1MM;1A] Made using Dion's modulus function from here. Try it!


1

1+, 25 22 bytes 1:1(|1+":1+":1+":)()() ... EDIT: The boring solution is shorter.


2

Ruby, ><>, HQ9+, Befunge-93, 68 characters #9&1+.@.1*.?)2l0+aao}*3d' puts"\u0048ello World!"#.1*57;!?lo oa}*3d' "Hello World!" (Ruby) Relevant part of code: puts"\u0048ello World!" quine (><>) After colliding with the # mirror, both lines are read as string literals and printed with a newline between. 99 ...


1

Acc!!, 90 bytes N Count i while _%60-10 { _*10+_%60*50-2880+N } _/60 Count j while _-j { Write 92-_%2*45 } Try it online! With comments # Read a line of stdin, convert it to a decimal number, and store it in the accumulator N Count i while _%60-10 { _*10+_%60*50-2880+N } _/60 # Loop that many times Count j while _-j { # Output \ if accumulator mod 2 ...


2

Flurry, 32 bytes {{}{<{}(<><<>()>{})>}[(<>())()]} This is an anonymous function that takes an argument as a Church numeral and returns a Church numeral as output. You can test it with the interpreter as follows: $ ./Flurry -nin -c '{{}{<{}(<><<>()>{})>}[(<>())()]}{}' 9 362880 While the function ...


2

Lua, 63 bytes c,a,b=0,...for i=a,b do c=c+({('').gsub(i,1,0)})[2]end print(c) Try it online! Apparently, we can't use ... as a range for for. What a shame.


2

Whispers v2, 23 bytes +1 > 1 >> Output 3 >> 1 Try it online! or Try it online doubled Outputs 1 normally and 2 when doubled. How it works Normal Whispers only recognises lines that match one of a certain set of regexes. In the normal version, this reduces the program down to > 1 >> Output 3 (i.e. the first and last lines don't match ...


1

Integral, 6 Bytes v*)f)☼ Try it! Explanation v* "*" ) Push 10 f Repeat string 10 times )☼ Push 10 copies onto the stack Stack is joined with newlines & implicitly outputted


2

><>, 44 bytes |>:a%:1=&+&/&0 v&n;>~1+::{:})?! >v,a^!?)0:-\ The wrong tool for the job, as ><> knows nothing about decimal notation. Takes (b,a) on the stack.


2

Lua, 98 bytes s="s,i,p=s..'s=;load(s)(...)',-1,0while p do i,p=i+1,s:find(...,p+1,1)end print(i/98)"load(s)(...) Try it online! Ported Python answer to Lua. The problem with Lua string functions is that you can't accept user input for anything but string.find with truthy fourth argument. Anyone trying to golf this should test all magic characters ...


4

Pyth, 361 bytes This has too many unprintables for TIO, so here's the hexdump: 00000000: 746a 6b6a 4322 01bd bf32 7574 a357 55f7 tjkjC"...2ut.WU. 00000010: f4ca 74e0 9fbf 89f3 58ad 59c8 798b b009 ..t.....X.Y.y... 00000020: 60bc 0f8a 71f4 a90e da7b 61a6 6145 9a5b `...q....{a.aE.[ 00000030: 2f16 8968 611f 9b8d 75fb a9f0 0308 7d38 /..ha...u.....}8 ...


2

MAWP, 23 bytes 25W[25W[67W;1A]%52W;1A] Try it! Two nested loops doing almost the same thing


2

x86-16 machine code, 27 25 bytes Binary: 00000000: 33db 4a51 56ac a20c 018a c2d4 0ae0 f675 3.JQV..........u 00000010: 0203 da5e 594a 75eb c3 ...^YJu.. Listing: 33 DB XOR BX, BX ; clear BX running sum 4A DEC DX ; N = N - 1 (only multiples below N) N_LOOP: 51 PUSH CX ...


3

MAWP, 197 bytes Here's a funny solution. __________________________________________________________________________________________________________________________;;;;;;;;;;;;;;;;;;;;;;;;;;%%%%%%;;;;;;;;;;;;;;;;;;;;;;;;;;%%%%%%%;;;;;;;;;; MAWP almost exclusively uses alphanumeric characters to print values, so instead we spam the _(stack length) operator to ...


2

05AB1E, 66 bytes gÍF3£D¬gÍFε3£}`R«ćªćU«X.Sγ€Ù˜ÐнsθQsʒ0Ê}©gs-4Q®ü‚€OÄO0Q&ˆ€¦}\\¦D}¯O I'm 100% sure that I can reduce some bytes here, working on it :) Meanwhile, I'll post this basic idea. Explenation: gÍF3£D¬gÍFε3£}`R«ćªćU«X.Sγ€Ù˜ÐнsθQsʒ0Ê}©gs-4Q®ü‚€OÄO0Q&ˆ€¦D}\\¦}¯O `R«ćªćU«X.Sγ€Ù˜ÐнsθQsʒ0Ê}©gs-4Q®ü‚€OÄO0Q&ˆ ...


0

PHP, 101 bytes $a=array_count_values(array_map(strlen,preg_split('/[^A-Za-z]/',$argn,0,1)));arsort($a);echo key($a); Try it online! Drat PHP and it's super long function names again...


0

Arn, 15 bytes pIÔX╗▀‹·¬○¯vËa? Explained Unpacked: +\$v{$:{!v%}?1}1-> \ Fold with... + ...addition $ Filter with... v{ ...block with key of v $: Any operation { Block with key of _ ! Boolean not v% v modulo _ (implied) } ?1 Each element on second line of _ (implied) } ...


1

Python3, 304 301 299 296 275 249 221 185 178 168 157 140 bytes lambda l:any(all(sum((x in t)+9*(x==y)for x,y in zip(p,t))==int(t[4:])for t in l)for p in permutations('ABCDEFGH',4)) from itertools import* Lambda expecting input in the form of an array. Try it online! Or 156 bytes as a full python program with textual input/output: from itertools import* l=...


2

Arn, 8 bytes xõPÑ_=>$ Explained Unpacked: *v{_}\1=> \ Fold... * ...with multiplication after... v{ ...mapping with key of v... _ ...by replacing with input } End map 1 Literal one => inclusive range to... _ ...input, implied


1

Integral, 5 Bytes v↕♦▼e Try it! Explanation v↕ Multiply two items of the stack, to be evaluated ♦ Swap the top two items ▼ Decrement e Evaluate ↕ that many times


1

1+, 256 255 64 61 59 56 bytes (|11+"""*+""*+(A|";";";";";)(A)^"""**+;)(B|()()())(B)(B) I'm lazy. Pushes a newline and an asterisk, then simply output them, without any tricks. No loops because creating terminating loops in 1+ is painful. EDIT: -1 byte by reusing the constant 2. EDIT: -191 ...


Top 50 recent answers are included