Last active
November 23, 2016 01:34
-
-
Save halan/91dc7047b740badeba4595895a138a68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const count = arr => | |
arr.map( (subarr) => | |
subarr.length ).reduce( (acc, l) => acc + l, 0) | |
const step = ({ | |
source: [ [ head, ...mtail ], ...tail], | |
result | |
}) => ({ | |
source: mtail.length === 0 ? [...tail] : [ [...mtail], ...tail ], | |
result: [...result, head] | |
}) | |
const order = arr => ( | |
Array.apply(null, Array(count(arr))) | |
.reduce( step, { source: arr, result: []}) | |
.result | |
) | |
module.exports = order |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const distribuicao = [ | |
['1s2'], | |
['2s2', '2p6'], | |
['3s2', '3p6', '3d10'], | |
['4s2', '4p6', '4d10', '4f14'], | |
['5s2', '5p6', '5d10', '5f14'], | |
['6s2', '6p6', '6d10'], | |
['7s2', '7p6'] | |
] | |
const run = require('./distribui') | |
console.log( | |
run(distribuicao) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cara esse seu distribui ele só está ordenando: