Questions tagged [expression-building]
For challenges about rearranging a set of mathematical operators or numbers to fulfill a certain expression.
34 questions
16
votes
5
answers
501
views
Flip the order of operations
Scientists have made contact with a parallel universe. Just one problem: They write math differently. Help the scientists make a program that can convert normal math expressions to their equivalent in ...
19
votes
9
answers
1k
views
Cryptic Multiplications
Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592.
If now each digits is ...
6
votes
1
answer
251
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 ...
19
votes
1
answer
741
views
Golfing Expressions
We can write mathematical expressions using the standard math operators (,),+,...
10
votes
0
answers
174
views
8 out of 10 programmers like countdown [duplicate]
Edit (Jan 24/2021): The original specification for the challenge had a few problems. Underneath the original text, I have added alternate conditions that were suggested by @caird-coinheringaahing (...
16
votes
6
answers
763
views
Represent n as an expression containing all the digits
Related Challenge: Single Digit Representations of Natural Numbers
Task
Write a program/function that when given a non-negative integer \$n \le 100000\$ outputs an expression which uses all the ...
7
votes
6
answers
538
views
Build the smallest number
Given a non-empty list of digits 0 though 9, output the smallest number that can be produced by an expression formed by reordering these digits and introducing exponentiation signs ...
6
votes
2
answers
407
views
2D interpolation
Given required values for an expression with 2 variables, output a short expression which fulfill these values
Input
You may take the input in any reasonable format, e.g. ...
27
votes
8
answers
3k
views
Single Digit Representations of Natural Numbers
Task
Write a program/function that when given a positive integer \$n\$ and a digit \$d\$ which is not 0 outputs a way to represent \$n\$ using only addition, subtraction, multiplication, ...
3
votes
0
answers
173
views
Make Three from One [duplicate]
Given a single digit integer and a three digit integer, output a mathematical formula that uses only the single digit and a given list of operators to equal the three digit integer.
Input: A one ...
13
votes
1
answer
558
views
Not just a four fours puzzle
In this variant of the Four fours puzzle your should use up to x x's (and no other number) and a defined set of operations to ...
20
votes
24
answers
2k
views
Make Zero From First 'n' Numbers
Challenge
The challenge is to write a code that takes a positive integer 'n' as an input and displays all the possible ways in which the numbers from 1 - n can be written, with either positive or ...
28
votes
8
answers
2k
views
Find number of ones to get a number using + and *
Introduction
Your goal is to find the least number of ones you need to add or multiply together to get the input value, this is A005245.
Input
One positive integer N.
Output
The smallest number ...
15
votes
2
answers
1k
views
Mathematical Expression Showdown!
You are given 6 numbers: 5 digits [0-9] and a target number. Your goal is to intersperse operators between the digits to get as close as you can to the target. You have to use each digit exactly once, ...
66
votes
13
answers
4k
views
Operator precedence: How wrong can I be?
Say I have an expression:
9 * 8 + 1 - 4
This expression can be interpreted in six different ways, depending on operator precedence:
...
16
votes
10
answers
2k
views
Fewest operations to 100
Overview
Given a list of digits, find the fewest operations to make 100
Input
A string of digits, which may or may not be in numerical order. The order of the digits cannot be changed, however plus ...
8
votes
1
answer
398
views
Roots and operators
I used to play a game while I was in the car, it consisted in taking the n-1 first numbers of another car plate and use operators and roots on them to get the ...
16
votes
2
answers
525
views
Make mathematics with minimal matchsticks
Meta-background
This was set as a question on Puzzling, and the instant reaction was "well, someone will just solve that by computer". There was a debate about just how complex a program to solve ...
29
votes
10
answers
4k
views
Solve an equation with (almost) any numbers you like
Given a string of the characters +=- where there is at least one =, insert positive integers between all the symbols and at the ...
10
votes
10
answers
1k
views
Find operations required to get result
So task is simple, given array of numbers and result, you need to find what operations you need to use on numbers from array , to obtain requested result.
Let's make it simple for start, and allow ...
16
votes
8
answers
1k
views
Express a number with only 0-9 and the four operations
Explanation
Befunge is a two-dimensional program that uses stacks.
That means, to do 5 + 6, you write 56+, meaning:
...
26
votes
11
answers
2k
views
Official Dyalog APL 2016 Year Game
If you think this could be fun, but too much work, consider participating in this much smaller challenge.
A bit of fun (and possibly frustration!) for 2016... Dyalog's "puzzle of the year". ...
13
votes
23
answers
5k
views
10 9 8 7 6 5 4 3 2 1... Print 2016 [closed]
As a spin-off to my challenge over at Puzzling, your goal is to output 2016.
Rules:
You must include the numbers ...
19
votes
1
answer
2k
views
Make a math equation from the date
In my Economics class, my friends and I like to come up with ways to rearrange the digits in the date (in MM/DD/YY) format to create a valid mathematical equation. For the most part, we are allowed to ...
15
votes
1
answer
865
views
Arithmetic... tock... tick... tock
This question brought to you by a game I like to play when stuck in long phone meetings.
Given any two times from a 24 hour clock (from 00:00 to 23:59), how many valid mathematical equations can be ...
16
votes
2
answers
706
views
Express a number - a modern "Des Chiffres et des Lettres"
Express a number
Back in the 60s, the French invented the TV game show "Des Chiffres et des Lettres" (Digits & Letters). The goal of the Digits-part of the show was to come as close as you can to ...
13
votes
1
answer
1k
views
Two-zero-one-five puzzle
Background
This puzzle is a variation on the four fours puzzle (itself the topic of a past question). Like that puzzle, the aim is to find mathematical expressions for different whole numbers, using ...
15
votes
4
answers
2k
views
It’s time to do the math
Introduction
This is one of my favorite math puzzles.
Given a digit (say 3) and the number of times to use that digit (say 5), generate 10 expressions which result to 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10 ...
6
votes
2
answers
948
views
Longest mathematical expression in a grid
Given a grid which contains these signs: 0..9, x, =, write the fastest code that outputs the longest string of connected (horizontally, vertically, and diagonally adjacent), distinct cells which is a ...
8
votes
12
answers
2k
views
Generate all possible integers
Input: you are given 2 integers, n and k. n is a positive (>= 1) integer, and ...
24
votes
4
answers
4k
views
Four fours puzzle
The Four fours puzzle is a popular recreational mathematical puzzle that involves using exactly four 4s (and no other number) and a defined set of operations to reach every number from 0 to a given ...
11
votes
1
answer
2k
views
Generate a number by using a given list of numbers and arithmetic operators
You are given a list of numbers L = [17, 5, 9, 17, 59, 14], a bag of operators O = {+:7, -:3, *:5, /:1} and a number ...
7
votes
4
answers
464
views
generate a valid equation using specified operators
A twist on a recently asked question, you are given a list of operators and a result and you need to find integers which, when operated on by those operators, generate the result.
Example 1
input
<...
12
votes
2
answers
2k
views
Generate a valid equation using user-specified numbers
This is based on a game one of my math teachers used to play in middle school. He would write 5 random one-digit numbers on the board, and then a random two-digit number. We would try to create an ...