WeixiangYan/CodeTransOcean huggingface dataset:
Task: Department numbers







Python: from itertools import permutations
 
def solve():
    c, p, f, s = "\\,Police,Fire,Sanitation".split(',')
    print(f"{c:>3}  {p:^6} {f:^4} {s:^10}")
    c = 1
    for p, f, s in permutations(range(1, 8), r=3):
        if p + s + f == 12 and p % 2 == 0:
            print(f"{c:>3}: {p:^6} {f:^4} {s:^10}")
            c += 1
 
if __name__ == '__main__':
    solve()





Ada: with Ada.Text_IO;

procedure Department_Numbers is
   use Ada.Text_IO;
begin
   Put_Line (" P S F");
   for Police in 2 .. 6 loop
      for Sanitation in 1 .. 7 loop
         for Fire in 1 .. 7 loop
            if
              Police mod 2 = 0                and
              Police + Sanitation + Fire = 12 and
              Sanitation /= Police            and
              Sanitation /= Fire              and
              Police     /= Fire
            then
               Put_Line (Police'Image & Sanitation'Image & Fire'Image);
            end if;
         end loop;
      end loop;
   end loop;
end Department_Numbers;
Task: Department numbers








VB: Module Module1

    Sub Main()
        For p = 2 To 7 Step 2
            For s = 1 To 7
                Dim f = 12 - p - s
                If s >= f Then
                    Exit For
                End If
                If f > 7 Then
                    Continue For
                End If
                If s = p OrElse f = p Then
                    Continue For 
                End If
                Console.WriteLine($"Police:{p}, Sanitation:{s}, Fire:{f}")
                Console.WriteLine($"Police:{p}, Sanitation:{f}, Fire:{s}")
            Next
        Next
    End Sub

End Module




Ada: with Ada.Text_IO;

procedure Department_Numbers is
   use Ada.Text_IO;
begin
   Put_Line (" P S F");
   for Police in 2 .. 6 loop
      for Sanitation in 1 .. 7 loop
         for Fire in 1 .. 7 loop
            if
              Police mod 2 = 0                and
              Police + Sanitation + Fire = 12 and
              Sanitation /= Police            and
              Sanitation /= Fire              and
              Police     /= Fire
            then
               Put_Line (Police'Image & Sanitation'Image & Fire'Image);
            end if;
         end loop;
      end loop;
   end loop;
end Department_Numbers;
Task: Department numbers

C: #include<stdio.h>

int main()
{
	int police,sanitation,fire;
	
	printf("Police     Sanitation         Fire\n");
	printf("----------------------------------");
	
	for(police=2;police<=6;police+=2){
		for(sanitation=1;sanitation<=7;sanitation++){
			for(fire=1;fire<=7;fire++){
				if(police!=sanitation && sanitation!=fire && fire!=police && police+fire+sanitation==12){
					printf("\n%d\t\t%d\t\t%d",police,sanitation,fire);
				}
			}
		}
	}
	
	return 0;
}
Task: Department numbers



C#: using System;
public class Program
{
    public static void Main() {
        for (int p = 2; p <= 7; p+=2) {
            for (int s = 1; s <= 7; s++) {
                int f = 12 - p - s;
                if (s >= f) break;
                if (f > 7) continue;
                if (s == p || f == p) continue; 
                Console.WriteLine($"Police:{p}, Sanitation:{s}, Fire:{f}");
                Console.WriteLine($"Police:{p}, Sanitation:{f}, Fire:{s}");
            }
        }
    }
}
Task: Department numbers


C++: #include <iostream>
#include <iomanip>

int main( int argc, char* argv[] ) {
    int sol = 1;
    std::cout << "\t\tFIRE\t\tPOLICE\t\tSANITATION\n";
    for( int f = 1; f < 8; f++ ) {
        for( int p = 1; p < 8; p++ ) {
            for( int s = 1; s < 8; s++ ) {
                if( f != p && f != s && p != s && !( p & 1 ) && ( f + s + p == 12 ) ) {
                std::cout << "SOLUTION #" << std::setw( 2 ) << sol++ << std::setw( 2 ) 
                << ":\t" << std::setw( 2 ) << f << "\t\t " << std::setw( 3 ) << p 
                << "\t\t" << std::setw( 6 ) << s << "\n";
                }
            }
        }
    }
    return 0;
}
Task: Department numbers





Java: public class DepartmentNumbers {
    public static void main(String[] args) {
        System.out.println("Police  Sanitation  Fire");
        System.out.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;
                    System.out.printf("  %d         %d         %d\n", i, j, k);
                    count++;
                }
            }
        }
        System.out.printf("\n%d valid combinations", count);
    }
}
Task: Department numbers







Python: from itertools import permutations
 
def solve():
    c, p, f, s = "\\,Police,Fire,Sanitation".split(',')
    print(f"{c:>3}  {p:^6} {f:^4} {s:^10}")
    c = 1
    for p, f, s in permutations(range(1, 8), r=3):
        if p + s + f == 12 and p % 2 == 0:
            print(f"{c:>3}: {p:^6} {f:^4} {s:^10}")
            c += 1
 
if __name__ == '__main__':
    solve()
Task: Department numbers








VB: Module Module1

    Sub Main()
        For p = 2 To 7 Step 2
            For s = 1 To 7
                Dim f = 12 - p - s
                If s >= f Then
                    Exit For
                End If
                If f > 7 Then
                    Continue For
                End If
                If s = p OrElse f = p Then
                    Continue For 
                End If
                Console.WriteLine($"Police:{p}, Sanitation:{s}, Fire:{f}")
                Console.WriteLine($"Police:{p}, Sanitation:{f}, Fire:{s}")
            Next
        Next
    End Sub

End Module
Task: Department numbers




Go: package main

import "fmt"

func main() {
    fmt.Println("Police  Sanitation  Fire")
    fmt.Println("------  ----------  ----")
    count := 0
    for i := 2; i < 7; i += 2 {
        for j := 1; j < 8; j++ {
            if j == i { continue }
            for k := 1; k < 8; k++ {
                if k == i || k == j { continue }
                if i + j + k != 12 { continue }
                fmt.Printf("  %d         %d         %d\n", i, j, k)
                count++
            }
        }
    }
    fmt.Printf("\n%d valid combinations\n", count)
}
Task: Department numbers



C#: using System;
public class Program
{
    public static void Main() {
        for (int p = 2; p <= 7; p+=2) {
            for (int s = 1; s <= 7; s++) {
                int f = 12 - p - s;
                if (s >= f) break;
                if (f > 7) continue;
                if (s == p || f == p) continue; 
                Console.WriteLine($"Police:{p}, Sanitation:{s}, Fire:{f}");
                Console.WriteLine($"Police:{p}, Sanitation:{f}, Fire:{s}");
            }
        }
    }
}








Fortran:       INTEGER P,S,F	
    1  PP:DO P = 2,7,2	
    2   SS:DO S = 1,7		
    3        IF (P.EQ.S) CYCLE SS	
    4        F = 12 - (P + S)		
    5        IF (F.LE.0 .OR. F.GT.7) CYCLE SS	
    6        IF ((F - S)*(F - P)) 7,8,7		
    7        WRITE (6,"(3I2)") P,S,F		
    8      END DO SS		
    9    END DO PP	
      END
Task: Department numbers


C++: #include <iostream>
#include <iomanip>

int main( int argc, char* argv[] ) {
    int sol = 1;
    std::cout << "\t\tFIRE\t\tPOLICE\t\tSANITATION\n";
    for( int f = 1; f < 8; f++ ) {
        for( int p = 1; p < 8; p++ ) {
            for( int s = 1; s < 8; s++ ) {
                if( f != p && f != s && p != s && !( p & 1 ) && ( f + s + p == 12 ) ) {
                std::cout << "SOLUTION #" << std::setw( 2 ) << sol++ << std::setw( 2 ) 
                << ":\t" << std::setw( 2 ) << f << "\t\t " << std::setw( 3 ) << p 
                << "\t\t" << std::setw( 6 ) << s << "\n";
                }
            }
        }
    }
    return 0;
}









Fortran:       INTEGER P,S,F	
    1  PP:DO P = 2,7,2	
    2   SS:DO S = 1,7		
    3        IF (P.EQ.S) CYCLE SS	
    4        F = 12 - (P + S)		
    5        IF (F.LE.0 .OR. F.GT.7) CYCLE SS	
    6        IF ((F - S)*(F - P)) 7,8,7		
    7        WRITE (6,"(3I2)") P,S,F		
    8      END DO SS		
    9    END DO PP	
      END
Task: Department numbers

C: #include<stdio.h>

int main()
{
	int police,sanitation,fire;
	
	printf("Police     Sanitation         Fire\n");
	printf("----------------------------------");
	
	for(police=2;police<=6;police+=2){
		for(sanitation=1;sanitation<=7;sanitation++){
			for(fire=1;fire<=7;fire++){
				if(police!=sanitation && sanitation!=fire && fire!=police && police+fire+sanitation==12){
					printf("\n%d\t\t%d\t\t%d",police,sanitation,fire);
				}
			}
		}
	}
	
	return 0;
}










Fortran:       INTEGER P,S,F	
    1  PP:DO P = 2,7,2	
    2   SS:DO S = 1,7		
    3        IF (P.EQ.S) CYCLE SS	
    4        F = 12 - (P + S)		
    5        IF (F.LE.0 .OR. F.GT.7) CYCLE SS	
    6        IF ((F - S)*(F - P)) 7,8,7		
    7        WRITE (6,"(3I2)") P,S,F		
    8      END DO SS		
    9    END DO PP	
      END
Task: Department numbers





Java: public class DepartmentNumbers {
    public static void main(String[] args) {
        System.out.println("Police  Sanitation  Fire");
        System.out.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;
                    System.out.printf("  %d         %d         %d\n", i, j, k);
                    count++;
                }
            }
        }
        System.out.printf("\n%d valid combinations", count);
    }
}






Fortran:       INTEGER P,S,F	
    1  PP:DO P = 2,7,2	
    2   SS:DO S = 1,7		
    3        IF (P.EQ.S) CYCLE SS	
    4        F = 12 - (P + S)		
    5        IF (F.LE.0 .OR. F.GT.7) CYCLE SS	
    6        IF ((F - S)*(F - P)) 7,8,7		
    7        WRITE (6,"(3I2)") P,S,F		
    8      END DO SS		
    9    END DO PP	
      END
Task: Department numbers







Python: from itertools import permutations
 
def solve():
    c, p, f, s = "\\,Police,Fire,Sanitation".split(',')
    print(f"{c:>3}  {p:^6} {f:^4} {s:^10}")
    c = 1
    for p, f, s in permutations(range(1, 8), r=3):
        if p + s + f == 12 and p % 2 == 0:
            print(f"{c:>3}: {p:^6} {f:^4} {s:^10}")
            c += 1
 
if __name__ == '__main__':
    solve()




Fortran:       INTEGER P,S,F	
    1  PP:DO P = 2,7,2	
    2   SS:DO S = 1,7		
    3        IF (P.EQ.S) CYCLE SS	
    4        F = 12 - (P + S)		
    5        IF (F.LE.0 .OR. F.GT.7) CYCLE SS	
    6        IF ((F - S)*(F - P)) 7,8,7		
    7        WRITE (6,"(3I2)") P,S,F		
    8      END DO SS		
    9    END DO PP	
      END
Task: Department numbers








VB: Module Module1

    Sub Main()
        For p = 2 To 7 Step 2
            For s = 1 To 7
                Dim f = 12 - p - s
                If s >= f Then
                    Exit For
                End If
                If f > 7 Then
                    Continue For
                End If
                If s = p OrElse f = p Then
                    Continue For 
                End If
                Console.WriteLine($"Police:{p}, Sanitation:{s}, Fire:{f}")
                Console.WriteLine($"Police:{p}, Sanitation:{f}, Fire:{s}")
            Next
        Next
    End Sub

End Module



Fortran:       INTEGER P,S,F	
    1  PP:DO P = 2,7,2	
    2   SS:DO S = 1,7		
    3        IF (P.EQ.S) CYCLE SS	
    4        F = 12 - (P + S)		
    5        IF (F.LE.0 .OR. F.GT.7) CYCLE SS	
    6        IF ((F - S)*(F - P)) 7,8,7		
    7        WRITE (6,"(3I2)") P,S,F		
    8      END DO SS		
    9    END DO PP	
      END
Task: Department numbers






PHP: <?php

$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
    for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
        $fire = 12 - $police - $sanitation;
        if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
            echo 'Police: ', $police, ', Sanitation: ', $sanitation, ', Fire: ', $fire, PHP_EOL;
            $valid++;
        }
    }
}
echo $valid, ' valid combinations found.', PHP_EOL;





Fortran:       INTEGER P,S,F	
    1  PP:DO P = 2,7,2	
    2   SS:DO S = 1,7		
    3        IF (P.EQ.S) CYCLE SS	
    4        F = 12 - (P + S)		
    5        IF (F.LE.0 .OR. F.GT.7) CYCLE SS	
    6        IF ((F - S)*(F - P)) 7,8,7		
    7        WRITE (6,"(3I2)") P,S,F		
    8      END DO SS		
    9    END DO PP	
      END
Task: Department numbers

C: #include<stdio.h>

int main()
{
	int police,sanitation,fire;
	
	printf("Police     Sanitation         Fire\n");
	printf("----------------------------------");
	
	for(police=2;police<=6;police+=2){
		for(sanitation=1;sanitation<=7;sanitation++){
			for(fire=1;fire<=7;fire++){
				if(police!=sanitation && sanitation!=fire && fire!=police && police+fire+sanitation==12){
					printf("\n%d\t\t%d\t\t%d",police,sanitation,fire);
				}
			}
		}
	}
	
	return 0;
}









COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. DEPARTMENT-NUMBERS.

       DATA DIVISION.
       WORKING-STORAGE SECTION.       
       01 BANNER        PIC X(24) VALUE "POLICE  SANITATION  FIRE".
       01 COMBINATION.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 POLICE     PIC 9.
          03 FILLER     PIC X(11) VALUE SPACES.
          03 SANITATION PIC 9.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 FIRE       PIC 9.
       01 TOTAL         PIC 99.

       PROCEDURE DIVISION.
       BEGIN. 
           DISPLAY BANNER.
           PERFORM POLICE-LOOP VARYING POLICE FROM 2 BY 2
           UNTIL POLICE IS GREATER THAN 6.
           STOP RUN.
 
       POLICE-LOOP. 
           PERFORM SANITATION-LOOP VARYING SANITATION FROM 1 BY 1
           UNTIL SANITATION IS GREATER THAN 7.
  
       SANITATION-LOOP.
           PERFORM FIRE-LOOP VARYING FIRE FROM 1 BY 1
           UNTIL FIRE IS GREATER THAN 7.
 
       FIRE-LOOP.
           ADD POLICE, SANITATION, FIRE GIVING TOTAL.
           IF POLICE IS NOT EQUAL TO SANITATION
               AND POLICE IS NOT EQUAL TO FIRE
               AND SANITATION IS NOT EQUAL TO FIRE
               AND TOTAL IS EQUAL TO 12,
               DISPLAY COMBINATION.
Task: Department numbers



C#: using System;
public class Program
{
    public static void Main() {
        for (int p = 2; p <= 7; p+=2) {
            for (int s = 1; s <= 7; s++) {
                int f = 12 - p - s;
                if (s >= f) break;
                if (f > 7) continue;
                if (s == p || f == p) continue; 
                Console.WriteLine($"Police:{p}, Sanitation:{s}, Fire:{f}");
                Console.WriteLine($"Police:{p}, Sanitation:{f}, Fire:{s}");
            }
        }
    }
}







COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. DEPARTMENT-NUMBERS.

       DATA DIVISION.
       WORKING-STORAGE SECTION.       
       01 BANNER        PIC X(24) VALUE "POLICE  SANITATION  FIRE".
       01 COMBINATION.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 POLICE     PIC 9.
          03 FILLER     PIC X(11) VALUE SPACES.
          03 SANITATION PIC 9.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 FIRE       PIC 9.
       01 TOTAL         PIC 99.

       PROCEDURE DIVISION.
       BEGIN. 
           DISPLAY BANNER.
           PERFORM POLICE-LOOP VARYING POLICE FROM 2 BY 2
           UNTIL POLICE IS GREATER THAN 6.
           STOP RUN.
 
       POLICE-LOOP. 
           PERFORM SANITATION-LOOP VARYING SANITATION FROM 1 BY 1
           UNTIL SANITATION IS GREATER THAN 7.
  
       SANITATION-LOOP.
           PERFORM FIRE-LOOP VARYING FIRE FROM 1 BY 1
           UNTIL FIRE IS GREATER THAN 7.
 
       FIRE-LOOP.
           ADD POLICE, SANITATION, FIRE GIVING TOTAL.
           IF POLICE IS NOT EQUAL TO SANITATION
               AND POLICE IS NOT EQUAL TO FIRE
               AND SANITATION IS NOT EQUAL TO FIRE
               AND TOTAL IS EQUAL TO 12,
               DISPLAY COMBINATION.
Task: Department numbers


C++: #include <iostream>
#include <iomanip>

int main( int argc, char* argv[] ) {
    int sol = 1;
    std::cout << "\t\tFIRE\t\tPOLICE\t\tSANITATION\n";
    for( int f = 1; f < 8; f++ ) {
        for( int p = 1; p < 8; p++ ) {
            for( int s = 1; s < 8; s++ ) {
                if( f != p && f != s && p != s && !( p & 1 ) && ( f + s + p == 12 ) ) {
                std::cout << "SOLUTION #" << std::setw( 2 ) << sol++ << std::setw( 2 ) 
                << ":\t" << std::setw( 2 ) << f << "\t\t " << std::setw( 3 ) << p 
                << "\t\t" << std::setw( 6 ) << s << "\n";
                }
            }
        }
    }
    return 0;
}








COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. DEPARTMENT-NUMBERS.

       DATA DIVISION.
       WORKING-STORAGE SECTION.       
       01 BANNER        PIC X(24) VALUE "POLICE  SANITATION  FIRE".
       01 COMBINATION.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 POLICE     PIC 9.
          03 FILLER     PIC X(11) VALUE SPACES.
          03 SANITATION PIC 9.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 FIRE       PIC 9.
       01 TOTAL         PIC 99.

       PROCEDURE DIVISION.
       BEGIN. 
           DISPLAY BANNER.
           PERFORM POLICE-LOOP VARYING POLICE FROM 2 BY 2
           UNTIL POLICE IS GREATER THAN 6.
           STOP RUN.
 
       POLICE-LOOP. 
           PERFORM SANITATION-LOOP VARYING SANITATION FROM 1 BY 1
           UNTIL SANITATION IS GREATER THAN 7.
  
       SANITATION-LOOP.
           PERFORM FIRE-LOOP VARYING FIRE FROM 1 BY 1
           UNTIL FIRE IS GREATER THAN 7.
 
       FIRE-LOOP.
           ADD POLICE, SANITATION, FIRE GIVING TOTAL.
           IF POLICE IS NOT EQUAL TO SANITATION
               AND POLICE IS NOT EQUAL TO FIRE
               AND SANITATION IS NOT EQUAL TO FIRE
               AND TOTAL IS EQUAL TO 12,
               DISPLAY COMBINATION.
Task: Department numbers





Java: public class DepartmentNumbers {
    public static void main(String[] args) {
        System.out.println("Police  Sanitation  Fire");
        System.out.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;
                    System.out.printf("  %d         %d         %d\n", i, j, k);
                    count++;
                }
            }
        }
        System.out.printf("\n%d valid combinations", count);
    }
}





COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. DEPARTMENT-NUMBERS.

       DATA DIVISION.
       WORKING-STORAGE SECTION.       
       01 BANNER        PIC X(24) VALUE "POLICE  SANITATION  FIRE".
       01 COMBINATION.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 POLICE     PIC 9.
          03 FILLER     PIC X(11) VALUE SPACES.
          03 SANITATION PIC 9.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 FIRE       PIC 9.
       01 TOTAL         PIC 99.

       PROCEDURE DIVISION.
       BEGIN. 
           DISPLAY BANNER.
           PERFORM POLICE-LOOP VARYING POLICE FROM 2 BY 2
           UNTIL POLICE IS GREATER THAN 6.
           STOP RUN.
 
       POLICE-LOOP. 
           PERFORM SANITATION-LOOP VARYING SANITATION FROM 1 BY 1
           UNTIL SANITATION IS GREATER THAN 7.
  
       SANITATION-LOOP.
           PERFORM FIRE-LOOP VARYING FIRE FROM 1 BY 1
           UNTIL FIRE IS GREATER THAN 7.
 
       FIRE-LOOP.
           ADD POLICE, SANITATION, FIRE GIVING TOTAL.
           IF POLICE IS NOT EQUAL TO SANITATION
               AND POLICE IS NOT EQUAL TO FIRE
               AND SANITATION IS NOT EQUAL TO FIRE
               AND TOTAL IS EQUAL TO 12,
               DISPLAY COMBINATION.
Task: Department numbers







Python: from itertools import permutations
 
def solve():
    c, p, f, s = "\\,Police,Fire,Sanitation".split(',')
    print(f"{c:>3}  {p:^6} {f:^4} {s:^10}")
    c = 1
    for p, f, s in permutations(range(1, 8), r=3):
        if p + s + f == 12 and p % 2 == 0:
            print(f"{c:>3}: {p:^6} {f:^4} {s:^10}")
            c += 1
 
if __name__ == '__main__':
    solve()



COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. DEPARTMENT-NUMBERS.

       DATA DIVISION.
       WORKING-STORAGE SECTION.       
       01 BANNER        PIC X(24) VALUE "POLICE  SANITATION  FIRE".
       01 COMBINATION.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 POLICE     PIC 9.
          03 FILLER     PIC X(11) VALUE SPACES.
          03 SANITATION PIC 9.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 FIRE       PIC 9.
       01 TOTAL         PIC 99.

       PROCEDURE DIVISION.
       BEGIN. 
           DISPLAY BANNER.
           PERFORM POLICE-LOOP VARYING POLICE FROM 2 BY 2
           UNTIL POLICE IS GREATER THAN 6.
           STOP RUN.
 
       POLICE-LOOP. 
           PERFORM SANITATION-LOOP VARYING SANITATION FROM 1 BY 1
           UNTIL SANITATION IS GREATER THAN 7.
  
       SANITATION-LOOP.
           PERFORM FIRE-LOOP VARYING FIRE FROM 1 BY 1
           UNTIL FIRE IS GREATER THAN 7.
 
       FIRE-LOOP.
           ADD POLICE, SANITATION, FIRE GIVING TOTAL.
           IF POLICE IS NOT EQUAL TO SANITATION
               AND POLICE IS NOT EQUAL TO FIRE
               AND SANITATION IS NOT EQUAL TO FIRE
               AND TOTAL IS EQUAL TO 12,
               DISPLAY COMBINATION.
Task: Department numbers








VB: Module Module1

    Sub Main()
        For p = 2 To 7 Step 2
            For s = 1 To 7
                Dim f = 12 - p - s
                If s >= f Then
                    Exit For
                End If
                If f > 7 Then
                    Continue For
                End If
                If s = p OrElse f = p Then
                    Continue For 
                End If
                Console.WriteLine($"Police:{p}, Sanitation:{s}, Fire:{f}")
                Console.WriteLine($"Police:{p}, Sanitation:{f}, Fire:{s}")
            Next
        Next
    End Sub

End Module


COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. DEPARTMENT-NUMBERS.

       DATA DIVISION.
       WORKING-STORAGE SECTION.       
       01 BANNER        PIC X(24) VALUE "POLICE  SANITATION  FIRE".
       01 COMBINATION.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 POLICE     PIC 9.
          03 FILLER     PIC X(11) VALUE SPACES.
          03 SANITATION PIC 9.
          03 FILLER     PIC X(5)  VALUE SPACES.
          03 FIRE       PIC 9.
       01 TOTAL         PIC 99.

       PROCEDURE DIVISION.
       BEGIN. 
           DISPLAY BANNER.
           PERFORM POLICE-LOOP VARYING POLICE FROM 2 BY 2
           UNTIL POLICE IS GREATER THAN 6.
           STOP RUN.
 
       POLICE-LOOP. 
           PERFORM SANITATION-LOOP VARYING SANITATION FROM 1 BY 1
           UNTIL SANITATION IS GREATER THAN 7.
  
       SANITATION-LOOP.
           PERFORM FIRE-LOOP VARYING FIRE FROM 1 BY 1
           UNTIL FIRE IS GREATER THAN 7.
 
       FIRE-LOOP.
           ADD POLICE, SANITATION, FIRE GIVING TOTAL.
           IF POLICE IS NOT EQUAL TO SANITATION
               AND POLICE IS NOT EQUAL TO FIRE
               AND SANITATION IS NOT EQUAL TO FIRE
               AND TOTAL IS EQUAL TO 12,
               DISPLAY COMBINATION.