← Complete problem index

PROJECT EULER · #0828

Numbers Challenge

Statement only · SolvedOriginal problem ↗

It is a common recreational problem to make a target number using a selection of other numbers. In this problem you will be given six numbers and a target number.

For example, given the six numbers 2, 3, 4, 6, 7, 25, and a target of 211, one possible solution is:

211=(3+6)×25(4×7)÷2

This uses all six numbers. However, it is not necessary to do so. Another solution that does not use the 7 is:

211=(252)×(6+3)+4

Define the score of a solution to be the sum of the numbers used. In the above example problem, the two given solutions have scores 47 and 40 respectively. It turns out that this problem has no solutions with score less than 40.

When combining numbers, the following rules must be observed:

  • Each available number may be used at most once.
  • Only the four basic arithmetic operations are permitted: +, , ×, ÷.
  • All intermediate values must be positive integers, so for example (3÷2) is never permitted as a subexpression (even if the final answer is an integer).

The attached file number-challenges.txt contains 200 problems, one per line in the format:

211:2,3,4,6,7,25

where the number before the colon is the target and the remaining comma-separated numbers are those available to be used.

Numbering the problems 1, 2, ..., 200, we let sn be the minimum score of the solution to the nth problem. For example, s1=40, as the first problem in the file is the example given above. Note that not all problems have a solution; in such cases we take sn=0.

Find n=12003nsn. Give your answer modulo 1005075251.

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.