Department numbers: Difference between revisions

m (→‎{{header|Rust}}: Applied rustfmt)
Line 1,148:
14 valid combinations
</pre>
 
=={{header|Groovy}}==
{{trans|Java}}
<lang groovy>class DepartmentNumbers {
static void main(String[] args) {
println("Police Sanitation Fire")
println("------ ---------- ----")
int count = 0
for (int i = 2; i <= 6; i += 2) {
for (int j = 1; j <= 7; ++j) {
if (j == i) continue
for (int k = 1; k <= 7; ++k) {
if (k == i || k == j) continue
if (i + j + k != 12) continue
println(" $i $j $k")
count++
}
}
}
println()
println("$count valid combinations")
}
}</lang>
{{out}}
<pre>Police Sanitation Fire
------ ---------- ----
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
 
14 valid combinations</pre>
 
=={{header|Haskell}}==
1,452

edits