Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. HAS-CLOSE-ELEMENTS.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI COMP-2.
           05 L-THRESHOLD COMP-2.
           05 RESULT PIC 9.

      * Check if in given list of numbers, are any two numbers closer to each other than
      * given threshold.
      * >>> has_close_elements([1.0, 2.0, 3.0], 0.5)
      * False
      * >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
      * True
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    for idx, elem in enumerate(numbers):
        for idx2, elem2 in enumerate(numbers):
            if idx != idx2:
                distance = abs(elem - elem2)
                if distance < threshold:
                    return True

    return False

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HAS-CLOSE-ELEMENTS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "HAS-CLOSE-ELEMENTS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI COMP-2.
           05 L-THRESHOLD COMP-2.
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1.0 TO L-NUMBERS(1)
       MOVE 2.0 TO L-NUMBERS(2)
       MOVE 3.9 TO L-NUMBERS(3)
       MOVE 4.0 TO L-NUMBERS(4)
       MOVE 5.0 TO L-NUMBERS(5)
       MOVE 2.2 TO L-NUMBERS(6)
       MOVE 0.3 TO L-THRESHOLD

       CALL "HAS-CLOSE-ELEMENTS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HAS-CLOSE-ELEMENTS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "HAS-CLOSE-ELEMENTS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI COMP-2.
           05 L-THRESHOLD COMP-2.
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1.0 TO L-NUMBERS(1)
       MOVE 2.0 TO L-NUMBERS(2)
       MOVE 3.9 TO L-NUMBERS(3)
       MOVE 4.0 TO L-NUMBERS(4)
       MOVE 5.0 TO L-NUMBERS(5)
       MOVE 2.2 TO L-NUMBERS(6)
       MOVE 0.05 TO L-THRESHOLD

       CALL "HAS-CLOSE-ELEMENTS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HAS-CLOSE-ELEMENTS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "HAS-CLOSE-ELEMENTS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI COMP-2.
           05 L-THRESHOLD COMP-2.
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1.0 TO L-NUMBERS(1)
       MOVE 2.0 TO L-NUMBERS(2)
       MOVE 5.9 TO L-NUMBERS(3)
       MOVE 4.0 TO L-NUMBERS(4)
       MOVE 5.0 TO L-NUMBERS(5)
       MOVE 0.95 TO L-THRESHOLD

       CALL "HAS-CLOSE-ELEMENTS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HAS-CLOSE-ELEMENTS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "HAS-CLOSE-ELEMENTS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI COMP-2.
           05 L-THRESHOLD COMP-2.
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1.0 TO L-NUMBERS(1)
       MOVE 2.0 TO L-NUMBERS(2)
       MOVE 5.9 TO L-NUMBERS(3)
       MOVE 4.0 TO L-NUMBERS(4)
       MOVE 5.0 TO L-NUMBERS(5)
       MOVE 0.8 TO L-THRESHOLD

       CALL "HAS-CLOSE-ELEMENTS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HAS-CLOSE-ELEMENTS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "HAS-CLOSE-ELEMENTS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI COMP-2.
           05 L-THRESHOLD COMP-2.
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1.0 TO L-NUMBERS(1)
       MOVE 2.0 TO L-NUMBERS(2)
       MOVE 3.0 TO L-NUMBERS(3)
       MOVE 4.0 TO L-NUMBERS(4)
       MOVE 5.0 TO L-NUMBERS(5)
       MOVE 2.0 TO L-NUMBERS(6)
       MOVE 0.1 TO L-THRESHOLD

       CALL "HAS-CLOSE-ELEMENTS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HAS-CLOSE-ELEMENTS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "HAS-CLOSE-ELEMENTS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI COMP-2.
           05 L-THRESHOLD COMP-2.
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1.1 TO L-NUMBERS(1)
       MOVE 2.2 TO L-NUMBERS(2)
       MOVE 3.1 TO L-NUMBERS(3)
       MOVE 4.1 TO L-NUMBERS(4)
       MOVE 5.1 TO L-NUMBERS(5)
       MOVE 1.0 TO L-THRESHOLD

       CALL "HAS-CLOSE-ELEMENTS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HAS-CLOSE-ELEMENTS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "HAS-CLOSE-ELEMENTS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI COMP-2.
           05 L-THRESHOLD COMP-2.
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1.1 TO L-NUMBERS(1)
       MOVE 2.2 TO L-NUMBERS(2)
       MOVE 3.1 TO L-NUMBERS(3)
       MOVE 4.1 TO L-NUMBERS(4)
       MOVE 5.1 TO L-NUMBERS(5)
       MOVE 0.5 TO L-THRESHOLD

       CALL "HAS-CLOSE-ELEMENTS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEPARATE-PAREN-GROUPS.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-PAREN-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC X(100).

      * Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
      * separate those group into separate strings and return the list of those.
      * Separate groups are balanced (each open brace is properly closed) and not nested within each other
      * Ignore any spaces in the input string.
      * >>> separate_paren_groups('( ) (( )) (( )( ))')
      * ['()', '(())', '(()())']
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    result = []
    current_string = []
    current_depth = 0

    for c in paren_string:
        if c == '(':
            current_depth += 1
            current_string.append(c)
        elif c == ')':
            current_depth -= 1
            current_string.append(c)

            if current_depth == 0:
                result.append(''.join(current_string))
                current_string.clear()

    return result

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEPARATE-PAREN-GROUPS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEPARATE-PAREN-GROUPS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-PAREN-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC X(100).

       PROCEDURE DIVISION.

       MOVE '(()()) ((())) () ((())()())' TO L-PAREN-STRING

       CALL "SEPARATE-PAREN-GROUPS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEPARATE-PAREN-GROUPS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEPARATE-PAREN-GROUPS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-PAREN-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC X(100).

       PROCEDURE DIVISION.

       MOVE '() (()) ((())) (((())))' TO L-PAREN-STRING

       CALL "SEPARATE-PAREN-GROUPS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEPARATE-PAREN-GROUPS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEPARATE-PAREN-GROUPS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-PAREN-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC X(100).

       PROCEDURE DIVISION.

       MOVE '(()(())((())))' TO L-PAREN-STRING

       CALL "SEPARATE-PAREN-GROUPS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SEPARATE-PAREN-GROUPS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SEPARATE-PAREN-GROUPS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-PAREN-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC X(100).

       PROCEDURE DIVISION.

       MOVE '( ) (( )) (( )( ))' TO L-PAREN-STRING

       CALL "SEPARATE-PAREN-GROUPS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRUNCATE-NUMBER.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-NUMBER COMP-2.
           05 RESULT COMP-2.

      * Given a positive floating point number, it can be decomposed into
      * and integer part (largest integer smaller than given number) and decimals
      * (leftover part always smaller than 1).
      *
      * Return the decimal part of the number.
      * >>> truncate_number(3.5)
      * 0.5
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TRUNCATE-NUMBER-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "TRUNCATE-NUMBER.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(15).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 PARTS-REPR.
           05 DECIMAL-PART PIC X(9).
           05 FRACTIONAL-PART PIC X(5).
       01 FLOAT-REPR REDEFINES PARTS-REPR PIC S9(9)V9(5) SIGN LEADING.

       01 LINKED-ITEMS.
           05 L-NUMBER COMP-2.
           05 RESULT COMP-2.

       PROCEDURE DIVISION.

       MOVE 3.5 TO L-NUMBER

       CALL "TRUNCATE-NUMBER" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO FLOAT-REPR
       STRING DECIMAL-PART "." FRACTIONAL-PART INTO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. BELOW-ZERO.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-OPERATIONS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC 9.

      * You're given a list of deposit and withdrawal operations on a bank account that starts with
      * zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
      * at that point function should return True. Otherwise it should return False.
      * >>> below_zero([1, 2, 3])
      * False
      * >>> below_zero([1, 2, -4, 5])
      * True
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    balance = 0

    for op in operations:
        balance += op
        if balance < 0:
            return True

    return False

       IDENTIFICATION DIVISION.
       PROGRAM-ID. BELOW-ZERO-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "BELOW-ZERO.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-OPERATIONS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1 TO L-OPERATIONS(1)
       MOVE 2 TO L-OPERATIONS(2)
       MOVE -3 TO L-OPERATIONS(3)
       MOVE 1 TO L-OPERATIONS(4)
       MOVE 2 TO L-OPERATIONS(5)
       MOVE -3 TO L-OPERATIONS(6)

       CALL "BELOW-ZERO" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. BELOW-ZERO-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "BELOW-ZERO.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-OPERATIONS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1 TO L-OPERATIONS(1)
       MOVE 2 TO L-OPERATIONS(2)
       MOVE -4 TO L-OPERATIONS(3)
       MOVE 5 TO L-OPERATIONS(4)
       MOVE 6 TO L-OPERATIONS(5)

       CALL "BELOW-ZERO" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. BELOW-ZERO-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "BELOW-ZERO.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-OPERATIONS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1 TO L-OPERATIONS(1)
       MOVE -1 TO L-OPERATIONS(2)
       MOVE 2 TO L-OPERATIONS(3)
       MOVE -2 TO L-OPERATIONS(4)
       MOVE 5 TO L-OPERATIONS(5)
       MOVE -5 TO L-OPERATIONS(6)
       MOVE 4 TO L-OPERATIONS(7)
       MOVE -4 TO L-OPERATIONS(8)

       CALL "BELOW-ZERO" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. BELOW-ZERO-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "BELOW-ZERO.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-OPERATIONS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1 TO L-OPERATIONS(1)
       MOVE -1 TO L-OPERATIONS(2)
       MOVE 2 TO L-OPERATIONS(3)
       MOVE -2 TO L-OPERATIONS(4)
       MOVE 5 TO L-OPERATIONS(5)
       MOVE -5 TO L-OPERATIONS(6)
       MOVE 4 TO L-OPERATIONS(7)
       MOVE -5 TO L-OPERATIONS(8)

       CALL "BELOW-ZERO" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. BELOW-ZERO-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "BELOW-ZERO.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC 9.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-OPERATIONS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT PIC 9.

       PROCEDURE DIVISION.

       MOVE 1 TO L-OPERATIONS(1)
       MOVE -2 TO L-OPERATIONS(2)
       MOVE 2 TO L-OPERATIONS(3)
       MOVE -2 TO L-OPERATIONS(4)
       MOVE 5 TO L-OPERATIONS(5)
       MOVE -5 TO L-OPERATIONS(6)
       MOVE 4 TO L-OPERATIONS(7)
       MOVE -4 TO L-OPERATIONS(8)

       CALL "BELOW-ZERO" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. INTERSPERSE.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 L-DELIMETER PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

      * Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
      * >>> intersperse([], 4)
      * []
      * >>> intersperse([1, 2, 3], 4)
      * [1, 4, 2, 4, 3]
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    if not numbers:
        return []

    result = []

    for n in numbers[:-1]:
        result.append(n)
        result.append(delimeter)

    result.append(numbers[-1])

    return result

       IDENTIFICATION DIVISION.
       PROGRAM-ID. INTERSPERSE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "INTERSPERSE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 L-DELIMETER PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 5 TO L-NUMBERS(1)
       MOVE 6 TO L-NUMBERS(2)
       MOVE 3 TO L-NUMBERS(3)
       MOVE 2 TO L-NUMBERS(4)
       MOVE 8 TO L-DELIMETER

       CALL "INTERSPERSE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. INTERSPERSE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "INTERSPERSE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 L-DELIMETER PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 2 TO L-NUMBERS(1)
       MOVE 2 TO L-NUMBERS(2)
       MOVE 2 TO L-NUMBERS(3)
       MOVE 2 TO L-DELIMETER

       CALL "INTERSPERSE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PARSE-NESTED-PARENS.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-PAREN-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

      * Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
      * For each of the group, output the deepest level of nesting of parentheses.
      * E.g. (()()) has maximum two levels of nesting while ((())) has three.
      *
      * >>> parse_nested_parens('(()()) ((())) () ((())()())')
      * [2, 3, 1, 3]
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    def parse_paren_group(s):
        depth = 0
        max_depth = 0
        for c in s:
            if c == '(':
                depth += 1
                max_depth = max(depth, max_depth)
            else:
                depth -= 1

        return max_depth

    return [parse_paren_group(x) for x in paren_string.split(' ') if x]

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PARSE-NESTED-PARENS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PARSE-NESTED-PARENS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-PAREN-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE '(()()) ((())) () ((())()())' TO L-PAREN-STRING

       CALL "PARSE-NESTED-PARENS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PARSE-NESTED-PARENS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PARSE-NESTED-PARENS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-PAREN-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE '() (()) ((())) (((())))' TO L-PAREN-STRING

       CALL "PARSE-NESTED-PARENS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PARSE-NESTED-PARENS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PARSE-NESTED-PARENS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-PAREN-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE '(()(())((())))' TO L-PAREN-STRING

       CALL "PARSE-NESTED-PARENS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. FILTER-BY-SUBSTRING.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-STRINGS OCCURS 100 TIMES INDEXED BY NI PIC X(100).
           05 L-SUBSTRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC X(100).

      * Filter an input list of strings only for ones that contain given substring
      * >>> filter_by_substring([], 'a')
      * []
      * >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
      * ['abc', 'bacd', 'array']
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

return [x for x in strings if substring in x]

       IDENTIFICATION DIVISION.
       PROGRAM-ID. FILTER-BY-SUBSTRING-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "FILTER-BY-SUBSTRING.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRINGS OCCURS 100 TIMES INDEXED BY NI PIC X(100).
           05 L-SUBSTRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC X(100).

       PROCEDURE DIVISION.

       MOVE 'xxx' TO L-STRINGS(1)
       MOVE 'asd' TO L-STRINGS(2)
       MOVE 'xxy' TO L-STRINGS(3)
       MOVE 'john doe' TO L-STRINGS(4)
       MOVE 'xxxAAA' TO L-STRINGS(5)
       MOVE 'xxx' TO L-STRINGS(6)
       MOVE 'xxx' TO L-SUBSTRING

       CALL "FILTER-BY-SUBSTRING" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. FILTER-BY-SUBSTRING-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "FILTER-BY-SUBSTRING.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRINGS OCCURS 100 TIMES INDEXED BY NI PIC X(100).
           05 L-SUBSTRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC X(100).

       PROCEDURE DIVISION.

       MOVE 'xxx' TO L-STRINGS(1)
       MOVE 'asd' TO L-STRINGS(2)
       MOVE 'aaaxxy' TO L-STRINGS(3)
       MOVE 'john doe' TO L-STRINGS(4)
       MOVE 'xxxAAA' TO L-STRINGS(5)
       MOVE 'xxx' TO L-STRINGS(6)
       MOVE 'xx' TO L-SUBSTRING

       CALL "FILTER-BY-SUBSTRING" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. FILTER-BY-SUBSTRING-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "FILTER-BY-SUBSTRING.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRINGS OCCURS 100 TIMES INDEXED BY NI PIC X(100).
           05 L-SUBSTRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC X(100).

       PROCEDURE DIVISION.

       MOVE 'grunt' TO L-STRINGS(1)
       MOVE 'trumpet' TO L-STRINGS(2)
       MOVE 'prune' TO L-STRINGS(3)
       MOVE 'gruesome' TO L-STRINGS(4)
       MOVE 'run' TO L-SUBSTRING

       CALL "FILTER-BY-SUBSTRING" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SUM-PRODUCT.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

      * For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
      * Empty sum should be equal to 0 and empty product should be equal to 1.
      * >>> sum_product([])
      * (0, 1)
      * >>> sum_product([1, 2, 3, 4])
      * (10, 24)
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    sum_value = 0
    prod_value = 1

    for n in numbers:
        sum_value += n
        prod_value *= n
    return sum_value, prod_value

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SUM-PRODUCT-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-PRODUCT.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-NUMBERS(1)
       MOVE 1 TO L-NUMBERS(2)
       MOVE 1 TO L-NUMBERS(3)

       CALL "SUM-PRODUCT" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SUM-PRODUCT-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-PRODUCT.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 100 TO L-NUMBERS(1)
       MOVE 0 TO L-NUMBERS(2)

       CALL "SUM-PRODUCT" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SUM-PRODUCT-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-PRODUCT.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 3 TO L-NUMBERS(1)
       MOVE 5 TO L-NUMBERS(2)
       MOVE 7 TO L-NUMBERS(3)

       CALL "SUM-PRODUCT" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SUM-PRODUCT-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SUM-PRODUCT.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 10 TO L-NUMBERS(1)

       CALL "SUM-PRODUCT" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. ROLLING-MAX.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

      * From a given list of integers, generate a list of rolling maximum element found until given moment
      * in the sequence.
      * >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
      * [1, 2, 3, 3, 3, 4, 4]
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    running_max = None
    result = []

    for n in numbers:
        if running_max is None:
            running_max = n
        else:
            running_max = max(running_max, n)

        result.append(running_max)

    return result

       IDENTIFICATION DIVISION.
       PROGRAM-ID. ROLLING-MAX-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "ROLLING-MAX.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 1 TO L-NUMBERS(1)
       MOVE 2 TO L-NUMBERS(2)
       MOVE 3 TO L-NUMBERS(3)
       MOVE 4 TO L-NUMBERS(4)

       CALL "ROLLING-MAX" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. ROLLING-MAX-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "ROLLING-MAX.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 4 TO L-NUMBERS(1)
       MOVE 3 TO L-NUMBERS(2)
       MOVE 2 TO L-NUMBERS(3)
       MOVE 1 TO L-NUMBERS(4)

       CALL "ROLLING-MAX" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. ROLLING-MAX-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "ROLLING-MAX.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
           05 RESULT OCCURS 100 TIMES INDEXED BY NJ PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 3 TO L-NUMBERS(1)
       MOVE 2 TO L-NUMBERS(2)
       MOVE 3 TO L-NUMBERS(3)
       MOVE 100 TO L-NUMBERS(4)
       MOVE 3 TO L-NUMBERS(5)

       CALL "ROLLING-MAX" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NJ FROM 1 BY 1 UNTIL NJ > 100
           MOVE RESULT (NJ) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRING-XOR.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-A PIC X(100).
           05 L-B PIC X(100).
           05 RESULT PIC X(100).

      * Input are two strings a and b consisting only of 1s and 0s.
      * Perform binary XOR on these inputs and return result also as a string.
      * >>> string_xor('010', '110')
      * '100'
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    def xor(i, j):
        if i == j:
            return '0'
        else:
            return '1'

    return ''.join(xor(x, y) for x, y in zip(a, b))

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRING-XOR-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRING-XOR.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-A PIC X(100).
           05 L-B PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE '111000' TO L-A
       MOVE '101010' TO L-B

       CALL "STRING-XOR" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRING-XOR-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRING-XOR.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-A PIC X(100).
           05 L-B PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE '1' TO L-A
       MOVE '1' TO L-B

       CALL "STRING-XOR" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRING-XOR-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRING-XOR.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-A PIC X(100).
           05 L-B PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE '0101' TO L-A
       MOVE '0000' TO L-B

       CALL "STRING-XOR" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. LONGEST.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-STRINGS OCCURS 100 TIMES INDEXED BY NI PIC X(100).
           05 RESULT PIC X(100).

      * Out of list of strings, return the longest one. Return the first one in case of multiple
      * strings of the same length. Return '' in case the input list is empty.
      * >>> longest([])
      *
      * >>> longest(['a', 'b', 'c'])
      * 'a'
      * >>> longest(['a', 'bb', 'ccc'])
      * 'ccc'
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    if not strings:
        return None

    maxlen = max(len(x) for x in strings)
    for s in strings:
        if len(s) == maxlen:
            return s

       IDENTIFICATION DIVISION.
       PROGRAM-ID. LONGEST-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "LONGEST.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRINGS OCCURS 100 TIMES INDEXED BY NI PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE 'x' TO L-STRINGS(1)
       MOVE 'y' TO L-STRINGS(2)
       MOVE 'z' TO L-STRINGS(3)

       CALL "LONGEST" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. LONGEST-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "LONGEST.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRINGS OCCURS 100 TIMES INDEXED BY NI PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE 'x' TO L-STRINGS(1)
       MOVE 'yyy' TO L-STRINGS(2)
       MOVE 'zzzz' TO L-STRINGS(3)
       MOVE 'www' TO L-STRINGS(4)
       MOVE 'kkkk' TO L-STRINGS(5)
       MOVE 'abc' TO L-STRINGS(6)

       CALL "LONGEST" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. GREATEST-COMMON-DIVISOR.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 RESULT PIC S9(10).

      * Return a greatest common divisor of two integers a and b
      * >>> greatest_common_divisor(3, 5)
      * 1
      * >>> greatest_common_divisor(25, 15)
      * 5
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    while b:
        a, b = b, a % b
    return a

       IDENTIFICATION DIVISION.
       PROGRAM-ID. GREATEST-COMMON-DIVISOR-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "GREATEST-COMMON-DIVISOR.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 3 TO L-A
       MOVE 7 TO L-B

       CALL "GREATEST-COMMON-DIVISOR" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. GREATEST-COMMON-DIVISOR-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "GREATEST-COMMON-DIVISOR.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 10 TO L-A
       MOVE 15 TO L-B

       CALL "GREATEST-COMMON-DIVISOR" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. GREATEST-COMMON-DIVISOR-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "GREATEST-COMMON-DIVISOR.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 49 TO L-A
       MOVE 14 TO L-B

       CALL "GREATEST-COMMON-DIVISOR" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. GREATEST-COMMON-DIVISOR-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "GREATEST-COMMON-DIVISOR.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-A PIC S9(10).
           05 L-B PIC S9(10).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 144 TO L-A
       MOVE 60 TO L-B

       CALL "GREATEST-COMMON-DIVISOR" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. ALL-PREFIXES.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC X(100).

      * Return list of all prefixes from shortest to longest of the input string
      * >>> all_prefixes('abc')
      * ['a', 'ab', 'abc']
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    result = []

    for i in range(len(string)):
        result.append(string[:i+1])
    return result

       IDENTIFICATION DIVISION.
       PROGRAM-ID. ALL-PREFIXES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "ALL-PREFIXES.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC X(100).

       PROCEDURE DIVISION.

       MOVE '' TO L-STRING

       CALL "ALL-PREFIXES" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. ALL-PREFIXES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "ALL-PREFIXES.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC X(100).

       PROCEDURE DIVISION.

       MOVE 'asdfgh' TO L-STRING

       CALL "ALL-PREFIXES" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

['a', 'as', 'asd', 'asdf', 'asdfg', 'asdfgh']

       IDENTIFICATION DIVISION.
       PROGRAM-ID. ALL-PREFIXES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "ALL-PREFIXES.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC X(100).

       PROCEDURE DIVISION.

       MOVE 'WWW' TO L-STRING

       CALL "ALL-PREFIXES" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRING-SEQUENCE.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-N PIC S9(10).
           05 RESULT PIC X(100).

      * Return a string containing space-delimited numbers starting from 0 upto n inclusive.
      * >>> string_sequence(0)
      * '0'
      * >>> string_sequence(5)
      * '0 1 2 3 4 5'
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

return ' '.join([str(x) for x in range(n + 1)])

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRING-SEQUENCE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRING-SEQUENCE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-N PIC S9(10).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE 0 TO L-N

       CALL "STRING-SEQUENCE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRING-SEQUENCE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRING-SEQUENCE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-N PIC S9(10).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE 3 TO L-N

       CALL "STRING-SEQUENCE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. STRING-SEQUENCE-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "STRING-SEQUENCE.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-N PIC S9(10).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE 10 TO L-N

       CALL "STRING-SEQUENCE" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. COUNT-DISTINCT-CHARACTERS.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 RESULT PIC S9(10).

      * Given a string, find out how many distinct characters (regardless of case) does it consist of
      * >>> count_distinct_characters('xyzXYZ')
      * 3
      * >>> count_distinct_characters('Jerry')
      * 4
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

       IDENTIFICATION DIVISION.
       PROGRAM-ID. COUNT-DISTINCT-CHARACTERS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "COUNT-DISTINCT-CHARACTERS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE '' TO L-STRING

       CALL "COUNT-DISTINCT-CHARACTERS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. COUNT-DISTINCT-CHARACTERS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "COUNT-DISTINCT-CHARACTERS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 'abcde' TO L-STRING

       CALL "COUNT-DISTINCT-CHARACTERS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. COUNT-DISTINCT-CHARACTERS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "COUNT-DISTINCT-CHARACTERS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 'aaaaAAAAaaaa' TO L-STRING

       CALL "COUNT-DISTINCT-CHARACTERS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. COUNT-DISTINCT-CHARACTERS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "COUNT-DISTINCT-CHARACTERS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 'Jerry jERRY JeRRRY' TO L-STRING

       CALL "COUNT-DISTINCT-CHARACTERS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PARSE-MUSIC.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-MUSIC-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

      * Input to this function is a string representing musical notes in a special ASCII format.
      * Your task is to parse this string and return list of integers corresponding to how many beats does each
      * not last.
      *
      * Here is a legend:
      * 'o' - whole note, lasts four beats
      * 'o|' - half note, lasts two beats
      * '.|' - quater note, lasts one beat
      *
      * >>> parse_music('o o| .| o| o| .| .| .| .| o o')
      * [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    note_map = {'o': 4, 'o|': 2, '.|': 1}
    return [note_map[x] for x in music_string.split(' ') if x]

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PARSE-MUSIC-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PARSE-MUSIC.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-MUSIC-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE '' TO L-MUSIC-STRING

       CALL "PARSE-MUSIC" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PARSE-MUSIC-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PARSE-MUSIC.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-MUSIC-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 'o o o o' TO L-MUSIC-STRING

       CALL "PARSE-MUSIC" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PARSE-MUSIC-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PARSE-MUSIC.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-MUSIC-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE '.| .| .| .|' TO L-MUSIC-STRING

       CALL "PARSE-MUSIC" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PARSE-MUSIC-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PARSE-MUSIC.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-MUSIC-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 'o| o| .| .| o o o o' TO L-MUSIC-STRING

       CALL "PARSE-MUSIC" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PARSE-MUSIC-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "PARSE-MUSIC.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-MUSIC-STRING PIC X(100).
           05 RESULT OCCURS 100 TIMES INDEXED BY NI PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 'o| .| o| .| o o| o o|' TO L-MUSIC-STRING

       CALL "PARSE-MUSIC" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
           MOVE RESULT (NI) TO OUTPUT-RECORD
           WRITE OUTPUT-RECORD
       END-PERFORM

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. HOW-MANY-TIMES.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 L-SUBSTRING PIC X(100).
           05 RESULT PIC S9(10).

      * Find how many times a given substring can be found in the original string. Count overlaping cases.
      * >>> how_many_times('', 'a')
      * 0
      * >>> how_many_times('aaa', 'a')
      * 3
      * >>> how_many_times('aaaa', 'aa')
      * 3
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    times = 0

    for i in range(len(string) - len(substring) + 1):
        if string[i:i+len(substring)] == substring:
            times += 1

    return times

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HOW-MANY-TIMES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "HOW-MANY-TIMES.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 L-SUBSTRING PIC X(100).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE '' TO L-STRING
       MOVE 'x' TO L-SUBSTRING

       CALL "HOW-MANY-TIMES" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HOW-MANY-TIMES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "HOW-MANY-TIMES.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 L-SUBSTRING PIC X(100).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 'xyxyxyx' TO L-STRING
       MOVE 'x' TO L-SUBSTRING

       CALL "HOW-MANY-TIMES" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HOW-MANY-TIMES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "HOW-MANY-TIMES.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 L-SUBSTRING PIC X(100).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 'cacacacac' TO L-STRING
       MOVE 'cac' TO L-SUBSTRING

       CALL "HOW-MANY-TIMES" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HOW-MANY-TIMES-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "HOW-MANY-TIMES.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC S9(10) SIGN LEADING.

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-STRING PIC X(100).
           05 L-SUBSTRING PIC X(100).
           05 RESULT PIC S9(10).

       PROCEDURE DIVISION.

       MOVE 'john doe' TO L-STRING
       MOVE 'john' TO L-SUBSTRING

       CALL "HOW-MANY-TIMES" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .


Prompt:
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SORT-NUMBERS.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       DATA DIVISION.

       LINKAGE SECTION.

       01 LINKED-ITEMS.
           05 L-NUMBERS PIC X(100).
           05 RESULT PIC X(100).

      * Input is a space-delimited string of numberals from 'zero' to 'nine'.
      * Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
      * Return the string with numbers sorted from smallest to largest
      * >>> sort_numbers('three one five')
      * 'one three five'
      *

      * Complete the WORKING-STORAGE SECTION and the PROCEDURE DIVISION
      * Store the result in the RESULT variable and mark the end of your program with END PROGRAM

       WORKING-STORAGE SECTION.

    value_map = {
        'zero': 0,
        'one': 1,
        'two': 2,
        'three': 3,
        'four': 4,
        'five': 5,
        'six': 6,
        'seven': 7,
        'eight': 8,
        'nine': 9
    }
    return ' '.join(sorted([x for x in numbers.split(' ') if x], key=lambda x: value_map[x]))

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SORT-NUMBERS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SORT-NUMBERS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE '' TO L-NUMBERS

       CALL "SORT-NUMBERS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SORT-NUMBERS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SORT-NUMBERS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE 'three' TO L-NUMBERS

       CALL "SORT-NUMBERS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SORT-NUMBERS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SORT-NUMBERS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE 'three five nine' TO L-NUMBERS

       CALL "SORT-NUMBERS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SORT-NUMBERS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SORT-NUMBERS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE 'five zero four seven nine eight' TO L-NUMBERS

       CALL "SORT-NUMBERS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SORT-NUMBERS-CALL.

       ENVIRONMENT DIVISION.

       INPUT-OUTPUT SECTION.

       FILE-CONTROL.

       SELECT OUTPUT-FILE ASSIGN TO "SORT-NUMBERS.TXT"
           ORGANIZATION IS LINE SEQUENTIAL
           STATUS IS OUTPUT-FILE-STATUS.

       DATA DIVISION.

       FILE SECTION.
       FD OUTPUT-FILE.
       01 OUTPUT-RECORD PIC X(100).

       WORKING-STORAGE SECTION.

       01 OUTPUT-FILE-STATUS PIC X(02).

       01 LINKED-ITEMS.
           05 L-NUMBERS PIC X(100).
           05 RESULT PIC X(100).

       PROCEDURE DIVISION.

       MOVE 'six five four three two one zero' TO L-NUMBERS

       CALL "SORT-NUMBERS" USING LINKED-ITEMS

       OPEN OUTPUT OUTPUT-FILE

       IF OUTPUT-FILE-STATUS NOT = "00"
           DISPLAY "ERROR OPENING OUTPUT FILE"
           STOP RUN
        END-IF

       MOVE RESULT TO OUTPUT-RECORD
       WRITE OUTPUT-RECORD

        IF OUTPUT-FILE-STATUS NOT = "00"
            DISPLAY "ERROR WRITING TO OUTPUT FILE"
            STOP RUN
        END-IF

        CLOSE OUTPUT-FILE
        .