Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 32352

The challenge involves mathematics in some central way. Also consider using more specific tags, listed in the tag wiki info.

4 votes

Approximate the plastic number

Octave, 50 bytes @(n)char(digits(n)*0+vpasolve(sym('r^3-r-1'))(1)); Try it online! Defines an anonymous function, withn the desired number of digits of output. This answer abuses that digits re …
Sanchises's user avatar
  • 9,526
1 vote

What is the standard scratch?

MATL, 7 bytes 3:5*si- Try it online! Input vector times range 3:5 minus the second input. Contrary to my Octave answer, it's actually shorter to have the inputs as two separate inputs, and shorter …
Sanchises's user avatar
  • 9,526
3 votes

What is the standard scratch?

Octave, 14 bytes @(a)[3:5 -1]*a Try it online! About twice as long as the MATL answer. I initially literally ported this to MATL, but it turned out iY* is longer than just *s. Note that the inpu …
Sanchises's user avatar
  • 9,526
1 vote

Calculate the Hafnian as quickly as possible

Octave This is basically a copy of Dennis' entry, but optimized for Octave. The main optimization is done by using the full input matrix (and its transpose) and recursion using only matrix indices, r …
Sanchises's user avatar
  • 9,526
4 votes

Calculate the vector component

MATL, 2 bytes Y\ Try it online! Least squares approach such as used in the APL answer.
Sanchises's user avatar
  • 9,526
11 votes

Verify Eigenpairs

MATL, 7 bytes *i2GY*= Inputs in order: l,v,A. Explanation: * % implicitly get l and v, multiply. i % get A 2G % get second input, i.e., v again Y* % perform matrix multiplication = % test equality …
Sanchises's user avatar
  • 9,526
5 votes

Verify Eigenpairs

MATLAB, 16 bytes @(A,v,l)A*v==v*l Rather trivial answer. Defines an anonymous function taking the inputs, and calculates element-wise equality of the resulting vectors. A single zero in a logical arr …
Sanchises's user avatar
  • 9,526
7 votes

Calculate the n-th iterate of a polynomial for a specific value; fⁿ(x)

Octave, 49 bytes @(p,x,n)(f=@(r,m){@()p(r(r,m-1)),x}{~m+1}())(f,n) Try it online! Or, taking coefficients: Octave, 75 57 bytes @(p,x,n)(f=@(f,n){@()polyval(p,f(f,n-1)),x}{~n+1}())(f,n) Try it onli …
Sanchises's user avatar
  • 9,526
1 vote

Calculate the n-th iterate of a polynomial for a specific value; fⁿ(x)

MATL, 11 bytes ii:"ZQ6Mw]& Try it online! Slightly less interesting than my Octave answer, although I think there's some clever juggling of inputs to make sure n=0 works as expected.
Sanchises's user avatar
  • 9,526
3 votes

Approximate the Dottie number to arbitrary precision

Octave, 42 bytes @(n)digits(n)*0+vpasolve(sym('cos(x)-x')); Try it online! Pretty much a duplicate of my answer to Approximate the Plastic Number, but somewhat shorter due to more relaxed requir …
Sanchises's user avatar
  • 9,526
2 votes

Infer geometric sequences

Octave, 38 35 bytes @(a,b,c)exp(log(a):log(b/a):log(c)) Try it online! Turns out @LuisMendo's MATL approach also saves 3 bytes in Octave, despite repeating log three times.
Sanchises's user avatar
  • 9,526
1 vote

Infer geometric sequences

MATL, 17 bytes t:,qtiw^w]x/tb>~) Try it online! Just to get the ball rolling in MATL. I can't imagine there isn't a less verbose way of solving this.
Sanchises's user avatar
  • 9,526
1 vote

Integer logarithms

Simple arbitrary base conversion to avoid using floating point math. …
Sanchises's user avatar
  • 9,526
3 votes

Sum \$\text{Square}^2\$

MATL, 9 bytes Z\UsX^tk= Try it online! As simple as it gets Z\ % Divisors of (implicit) input U % Square s % Sum X^ % Square root t % Duplicate this value k= % Is it equal to its rounded value …
Sanchises's user avatar
  • 9,526
52 votes
3 answers
6k views

Quiche Lorraine [closed]

Since it was Pi day recently, I have noticed a number of challenges that ask you to calculate pi. Of course, a quiche lorraine is not quite a pie (you can claim a Bonus Score¹ of +1 if you guessed th …
Sanchises's user avatar
  • 9,526

15 30 50 per page