Files
freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-93-arithmetic-expressions.md
2022-10-18 12:59:49 +05:30

1.4 KiB
Raw Blame History

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5900f3ca1000cf542c50fedc Problem 93: Arithmetic expressions 1 302210 problem-93-arithmetic-expressions

--description--

使用集合 {1, 2, 3, 4} 中每个数字恰好一次、加减乘除(+, , , /)四则运算以及括号,可以得到不同的正整数。

例如:

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

需要注意的是把数字直接连接起来是不被允许的例如12 + 34。

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.

--hints--

arithmeticExpressions() should return a number.

assert(typeof arithmeticExpressions() === 'number');

arithmeticExpressions() should return 1258.

assert.strictEqual(arithmeticExpressions(), 1258);

--seed--

--seed-contents--

function arithmeticExpressions() {

  return true;
}

arithmeticExpressions();

--solutions--

// solution required