New answers tagged

0 votes

I reverse the source code, you negate the input!

Knight, 5 bytes O P~O Try It Online! Try It Online reversed!
user avatar
  • 5,593
0 votes

I reverse the source code, you negate the input!

Ly, 3 bytes +0- Try it online! Forwards: ...
user avatar
  • 2,009
1 vote

Generate a Kirkman triple system

PARI/GP, 218 bytes ...
user avatar
  • 35.9k
2 votes

I reverse the source code, you negate the input!

sed, 14 bytes #//--/s;/-/^/s The code is only comment, which means the input is outputted unchanged. Attempt This Online! Reversed: ...
user avatar
  • 1,285
2 votes

I reverse the source code, you negate the input!

Alice, 11 bytes \ X'@ /I-O/ Try it online! !enilno ti yrT Operates entirely within ordinal mode. The negation is done by taking string symmetric difference ...
user avatar
  • 64.7k
2 votes

I reverse the source code, you negate the input!

Alice, 15 bytes /O\ /I@ @I/R\O/ Try it online! !enilno ti yrT Flattened Original I O@, reads from the input, output Reversed <...
user avatar
  • 1,798
0 votes

The inverse Collatz Conjecture

dc, 35 bytes [3*1+]0:s[1-2/]1:s[pd2%;sxd0<l]dslx Try it online!
user avatar
  • 451
1 vote

Are they collinear?

Vyxal, 4 bytes v-ÞḊ Try it Online! Outputs 0 for truthy and any other integer for falsy. Port of fireflame241's Jelly answer. ...
user avatar
  • 9,016
0 votes

I reverse the source code, you negate the input!

dc, 5 bytes dp-r0 Try it online!
user avatar
  • 451
1 vote

Anti-divisors of a number

Nibbles, 8 bytes (16 nibbles) >>|,$~-!=$*%@$~~ ...
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
  • 451
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,296
1 vote

Anti-divisors of a number

x86 64-bit machine code, 26 bytes 89 F1 51 8D 44 71 01 99 01 C9 F7 F1 58 83 FA 02 77 01 AB 91 E2 EC FF 4F FC C3 Try it online! Takes \$n\$ in ESI and writes the ...
user avatar
  • 7,296
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
1 vote

Are the numbers amicable?

Vyxal, 5 bytes ∆KUṘ⁼ Try it Online!
user avatar
  • 9,016
1 vote

Divisor reduction

Vyxal l, 5 bytes ≬KL-İ Try it Online! Flagless: Vyxal, 6 bytes ≬KL-İL Try it Online!
user avatar
  • 9,016
3 votes

Cartesian - polar conversion couple

Factor, 16 + 15 = 31 bytes [ rect> >polar ] Try it online! [ cis * >rect ] Try it online! ...
user avatar
  • 10.8k
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
  • 35.9k
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,050
0 votes

Find a Fixed Point

J, 3 bytes ^:_ Try it online! When a conjunction in J is missing an operand, it becomes an adjective. This program produces an adjective which takes as an argument ...
user avatar
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
0 votes

Find a Fixed Point

Vyxal, 1 byte Try it Online! Builtin lol
user avatar
  • 9,016
1 vote

Find a Fixed Point

dc, 30 bytes [pq][Smrd3Rd3Rxd3R=mLmlmx]dsmx Try it online! Takes as input the function in the form of a macro and initial value on the stack(pushed in that order). ...
user avatar
  • 451
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.3k
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,016
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,760
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,016
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.2k
4 votes

Cartesian - polar conversion couple

Mathematica, 18+20 = 38 bytes ToPolarCoordinates FromPolarCoordinates Try it online! For the ...
user avatar
  • 9,016
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,593
1 vote

Anti-divisors of a number

Perl 5 -n, 35 bytes //;map{abs($'%$_*2-$_)<2&&say}2..$_ Try it online! Uses a take on xnor's formula in his python ...
user avatar
  • 12.7k
1 vote

Output the nth Even Perfect Number

Haskell, 52 bytes ([n|n<-[1..],n==sum[d|d<-[1..div n 2],mod n d<1]]!!) Try it online! Starts at n = 0. Not particularly fast
user avatar
  • 451
1 vote

Anti-divisors of a number

lin, 33 bytes .#n.n.<1drop".n.+_ %.~2/ -2^1<".# Try it here! For testing purposes (use -i flag when running ...
user avatar
1 vote

Anti-divisors of a number

Haskell, 38 bytes h n=[m|m<-[2..n-1],abs(mod n m*2-m)<2] Try it online!
user avatar
  • 451
0 votes

What is the average of n, the closest prime to n, the square of n and the closest Fibonacci number to n?

Haskell, 150 bytes ...
user avatar
  • 451
4 votes

Anti-divisors of a number

APL (Dyalog Classic), 23 bytes {1↓⍵{(2>|⍵-2×⍵|⍺)/⍵}⍳⍵} Try it online! Usage: ...
user avatar
  • 71
1 vote

Anti-divisors of a number

Charcoal, 16 bytes NθIΦ…²θ‹↔⁻⊗﹪θιι² Try it online! Link is to verbose version of code. Explanation: ...
user avatar
  • 146k
1 vote

Anti-divisors of a number

C (gcc), 58 52 bytes m;f(n){for(m=1;++m<n;)(n%m*2-m)/2||printf("%d ",m);} Try it online! Saved 6 bytes thanks to the suggestion of porting Kevin's ...
user avatar
  • 18.6k
2 votes

Anti-divisors of a number

Java 8, 69 64 bytes n->{for(int i=1;++i<n;)if((n%i*2-i)/2==0)System.out.println(i);} -5 bytes thanks to @Deadcode Outputs the results to STDOUT on separated ...
user avatar
1 vote

Anti-divisors of a number

MathGolf, 13 bytes ╒╞g{_k\%∞-±2< Try it online. Explanation: ...
user avatar
3 votes

Anti-divisors of a number

05AB1E, 8 bytes L¦ʒ%·yα! Try it online or verify all test cases. Explanation: ...
user avatar
3 votes

Anti-divisors of a number

Desmos, 40 bytes l=[1...n][2...] f(n)=l[-2<2mod(n,l)-l<2] Try It On Desmos! Try It On Desmos! - Prettified
user avatar
  • 5,593
5 votes

Anti-divisors of a number

Knight, 40 34 bytes -6 bytes thanks to @Bubbler by looping backwards ;=i=pE P W<1=i-iT&>4^-*2%p i i 2Oi Try It Online! Outputs each anti-divisor in a ...
user avatar
  • 5,593
3 votes

Delannoy numbers

K (ngn/k), 18 bytes {0/x(+':+\)/1,y#1} Try it online! Port of my APL answer that does not use the binomial coefficient built-in. See the linked answer for the ...
user avatar
  • 64.7k

Top 50 recent answers are included