New answers tagged

0 votes

Addition/Multiplication table generator

Vyxal, 18 bytes ɾ?\vdpĖ:vvS$fGL↲Ṡ⁋ Try it Online! Without strict IO formats, the whole :vvS$fGL↲Ṡ⁋ could be omitted
user avatar
  • 9,066
1 vote

1, 2, Fizz, 4, Buzz

D, 90 bytes import std;void main(){foreach(i;1..101)max("FizzBuzz"[i%3?4:0..i%5?4:8],i.text).writeln;} Try it online!
user avatar
1 vote

The vanilla factorial challenge

Regex 🐇 (RME / PCRE2 v10.35+), 12 bytes ^((?*x+)x)*$ Attempt This Online! - PCRE2 Try it on replit.com! - RegexMathEngine, in ...
user avatar
  • 9,610
1 vote

The vanilla factorial challenge

Carbon, 53 bytes fn f(x:i32)->i32{return if(x==0)then 1else x*f(x-1);} Try it Online! Here is a full program for testing at the above site: ...
user avatar
  • 3,347
1 vote

The vanilla factorial challenge

StackCell, 14 bytes Uses this input format and this output format The below code uses the Unicode control character glyphs [U+24XX] to represent ASCII unprintable control characters embedded in the ...
user avatar
1 vote

The vanilla factorial challenge

Knight, 26 bytes ;=yT;=x+0P;W=x-xT=y*+xTyOy Try it online!
user avatar
1 vote

Cryptic Multiplications

Python 3, 128 bytes ...
user avatar
1 vote

How many steps does it take from n to 1 by subtracting the greatest divisor?

dc, 39 bytes 0[1+rd[d3R1-d_4R%0<t]dstxr-d_3R1<l]dslx Try it online! Takes input as number on top of stack, and leaves result as top of stack
user avatar
  • 475
1 vote

Cartesian - polar conversion couple

R, 30+24=54 bytes Cartesian to polar, 30 bytes \(x,y)c(Mod(z<-x+1i*y),Arg(z)) Attempt This Online! No imaginary numbers for +2: ...
user avatar
  • 12.1k
2 votes

Cartesian - polar conversion couple

x86 64-bit machine code, 23 + 13 = 36 bytes D9 06 D9 07 D9 F3 D9 07 D8 C8 D9 06 D8 C8 DE C1 D9 FA D9 1E D9 1F C3 D9 07 D9 FB D8 0E D9 1F D8 0E D9 1E C3 Try it ...
user avatar
  • 7,326
2 votes

Cartesian - polar conversion couple

05AB1E (legacy), 7 + 22 = 29 bytes Polar to Cartesian (7 bytes): .¾¹.½‚* Loose inputs in the order \$\phi,r\$; outputs as a pair \$[x,y]\$. Try it online or verify ...
user avatar
0 votes

Iterated partial sums

PARI/GP, 31 bytes f(a,n)=Vec(Ser(a)/(1-x)^n+.5)\1 Attempt This Online! Converts the list to a power series, divides it by \$(1-x)^n\$, and then converts it back to ...
user avatar
  • 36.1k
1 vote

Iterated partial sums

Vyxal, 2 bytes Try it Online!
user avatar
  • 9,066
3 votes

Cartesian - polar conversion couple

Factor, 16 + 15 = 31 bytes [ rect> >polar ] Try it online! [ cis * >rect ] Try it online! ...
user avatar
  • 10.9k
1 vote

Cartesian - polar conversion couple

PARI/GP, 34 + 24 = 58 bytes f(x,y)=[abs(z=x+I*y),if(z,arg(z))] g(r,a)=r*[cos(a),sin(a)] Attempt This Online!
user avatar
  • 36.1k
8 votes

Cartesian - polar conversion couple

Python, 49 + 48 = 97 bytes -2 thanks to @Seb lambda r,a,n=9e9:((x:=r*(a/n-1j)**n).real,x.imag) Attempt This Online! lambda x,y,n=1e-9:(abs(c:=x+1j*y),(c**n).imag/n) Doesn't use any libraries, no exp, ...
user avatar
  • 8,180
1 vote

Cartesian - polar conversion couple

SageMath, 69 68 bytes lambda x,y:((x^2+y^2)^.5,arctan2(y,x)) lambda r,t:(r*cos(t),r*sin(t)) Try it online! Adjusted score correctly thanks to Steffan. Saved a ...
user avatar
  • 18.6k
2 votes

Cartesian - polar conversion couple

MATLAB/Octave, 9+9=18 bytes, builtins Simple builtins, convert between (x,y) and (angle[radians],radius) Cartesian to polar: @cart2pol Try it online! Polar to ...
user avatar
3 votes

Cartesian - polar conversion couple

J 10 (5 + 5) to polar, 5 bytes *.@j. Try it online! to cartesian, 5 bytes +.@r. Try it online! Both of these amount to one ...
user avatar
  • 28.6k
1 vote

Cartesian - polar conversion couple

lin, 28 + 17 = 45 bytes To Polar ([a b] -> [a b]): "2^.$_ +.5^"".$_.~ atant", Q To Cartesian (...
user avatar
5 votes

Cartesian - polar conversion couple

Wolfram Language (Mathematica), 14+11=25 bytes AbsArg[#+I#2]& AngleVector Try it online! Input [x,y]/...
user avatar
  • 16.3k
2 votes

Cartesian - polar conversion couple

Python, 48+48 = 96 bytes lambda*t:(hypot(*t),atan2(*t)) from math import* Attempt This Online! -4 bytes thanks to xnor. lambda a,b:(a*cos(b),a*sin(b)) from math import* Attempt This Online!
user avatar
  • 9,066
1 vote

Cartesian - polar conversion couple

C (gcc), 88 bytes C(x,b,t)float*x,t;{t=x[1];x[1]=b?*x*sin(t):atan(t/(*x));*x=b?*x*cos(t):sqrt(*x**x+t*t);} 86 bytes 2 bytes can be saved by inverting the order of ...
user avatar
  • 2,830
2 votes

Cartesian - polar conversion couple

APL (Dyalog Classic), 22 + 15 = 37 bytes Cartesian to Polar: 22 bytes {(.5*⍨+/⍵⍺*2),¯3○⍵÷⍺} Polar to Cartesian: 15 bytes ...
user avatar
  • 71
3 votes

Cartesian - polar conversion couple

Jelly, 7 + 6 bytes = 13 Polar to Cartesian: ×ıÆe×Æi A dyadic Link accepting \$\theta\$ on the left and \$r\$ on the right that yields a list \$[x, y]\$. Try it ...
user avatar
1 vote

Cartesian - polar conversion couple

Vyxal, 10 + 7 = 17 bytes Cartesian to Polar, 10 bytes ²∑√?Ṙƒ/∆T" Try it Online! Polar to Cartesian, 7 bytes ⁰₍∆c∆s* Try ...
user avatar
  • 9,066
4 votes

Cartesian - polar conversion couple

Pip -p, 10 + 12 = 22 bytes Polar to Cartesian: a*[CObSIb] Takes angle in radians. Outputs a list containing x and y. Try it ...
user avatar
  • 33.3k
4 votes

Cartesian - polar conversion couple

Mathematica, 18+20 = 38 bytes ToPolarCoordinates FromPolarCoordinates Try it online! For the ...
user avatar
  • 9,066
4 votes

Cartesian - polar conversion couple

Desmos, 33+19 = 52 score Both functions take in two arguments representing either polar or Cartesian coordinates (depending on which function is being used), and returns a list representing the ...
user avatar
  • 5,790
0 votes

The plus-minus sequence

C (gcc), 62 bytes int f(int a,int b){for(;1;b=(a+=b)-2*b)printf("%d %d\n",a,b);} Try it online! Theoretically outputs indefinitely, however, it only ...
user avatar
  • 475
1 vote

Cryptic Multiplications

Charcoal, 36 bytes FXχLθFEXχLη⪫⟦ικ×ικ⟧¶⊞υEκ⌕κλI№υ§υI⁺θη Try it online! Link is to verbose version of code. Explanation: FXχLθ ...
user avatar
  • 146k
3 votes

Cryptic Multiplications

05AB1E, 20 bytes €g°Ý`âIšεDPª»DSk»}ć¢ Port of @Steffan's Vyxal answer, but with less convenient builtins. Try it online or verify (almost) all test cases (the last ...
user avatar
1 vote

Cryptic Multiplications

Ruby, 108 bytes ->a,b{[*0..9].permutation.map{|c|"#{a}*#{b}==#{a*b}".tr('0-9',c*'')}.uniq.count{|c|/^0|\*0|=0/!~c&&eval(c)}} Try it online!
user avatar
  • 18.3k
4 votes

Cryptic Multiplications

Knight, 416 219 bytes ...
user avatar
  • 9,066
4 votes

Cryptic Multiplications

Vyxal s, 17 bytes vL↵ʀΠƛ?"ƛΠJṄ:vḟ;≈ Try it Online! This would flaglessly be 19 bytes. It can be shorter flagless, though: ...
user avatar
  • 9,066
3 votes

Cryptic Multiplications

Jelly,  20 18  17 bytes Thanks to Steffan for a speed up! (‘×⁵ -> æċ⁵) and a byte that ended up saving elsewhere! Save of 2 ...
user avatar
7 votes

Cryptic Multiplications

K (ngn/k), 41 36 bytes -5 bytes inspired by Jonathan Allan's answer. {#*={.(=`k@x,*/x)_" "}'?+x,'!10*1+x} Try it online! The last 4 cases are too slow to ...
user avatar
  • 55k
3 votes

Cryptic Multiplications

JavaScript (ES6),  127  120 bytes Expects (p)(q), as strings. ...
user avatar
  • 169k
1 vote

Additive Persistence

Ly, 21 bytes 0s+1[pSy,![lu;]&+l`s] Try it online! A pretty straight forward interpretation of the challenge rules this time. ...
user avatar
  • 2,009
1 vote

Summation from a to b

Factor + math.unicode, 12 bytes [ [a,b] Σ ] Try it online! Interesting tidbit: sum (and ...
user avatar
  • 10.9k
1 vote

Additive Persistence

Knight, 54 bytes ;=iP;=r 0;W<1Li;=s 0;Wi;=s+sA Ai=iGi 1Li;=i+""s=r+1rOr Try it online!
user avatar
  • 9,066
1 vote

Strange Addition

Knight, 45 bytes ;=aP;=bP Wa;O+A I>a bAaAb"\";=aGa 1La=bGb 1Lb Try it online! Takes two zero-padded numbers (it works with spaces as well).
user avatar
  • 9,066
1 vote

Summation from a to b

Knight, 19 bytes O/*+E=aP=bP+1-b a 2 Try it online! Uses the formula (a+b)*(b-a+1)/2.
user avatar
  • 9,066
0 votes

Average Two Letters

Knight, 14 bytes O A/+A P A P 2 Try it online!
user avatar
  • 9,066
2 votes

The vanilla factorial challenge

Brachylog, 1 byte Try it online! Also works with a fixed output and an unknown input, with decent performance. No built-in, 3 bytes ...
user avatar
  • 36.6k
2 votes

The vanilla factorial challenge

JavaScript, 19 bytes f=n=>n?f(n-1n)*n:1n 2 bytes longer than the other JS answers, but can safely calculate as high as 11190! instead of 18!, with anything ...
user avatar
  • 331
3 votes

The vanilla factorial challenge

Knight, 25 bytes ;=x+=y 1P;W=x-x 1=y*x yOy Try it online! Ungolfed: ...
user avatar
  • 64.8k
1 vote

The vanilla factorial challenge

Knight, 28 bytes ;;;=xP=y 1W<0=x-x 1=y*y+1xOy Try it online!
user avatar
  • 9,066
1 vote

Add two numbers

Quipu, 11 bytes \/ \/ ++ /\ Attempt This Online! Explanation Each side-by-side pair of characters is a command ("knot"), and execution proceeds from top ...
user avatar
  • 33.3k
2 votes

Add two numbers

Trianguish, 15 bytes 00000000: 1020 c301 a050 c008 b105 0c01 0710 19 Try it online!
user avatar
  • 9,066

Top 50 recent answers are included