Department numbers: Difference between revisions

m
→‎{{header|R}}: Syntax highlighting.
(Add CLU)
m (→‎{{header|R}}: Syntax highlighting.)
Line 3,398:
=={{header|R}}==
We solve this task in two lines. The rest of the code is to make the result look nice.
<lang rrsplus>allPermutations <- setNames(expand.grid(seq(2, 7, by = 2), 1:7, 1:7), c("Police", "Sanitation", "Fire"))
solution <- allPermutations[which(rowSums(allPermutations)==12 & apply(allPermutations, 1, function(x) !any(duplicated(x)))),]
solution <- solution[order(solution$Police, solution$Sanitation),]
331

edits