New answers tagged

0

Hexagony, 14 bytes ,{,:'2<'+{*/@; Try it online! Linear control flow: ,{,'+{*2':;@ Wasting 2 characters for control-flow redirection, and does not reuse the duplicate , and {. With enough effort, this probably can be optimized.


1

Pyth, 5 bytes C.OCM Try it online!


1

Husk, 2 bytes ←p Try it online!


2

Vyxal, 1 byte ′ Try it online! There's a builtin just for this.


0

Python 3, 30 27 bytes f=lambda n:1>>n or n*f(n-1) Try it online!


1

Lua (67 bytes) function x(t,n)return load("return "..table.concat(t,"+",1,n))()end Explanation: table.concat(t,"+",1,n) gives the string formed by concatenation of elements of t from 1 to n using + as connector, i.e. t[1]+...+t[n]. load(<string>)(), as its name suggests, loads a string to be executed as a function. In ...


1

Husk, 4 3 bytes Saved 1 byte thanks to Dominic Van Essen !¡∫ Try it online! !¡∫ ¡ Repeatedly apply the following function to the first argument, making an infinite list ∫ Cumulative sum (one cycle) ! Index into this list with the second argument


0

BRASCA, 15 bytes xig[:1-]x[*$]xn Explanation xig - Remove LF from implicit STDIN, convert to numbers and concatenate [:1-] - Generate a sequence from N to 0 on the stack x - Remove the 0 [*$] - Multiply it all together $n - Bring the number to the front and output it ...


0

Java, 45 chars char c(char a,char b){return(char)((a+b)/2);} Try it online!


2

convey, 16 bytes }>-1 1@"v ^*",{ Try it online! Loops over the input value until it reaches 0. There may be a shorter way using the indices command (/.), but it seems to take up more logic than I want. Since the interpreter includes a handy-dandy gif maker, you can even see it in action.


1

Vyxal, 13 bytes 0?(»Þ([Ḇ»↜Œ∑∫ Try it Online! A port of the 05AB1E answer Explained 0?(»Þ([Ḇ»↜Œ∑∫ 0? # Push 0 followed by the input number ( # Input number of times: »Þ([Ḇ» # Push the number 433544355 ↜Œ # And get the indexes corresponding to the numbers in the second last item on the stack ∑...


0

Haskell, 45 bytes 1?x=(x+) n?x=(!!)$iterate((n-1)?x)$signum$n-2 Try it online! Call it with (n?a)b. Haskell, 51 bytes (1?a)b=a+b (2?_)0=0 (_?_)0=1 (n?a)b=(n-1)?a$n?a$b-1 Try it online! Copied straight from the hyperoperation formula on Wikipedia. Call it with (n?a)b.


2

Python 3, 88 85 77 73 bytes i=0 exec("i+=1;print(i%3*i%5and i or(i%3<1)*'Fizz'+(i%5<1)*'Buzz');"*100) Try it online!


1

05AB1E (legacy), 6 bytes ζÆ(I>M Port of @Dennis's Jelly answer, so make sure to upvote him as well! The I/O is also in the same format, except with the input wrapped inside a list instead of three loose inputs: \$[Z,Y,X]\$, with little-endian digit order, using the digit \$0\$ for unary. Try it online or verify all test cases. The new 05AB1E version ...


0

05AB1E, 2 bytes zm Try it online! zm # full program # implicit input... m # to the power of... z # 1 divided by... # implicit input # implicit output


2

Canvas, 31 bytes A2^{w3%0≡Fizz×y5%0≡Buzz×+:?O]yO Try it here! Okay seriously guys why is it that both ascii-art focused languages didn't already have a FizzBuzz? This uses my favourite FizzBuzz approach found in the Vyxal answer.


0

Perl 5 -MList::Util=sum -a, 44 bytes say sum(@F[$_..$_+$,-1])/$,for 0..@F-($,=<>) Try it online!


1

x86 Machine Code, 20 bytes 86 89 D9 31 C0 03 44 8F FC E2 FA 31 D2 F7 F3 AB 39 F7 72 ED C3 The above bytes define a function that calculates the moving average of a list, modifying the elements of the list in-place. It assumes that the list is a contiguous array of integer elements. The function takes the following inputs in registers edi: the address of ...


0

Prolog (SWI), 84 bytes g([],A,A). g([H|T],E,O):-M is mod(H,2),F is E+1-M,P is O+M,g(T,F,P). f(X):-g(X,0,0). Try it online! Actually, I don't know how to make print results in TIO (there'll just be a warning if a query fails), so try it in SWISH. Please just don't make any changes to it. g\2 accepts a list, the number of even elements found so far, and the ...


1

Nim, 105 101 100 bytes import math,random randomize() let t=TAU.rand u=2.0.rand-1 v=sqrt(1-u*u) echo [t.cos*v,t.sin*v,u] Try it online! Uses the third method with a bit of substitution: $$u = \cos(\phi) = 2j - 1$$ $$v = \sin(\phi) = \sqrt{1-u^2}$$


0

Husk, 3 bytes mAX Try it online! Output as a list of rationals.


1

FALSE, 86 bytes [\100*\/$100$@\/*-0=]m:1[$100>~][0\$3m;![\%1\"Fizz"]?$5m;![\%1\"Buzz"]?\0=[$.]?10,1+]# Try it online! Explanation [\100*\/$100$@\/*-0=]m: Define Modulo Function [\100*\/ Divide number * 100 by the divisor to get decimals $100$@/* Get truncated result -0= Subtract to get decimal, if equal to 0, then the ...


0

Stax, 8 bytes ä;ªÜé▐ßó Run and debug it Uncompressed is 9 bytes, still beating CJam(with the same method). Explanation |T{Ze*m|M |T permutations of input { m mapped to: Z tuck a zero under the string e evaluate the string * multiply the top two elements |M get the maximum of the mapped list


0

Jelly, 12 bytes Œ!ŒṖ€Ṗ€ẎḌP€Ṁ Try it online! ಠ_ಠ Tied with CJam. Takes input as a list of values, +2 bytes to input as space-separated How it works Œ!ŒṖ€Ṗ€ẎḌP€Ṁ - Main link. Takes a list L on the left Œ! - Permutations of L ŒṖ€ - Partitions of each Ṗ€ - Remove the last one from each Ẏ - Join into one list Ḍ -...


Top 50 recent answers are included