freeCodeCamp/curriculum/challenges/portuguese/08-coding-interview-prep/rosetta-code/combinations.portuguese.md

2.3 KiB

title id challengeType videoUrl localeTitle
Combinations 5958469238c0d8d2632f46db 5 Combinações

Description

Tarefa:

Dados inteiros não negativos m e n , geram todas as combinações de tamanho m dos inteiros de 0 (zero) a n-1 na ordem classificada (cada combinação é classificada e a tabela inteira é classificada).

Exemplo:

3 pente 5 é:

 0 1 2
0 1 3
0 1 4
0 2 3
0 2 4
0 3 4
1 2 3
1 2 4
1 3 4
2 3 4

Instructions

Tests

tests:
  - text: <code>combinations</code> é uma função.
    testString: 'assert(typeof combinations === "function", "<code>combinations</code> is a function.");'
  - text: '<code>combinations(3, 5)</code> devem retornar <code>[[0, 1, 2], [0, 1, 3], [0, 1, 4], [0, 2, 3], [0, 2, 4], [0, 3, 4], [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]</code> .'
    testString: 'assert.deepEqual(combinations(testInput1[0], testInput1[1]), testOutput1, "<code>combinations(3, 5)</code> should return <code>[[0, 1, 2], [0, 1, 3], [0, 1, 4], [0, 2, 3], [0, 2, 4], [0, 3, 4], [1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]</code>.");'
  - text: '<code>combinations(4, 6)</code> devem retornar <code>[[0,1,2,3], [0,1,2,4], [0,1,2,5], [0,1,3,4], [0,1,3,5], [0,1,4,5], [0,2,3,4], [0,2,3,5], [0,2,4,5], [0,3,4,5], [1,2,3,4], [1,2,3,5], [1,2,4,5], [1,3,4,5], [2,3,4,5]]</code>'
    testString: 'assert.deepEqual(combinations(testInput2[0], testInput2[1]), testOutput2, "<code>combinations(4, 6)</code> should return <code>[[0,1,2,3],  [0,1,2,4],  [0,1,2,5],  [0,1,3,4],  [0,1,3,5],  [0,1,4,5],  [0,2,3,4],  [0,2,3,5],  [0,2,4,5],  [0,3,4,5],  [1,2,3,4],  [1,2,3,5],  [1,2,4,5],  [1,3,4,5],  [2,3,4,5]]</code>");'

Challenge Seed

function combinations (m, n) {
  // Good luck!
  return true;
}

After Test

console.info('after the test');

Solution

// solution required