Questions tagged [math]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
44 views

Find the distance between 2 points in a 3d space (x,y,z) [duplicate]

Your challenge is to create the shortest code that can achieve the above problem given 6 coordinates (x1,y1,z1) (x2,y2,z2) In python 3, this can be used: (i think im correct hopefully) ...
user avatar
  • 3,049
15 votes
10 answers
780 views

AoCG2021 Day 14: Adjusting dancing program's period

Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2017 Day 16. I'm using the wording from my Puzzling SE puzzle based on the same AoC challenge instead of the ...
user avatar
  • 64.8k
15 votes
7 answers
736 views

Are these the basis vectors?

A basis of a vector space \$V\$ is a set of vectors \$B\$ such that every vector \$\vec v \in V\$ can be uniquely written as a linear combination of the vectors in \$B\$. In other words, let \$B = \{\...
user avatar
21 votes
30 answers
3k views

Total cost of The 12 Days of Christmas

Introduction I have decided that this Christmas, as a "present" to a friend, I wish to purchase the things described in the classic song "The 12 Days of Christmas". The only ...
user avatar
  • 3,410
4 votes
3 answers
568 views

How to shorten the Python code? Part II

Code Python 3, 245 bytes ...
user avatar
  • 2,547
20 votes
1 answer
502 views

How to solve the LCM in 50 bytes of Python

I've recently stumbled upon a Russian site called acmp.ru, in which one of the tasks, HOK, asks us to find the LCM of two positive integers. The full statement, translated to English is as follows: ...
user avatar
18 votes
21 answers
2k views

Digit small numbers

A digit small number is a positive integer \$n\$ such for any two numbers that multiply to \$n\$, their total number of digits is more than the digits in \$n\$. In otherwords: there are no two ...
user avatar
  • 89.4k
28 votes
11 answers
2k views

Infinite ordinals from a well-ordering

Your task is to write a short program that represents a large (infinite) ordinal, using a well-ordering of the set of positive integers. Your program will take two different positive integers and ...
user avatar
  • 6,765
1 vote
2 answers
104 views

When the result will reach the people? [closed]

Assume the result of an exam has been published. After 5 minutes, First person knows the result. In next 5 minutes, new 8 persons know the result, and in total 9 know it. Again after 5 minutes, new 27 ...
user avatar
  • 169
13 votes
9 answers
997 views

Bijective meets mixed base

Background A bijective base \$b\$ numeration, where \$b\$ is a positive integer, is a bijective positional notation that makes use of \$b\$ symbols with associated values of \$1,2,\cdots,b\$. ...
user avatar
  • 64.8k
16 votes
19 answers
1k views

Find the k-th order summary of a number

Background The summary of a non-negative integer \$n\$ is the concatenation of all digits that appear in \$n\$ in increasing order, with each digit being preceded by the number of times it appears in \...
user avatar
  • 6,609
8 votes
27 answers
2k views

How long is the number in this base?

Given a positive integer \$n\$ and another positive integer \$b\$ (\$1 < b < 36\$), return the number of digits/length of \$n\$ in base \$b\$ ...
user avatar
  • 113
22 votes
9 answers
2k views

Bird's Algorithm for Computing Determinants

There is a division-free algorithm for computing determinants published by R.S.Bird in 2011 that uses only matrix multiplications. Given a \$n×n\$ matrix \$X\$, the matrix \$Y=μ(X)\$ is another \$n×n\$...
user avatar
1 vote
0 answers
84 views

Make me equal to 24 [duplicate]

Based on this game. Description : Based on Wikipedia's description. The 24 Game is an arithmetical card game in which the objective is to find a way to manipulate four integers so that the end result ...
user avatar
  • 329
8 votes
4 answers
584 views

Solve linear equations over the integers

All variables in this question are integer valued. Input 4 integers w, x, y, z. They can be positive or negative and will be less than 1048576 in absolute value. Output The general solution to the ...
user avatar
12 votes
7 answers
1k views

Fibonacci-like gap formula

Background The recurrence of the Fibonacci sequence is defined as $$ f(n+2) = f(n+1) + f(n) $$ From this recurrence alone, the following gap formulae (recurrences relating three terms with certain ...
user avatar
  • 64.8k
15 votes
14 answers
2k views

Inverse n-bonacci sequence

We all know about the Fibonacci sequence. We start with two 1s and keep getting the next element with the sum of previous two elements. n-bonacci sequence can be defined in similar way, we start with <...
user avatar
  • 169
14 votes
13 answers
2k views

Find the smallest solution for this simple equation

Input 4 integers w, x, y, z from the range -999 to 999 inclusive where none of the values is 0. Output 4 integers a, b, c, d so that aw + bx + cy + dz == 0 where none of the values is 0. Restrictions ...
user avatar
21 votes
9 answers
1k views

Self-referential triangle sequence

Output the flattened version of the sequence A297359, which starts like the following: ...
user avatar
  • 64.8k
15 votes
7 answers
3k views

Make S + S + ... + S as Large as Possible!

Let \$S \subset \mathbb N_{\geq0}\$ be a subset of the nonnegative integers, and let $$ S^{(k)} = \underbrace{S + S + \dots + S}_{k\ \textrm{times}} = \{ a_1 + a_2 + \dots + a_k : a_i \in S\}. $$ For ...
user avatar
  • 8,117
19 votes
12 answers
2k views

How many values of this type?

Background The number of values for a given type is called the cardinality of that type, and that of type T is written as |T|. Haskell and a few other languages ...
user avatar
  • 64.8k
21 votes
2 answers
775 views

Lean golf: Pascal vs. Fibonacci

The Pascal's triangle and the Fibonacci sequence have an interesting connection: Source: Math is Fun - Pascal's triangle Your job is to prove this property in Lean theorem prover (Lean 3 + mathlib). ...
user avatar
  • 64.8k
24 votes
2 answers
2k views

∀ a b. a + b = b + a

This question is a part of the lean LotM. A ring is a type of structure that takes the rules of addition and multiplication we are familiar with and abstracts them, so we can reason about them. To do ...
user avatar
  • 89.4k
19 votes
13 answers
2k views

The Area of Rectangles

Getting the area covered by a rectangle is really easy; just multiply its height by its width. However in this challenge we will be getting the area covered by multiple rectangles. This is equally ...
user avatar
  • 89.4k
24 votes
62 answers
3k views

Implement the hyperfactorial

The objective Given the non-negative integer \$n\$, output the value of the hyperfactorial \$H(n)\$. You don't have to worry about outputs exceeding your language's integer limit. Background The ...
user avatar
  • 349
3 votes
7 answers
662 views

Multiplication for geometric algebra

The basis vectors for geometric algebra are $$(e_0=1), e_1, e_2,\dots,e_n$$ They all square to 1 (we do not consider vectors which square to -1 or zero) $$e_i \cdot e_i = 1$$ They are associative and ...
user avatar
  • 47
1 vote
0 answers
168 views

Pythagoras' Golfing Grid [closed]

Recently, I created a binary word search that got me working with grids. It was fun, so I wanted to create some more similar content. Meet Pythagoras' Golfing grid: Each of ...
user avatar
6 votes
18 answers
855 views

Written Word Equation

Word equations, but not as you know it! Given a sentence which will include two numbers, numerically, and a spelt operator, in the order seen in the examples, your goal is to give the numerical answer ...
user avatar
  • 1,682
3 votes
7 answers
726 views

Yet another coin flipping problem

Problem Starting with a set of 10 coins at the start where all coins are tails up, and given n number of integers \$x_1, x_2, x_3... x_n\$ representing n rounds of coin flipping. At each round, we ...
user avatar
  • 141
20 votes
12 answers
1k views

Minimally prepend numbers to get a symmetric Young diagram

Background A Young diagram is a diagram that represents a nonincreasing sequence of positive integers using left-justified rows of squares. As an example, 5, 4, 1 ...
user avatar
  • 64.8k
12 votes
16 answers
833 views

Generate all \$3\times 3\$ magic squares

Though challenges involving magic squares abound on this site, none I can find so far ask the golfer to print / output all normal magic squares of a certain size. To be clear, a normal magic square of ...
user avatar
  • 223
12 votes
8 answers
1k views

Boustrophedon transform

Related: Boustrophedonise, Output the Euler Numbers (Maybe a new golfing opportunity?) Background Boustrophedon transform (OEIS Wiki) is a kind of transformation on integer sequences. Given a sequence ...
user avatar
  • 64.8k
13 votes
2 answers
504 views

Is this an interval graph?

Background An interval graph (Wikipedia, MathWorld, GraphClasses) is an undirected graph derived from a set of intervals on a line. Each vertex represents an interval, and an edge is present between ...
user avatar
  • 64.8k
15 votes
3 answers
253 views

Bijection between \$ \mathbb N \$ and at-most-\$n\$-ary trees

Background Related: a golflang theory I posted in TNB a while ago At-most-\$n\$-ary trees are rooted trees where each internal node has between 1 and \$n\$ children (inclusive). Two trees are ...
user avatar
  • 64.8k
13 votes
4 answers
584 views

Maximal hexagonal dot pattern

Challenge Imagine a hexagonal grid as shown below. Let's call such a grid has size \$n\$ if it has \$n\$ dots on one side. The following is one of size 3: ...
user avatar
  • 64.8k
13 votes
1 answer
335 views

Flatten a parabola keeping the distances between points along the curve constant

Background Math SE's HNQ How to straighten a parabola? has 4,000+ views, ~60 up votes, 16 bookmarks and six answers so far and has a related companion HNQ in Mathematica SE How to straighten a curve? ...
user avatar
  • 511
5 votes
5 answers
230 views

Potential nonzero entries in an irregular sequence

Background A338268 is a sequence related to a challenge by Peter Kagey. It defines a two-parameter function \$T(n,k)\$, which counts the number of integer sequences \$b_1, \cdots, b_t\$ where \$b_1 + \...
user avatar
  • 64.8k
16 votes
19 answers
1k views

Compare positions of integers in this sequence

A001057 is one way to represent an integer as a natural number. It lists them according to the following pattern: 0, 1, -1, 2, -2, 3, -3, 4, -4, ... In this ...
user avatar
11 votes
20 answers
2k views

Third Stirling numbers of the second kind

\$\left\{ n \atop k \right\}\$ or \$S(n, k)\$ is a way of referring to the Stirling numbers of the second kind, the number of ways to partition a set of \$n\$ items into \$k\$ non-empty subsets. For ...
user avatar
8 votes
4 answers
324 views

Hexagonal section numbers

Introduction Let's draw some regular hexagons formed by hexagonal tiles, marking the vertices of the tiles with dots. Then we will count the number of dots. ...
user avatar
  • 64.8k
21 votes
10 answers
2k views

Is this a Jordan matrix?

Background A Jordan matrix is a block-diagonal matrix where each block on the diagonal has the structure of $$ \begin{bmatrix} \lambda & 1 & 0 & \cdots & 0 \\ 0 &...
user avatar
  • 64.8k
5 votes
3 answers
155 views

Is this an ordinal transform? [duplicate]

Related: What's my telephone number? which asks to calculate the terms of A000085, the number of possible ordinal transforms of length n. Background Ordinal transform is a transformation on an integer ...
user avatar
  • 64.8k
20 votes
21 answers
3k views

Implement the Torian

The Torian, \$x!x\$, of a non-negative integer \$x\$ can be recursively defined as $$ x!0 = x \\ x!n = \prod^x_{i=1} i!(n-1) = 1!(n-1) \times 2!(n-1) \times \cdots \times x!(n-1) $$ The Torian is then ...
user avatar
10 votes
2 answers
345 views

Greatest Common Gaussian Divisor

Gaussian integers are complex numbers \$x+yi\$ such that \$x\$ and \$y\$ are both integers, and \$i^2 = -1\$. The norm of a Gaussian integer \$N(x+yi)\$ is defined as \$x^2 + y^2 = |x+yi|^2\$. It is ...
user avatar
13 votes
2 answers
276 views

Number of distinct shadow transforms

Background Shadow transform of a 0-based integer sequence \$a(n)\$ is another 0-based integer sequence \$s(n)\$ defined with the following equation: $$ s(n) = \sum_{i=0}^{n-1}{(1 \text{ if } n \text{ ...
user avatar
  • 64.8k
1 vote
4 answers
195 views

Chasing the car [closed]

Imagine you are sitting at a park. Suddenly your car gets hijacked and being driven in different directions. Here are the directions, arrows show which direction goes towards where: ...
user avatar
  • 421
17 votes
10 answers
606 views

To raise \$ e \$ to the power of a matrix

Inspired by this 3Blue1Brown video Given a square matrix \$ M \$, compute its matrix exponential \$ \exp(M) \$, which is defined, using an extension of the Maclaurin series for \$ e^x \$, as $$ \exp(M)...
user avatar
  • 22.2k
5 votes
10 answers
1k views

Odds that a string of N digits contains two or more of the same

I have to fill in 2fa codes all day. They're 6-digit strings. One day I noticed that not once did any of these codes contain 6 unique digits, like 198532 There was always at least one double, like ...
user avatar
  • 1,276
7 votes
10 answers
3k views

The worst ever phone number entry screen

The name of the challenge was prompted by this GIF and the GIF also gave me the idea. Your challenge today is to take a input guaranteed to be \$2<=n<=100\$ and output a sequence of ...
user avatar
23 votes
14 answers
2k views

Find the Erdős–Woods origin

Consider, for a given positive integer \$k\$, the sequence \$(a, a+1, a+2, ..., a+k)\$, where \$a\$ is some positive integer. Is there ever a pair \$a, k\$ such that for each element \$a+i\$ in the ...
user avatar

1
2
3 4 5
34