Department numbers: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
Line 66: | Line 66: | ||
</pre> |
</pre> |
||
=={{header|Lua}}== |
|||
<lang lua> |
|||
print( "Fire", "Police", "Sanitation" ) |
|||
sol = 0 |
|||
for f = 1, 7 do |
|||
for p = 1, 7 do |
|||
for s = 1, 7 do |
|||
if s + p + f == 12 and p % 2 == 0 and f ~= p and f ~= s and p ~= s then |
|||
print( f, p, s ); sol = sol + 1 |
|||
end |
|||
end |
|||
end |
|||
end |
|||
print( string.format( "\n%d solutions found", sol ) ) |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
Fire Police Sanitation |
|||
1 4 7 |
|||
1 6 5 |
|||
2 4 6 |
|||
2 6 4 |
|||
3 2 7 |
|||
3 4 5 |
|||
4 2 6 |
|||
4 6 2 |
|||
5 4 3 |
|||
5 6 1 |
|||
6 2 4 |
|||
6 4 2 |
|||
7 2 3 |
|||
7 4 1 |
|||
14 solutions found |
|||
</pre> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |
||