Files
freeCodeCamp/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-93-arithmetic-expressions.english.md
Oliver Eyton-Williams f1c9b08cf3 fix(curriculum): add isHidden: false to challenges
This includes certificates (where it does nothing), but does not
include any translations.
2020-05-25 16:25:19 +05:30

1.7 KiB
Raw Blame History

id, challengeType, isHidden, title, forumTopicId
id challengeType isHidden title forumTopicId
5900f3ca1000cf542c50fedc 5 false Problem 93: Arithmetic expressions 302210

Description

By using each of the digits from the set, {1, 2, 3, 4}, exactly once, and making use of the four arithmetic operations (+, , *, /) and brackets/parentheses, it is possible to form different positive integer targets.

For example,

8 = (4 * (1 + 3)) / 2
14 = 4 * (3 + 1 / 2)
19 = 4 * (2 + 3) 1
36 = 3 * 4 * (2 + 1)

Note that concatenations of the digits, like 12 + 34, are not allowed.

Using the set, {1, 2, 3, 4}, it is possible to obtain thirty-one different target numbers of which 36 is the maximum, and each of the numbers 1 to 28 can be obtained before encountering the first non-expressible number.

Find the set of four distinct digits, a < b < c < d, for which the longest set of consecutive positive integers, 1 to n, can be obtained, giving your answer as a string: abcd.

Instructions

Tests

tests:
  - text: <code>arithmeticExpressions()</code> should return a number.
    testString: assert(typeof arithmeticExpressions() === 'number');
  - text: <code>arithmeticExpressions()</code> should return 1258.
    testString: assert.strictEqual(arithmeticExpressions(), 1258);

Challenge Seed

function arithmeticExpressions() {
  // Good luck!
  return true;
}

arithmeticExpressions();

Solution

// solution required