Files
freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/department-numbers.chinese.md
2020-08-16 04:45:18 +05:30

1.8 KiB
Raw Blame History

title, id, challengeType, videoUrl, localeTitle
title id challengeType videoUrl localeTitle
Department Numbers 59f40b17e79dbf1ab720ed7a 5 部门编号

Description

有一个高度组织化的城市决定为每个部门分配一个号码:

警察局环卫部门消防部门

每个部门的数字可以在1到7之间

这三个部门编号应该是唯一的彼此不同并且必须加起来为12。

警察局长不喜欢奇怪的号码,并希望他的部门有一个偶数。

任务:

编写一个输出所有有效组合的程序:

[2,3,7]

[2,4,6]

[2,6,4]

[2,7,3]

[4,1,7]

[4,2,6]

[4,3,5]

[4,5,3]

[4,6,2]

[4,7,1]

[6,1,5]

[6,2,4]

[6,4,2]

[6,5,1]

Instructions

Tests

tests:
  - text: <code>combinations</code>应该是一个功能。
    testString: assert(typeof combinations === 'function');
  - text: '<code>combinations([1, 2, 3], 6)</code>应该返回一个数组。'
    testString: assert(Array.isArray(combinations([1, 2, 3], 6)));
  - text: '<code>combinations([1, 2, 3, 4, 5, 6, 7], 12)</code>应返回长度为14的数组。'
    testString: assert(combinations(nums, total).length === len);
  - text: '<code>combinations([1, 2, 3, 4, 5, 6, 7], 12)</code>应返回所有有效组合。'
    testString: assert.deepEqual(combinations(nums, total), result);

Challenge Seed

function combinations (possibleNumbers, total) {
  // Good luck!
  return true;
}

After Test

console.info('after the test');

Solution

// solution required