Department numbers: Difference between revisions

m
→‎JS ES6: Tidied.
(Add Draco)
m (→‎JS ES6: Tidied.)
Line 2,293:
Briefly:
<lang JavaScript>(() => {
"use strict";
 
const
// concatMap :: (a -> [b]) -> [a] -> [b]
return ' label = "(Police, Sanitation, Fire)\n' +",
const concatMap = (f, xs) => [].concat.apply([], xs.map(f));
solutions = [2, 4, 6]
 
.flatMap(
return '(Police, Sanitation, Fire)\n' +
concatMap( x => [1, 2, 3, 4, 5, 6, 7]
concatMap.flatMap(y =>
concatMap(zy => [12 - (x + y)]
z !== y && 1 <= z && z <= 7 ? [.flatMap(
z => z !== y && 1 <= z && z <= 7 ? [
[x, y, z]
] : [], [12 - (x + y)]
), [1, 2, 3, 4, 5, 6, 7]
), [2, 4, 6]
)
.map(JSON.stringify)
.join('"\n'");
 
return `${label}\n${solutions}`;
})();</lang>
{{Out}}
9,655

edits