From 0880a0dfbb4b71caad75aaae5daf23eb2d2db5d5 Mon Sep 17 00:00:00 2001 From: Trey Bastian Date: Mon, 1 Dec 2025 13:38:55 +0000 Subject: 2025 day 1 part 1 --- 2025/day_01.cbl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 2025/day_01.cbl (limited to '2025/day_01.cbl') diff --git a/2025/day_01.cbl b/2025/day_01.cbl new file mode 100644 index 0000000..9c5c062 --- /dev/null +++ b/2025/day_01.cbl @@ -0,0 +1,51 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. day_01. + AUTHOR. Trey Bastian. + ENVIRONMENT DIVISION. + INPUT-OUTPUT SECTION. + FILE-CONTROL. + SELECT input-file ASSIGN TO "./input.txt" + ORGANIZATION IS LINE SEQUENTIAL. + DATA DIVISION. + FILE SECTION. + FD input-file. + 01 input-line. + 02 direction PIC X. + 02 move-text PIC XXX. + WORKING-STORAGE SECTION. + 01 dial-position PIC 9(2) VALUE 50. + 01 move-num PIC S9(3). + 01 zero-count PIC 9(4) VALUE ZEROS. + 01 eof PIC X. + 88 eof-y VALUE "Y". + 88 eof-n VALUE "N". + + + PROCEDURE DIVISION. + OPEN INPUT input-file. + SET eof-n to TRUE. + PERFORM UNTIL eof-y + READ input-file AT END + SET eof-y to TRUE + NOT AT END + MOVE FUNCTION NUMVAL(move-text) TO move-num + IF direction = "L" + COMPUTE move-num = 0 - move-num + END-IF + + COMPUTE dial-position = FUNCTION MOD(dial-position + + move-num, 100) + + if dial-position < 0 + ADD 100 to dial-position + END-IF + + if dial-position = 0 + ADD 1 to zero-count + END-IF + END-READ + END-PERFORM. + CLOSE input-file. + DISPLAY zero-count. + STOP-RUN. + -- cgit v1.2.3