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
15 votes
10 answers
483 views

In between fractions

Given two positive integer fractions \$x\$ and \$y\$ such that \$x < y\$, give the fraction \$z\$ with the smallest positive integer denominator such that it is between \$x\$ and \$y\$. For example ...
user avatar
  • 84.8k
-1 votes
0 answers
83 views

Find the Lowest Allowable Integer Which is an Optimal Even-Harmonic of the Values in a List [closed]

PROBLEM For a list of numbers, list: Find the lowest possible integer, x, which is optimally close to the whole number even-...
user avatar
16 votes
25 answers
1k views

Alternating sums of multidimensional arrays

Given a multidimensional array, find the recursive alternating sum. An alternating sum is simply the sum of an array, where every other item (starting with the second) is negated. For example, the ...
user avatar
20 votes
8 answers
2k views

ASCII-Art n'th Root

Challenge: Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal ...
user avatar
1 vote
1 answer
357 views

Best performance on x/(y+z) + y/(x+z) + z/(x+y) = N

Consider the equation $$\frac x {y+z} + \frac y {x+z} + \frac z {x+y} = n$$ for positive integers \$x, y, z\$ and \$n \ge 4\$. Your code will receive \$n\$ as an input, and output three integers \$x, ...
user avatar
  • 519
9 votes
2 answers
308 views

Sorting passengers on a plane

A few days ago I made a puzzle about moving people on an airplane. Now I am interested in the general version of this puzzle and the shortest code golf for it. I will briefly summarise the puzzle here....
user avatar
14 votes
6 answers
656 views

Rounding a range

You have a line with two endpoints a and b (0 ≤ a < b) on a 1D space. When ...
user avatar
  • 2,121
29 votes
28 answers
3k views

Collatz Encoding

The Collatz Conjecture The famous Collatz Conjecture (which we will assume to be true for the challenge) defines a sequence for each natural number, and hypothesizes that every such sequence will ...
user avatar
16 votes
7 answers
2k views

Is this polynomial a square?

Given an integral polynomial \$p\$, determine if \$p\$ is a square of another integral polynomial. An integral polynomial is a polynomial with only integers as coefficients. For example, \$x^2+2x+1\$ ...
user avatar
  • 32.8k
18 votes
17 answers
3k views

Convert angle to clock time

Your task is to make a program or function that takes a nonnegative integer (or a different convenient format to represent it) that represents an angle measure in degrees from 0 to 180 (inclusive) as ...
user avatar
  • 1,841
8 votes
35 answers
3k views

Find the weight of five apples

Problem John bought 5 apples. You are given the weights of every group of four apples, and must then find the weights of the apples themselves. For example, if all apples without the first one weigh ...
user avatar
  • 99
19 votes
30 answers
2k views

Convert from variable-width Two's Complement to Integer

Take an input, and convert it from Two's Complement notation (binary where the first bit is negated, but the rest are taken as normal) into an integer (in a somewhat standard output form). Input can ...
user avatar
  • 1,250
22 votes
26 answers
2k views

Randomly Rounding

Input a decimal number and round it to an integer, randomly rounding up or down with a probability based on its fractional part, so the expected value of the output equals to the input value. If ...
user avatar
  • 28.6k
18 votes
9 answers
2k views

Is it irrational?

Your task is to make a program that decides if a real number between 0 and 1 is irrational or not. As stated, this is obviously impossible, so instead we will use the following definition: ...
user avatar
  • 6,645
14 votes
2 answers
504 views

Find the magic numbers to divide a number without division

An integer \$x\in[0,2^{32}-1]\$ divided by an integer \$d\in{[1,2^{31}]}\$ will produce an integral quotient \$q\$ and a remainder \$r\$, so that \$x=d\times q+r\$. Any \$q\$, in fact, can be ...
user avatar
  • 2,121
17 votes
12 answers
2k views

Random Point from a 2D Donut Distribution

A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius <...
user avatar
  • 6,120
21 votes
1 answer
529 views

Can you draw this in one stroke?

Related | Related Given an ASCII art with |, _, and , check if you can draw the art in one ...
user avatar
  • 3,605
4 votes
3 answers
248 views

Find All Digitroot Cyclic Sequences With Length Greater Than One

Digital sum, DR, Digit root is the iterative process of summing digits of a number until you end up with a single digit root number: e.g. digit root of 12345 is 6 since 1 + 2 + 3 + 4 + 5 = 15 = 1+5. ...
user avatar
  • 179
10 votes
3 answers
296 views

Coordinates for a Heronian tetrahedron

Did you know that Heronian Tetrahedra Are Lattice Tetrahedra? A Heronian tetrahedron is a tetrahedron where the length of each edge is an integer, the area of each face is an integer, and the volume ...
user avatar
  • 8,097
18 votes
3 answers
589 views

Find a factorial with n trailing zeros, quickly

Problem A fact you may have noticed about factorials is that as \$n\$ gets larger \$n!\$ will have an increasing number of \$0\$s at the end of it's base \$10\$ representation. In fact this is true ...
user avatar
  • 84.8k
21 votes
33 answers
3k views

Sum of two squares

Given a nonnegative integer \$n\$, determine whether \$n\$ can be expressed as the sum of two square numbers, that is \$\exists a,b\in\mathbb Z\$ such that \$n=a^2+b^2\$. ...
user avatar
  • 3,931
15 votes
4 answers
518 views

Output a Steiner quadruple system

A Steiner quadruple system \$SQS(n)\$ is a collection of subsets (blocks) of size 4 of a set \$S\$ of size \$n\$ such that every subset of \$S\$ of size 3 is in exactly one block. It is easy to show ...
user avatar
19 votes
27 answers
2k views

Prime a*b+c of N

Given an integer \$N\$, print or return integers \$a\$, \$b\$, and \$c\$ that satisfy all of the following conditions, if such integers exist: \$a \times b + c = N\$ \$a\$, \$b\$, and \$c\$ are all ...
user avatar
  • 757
17 votes
28 answers
1k views

Reversed Multiple Pair

Intro Two numbers are a reversed multiple pair if they satisfy the following property: $$ a\cdot b = \operatorname{reversed}( (a-1)\cdot b ) $$ Here, \$\operatorname{reversed}()\$ means to reverse the ...
user avatar
  • 3,053
0 votes
0 answers
138 views

Infinite-Time Busy Beaver

An infinite time Turing machine is a generalization of a Turing machine to infinite computation lengths. It has three tapes: two of them are blank initially, and the other one contains the input to ...
user avatar
  • 491
11 votes
18 answers
818 views

Move to Right and left

Task Your task is to take an array of numbers as input, and produce a new one where each number has been shifted both right and left, leaving 0s if no number fills ...
user avatar
  • 2,493
19 votes
4 answers
538 views

Egyptian fractions summing to n

An "Egyptian fraction" is a list of distinct fractions with a numerator of \$1\$. For example: \$ \frac 1 1+ \frac 1 2 + \frac 1 3 + \frac 1 6 \$ The "size" of an Egyptian ...
user avatar
  • 84.8k
6 votes
1 answer
188 views

Represent any integer with an expression that uses no digit besides '4' [closed]

Fourward (Introduction) I have an unhealthy obsession with the number 4. I love it so much, in fact, that seeing any other digit is frustrating to me. I therefour wish to create a 'Fourier ...
user avatar
8 votes
8 answers
267 views

Products all the way down

You are probably familiar with the Cartesian product. It takes two lists and creates a list of all pairs that can be made from an element of the first and an element from the second: \$ \left[1,2\...
user avatar
  • 84.8k
32 votes
18 answers
3k views

Egyptian fraction representations of 1

An Egyptian fraction is a representation of a rational number using the sum of distinct unit fractions (a unit fraction is of the form \$ \frac 1 x \$ where \$ x \$ is a positive integer). For all[1] ...
user avatar
  • 18.4k
21 votes
13 answers
2k views

Output every sublist ... eventually

You will be given as input an infinite stream of positive integers. Your task is to write a program which outputs an infinite sequence of lists with two requirements: All lists in the output are ...
user avatar
  • 84.8k
6 votes
10 answers
763 views

Generate Fmbalbuena Numbers

My user id is 106959 How to check if the number is Fmbalbuena number? First Step: Check if the number of digits is a multiple of 3: ...
user avatar
  • 2,493
-6 votes
4 answers
150 views

Indices of square numbers that are also pentagonal [closed]

First 15 numbers of the A046173: ...
user avatar
  • 3,031
31 votes
14 answers
2k views

Iterate your way to a fraction

I recently learned from a comment by MathOverflow user pregunton that it is possible to enumerate all rational numbers using iterated maps of the form \$f(x) = x+1\$ or \$\displaystyle g(x) = -\frac ...
user avatar
  • 8,097
7 votes
2 answers
264 views

No parentheses shall be omitted

This expression actually has an omitted pair of parentheses. 1 + 2 * 3 To make things clear, it should be, 1 + (2 * 3) Even ...
user avatar
  • 2,121
3 votes
9 answers
157 views

Find the absolute minimum difference between 2 divided numbers from n [duplicate]

Input: An integer n Output: A string A * B Example 12 Possible 2 divisible numbers: ...
user avatar
  • 3,031
13 votes
6 answers
428 views

AoCG2021 Day 22: Hyperbolic rescue

Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2017 Day 11. Crossing the bridge, you've barely reached the other side of the stream when you ...
user avatar
  • 84.8k
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,031
15 votes
10 answers
778 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
  • 62.1k
15 votes
7 answers
735 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,224
4 votes
3 answers
535 views

How to shorten the Python code? Part II

Code Python 3, 245 bytes ...
user avatar
  • 2,493
20 votes
1 answer
462 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
  • 16.9k
-1 votes
2 answers
201 views

Challenge: create a large number using an esoteric programming language [duplicate]

I enjoy large numbers and esoteric programming language, so I decided to combine them into a programming challenge. Your goal is to push the limits of esoteric languages like BF or Pyth and return the ...
user avatar
  • 491
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
  • 84.8k
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,645
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
991 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
  • 62.1k
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,449
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

1
2 3 4 5
33