aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrey Bastian <hello@treybastian.com>2025-12-01 13:38:55 +0000
committerTrey Bastian <hello@treybastian.com>2025-12-01 13:38:55 +0000
commit0880a0dfbb4b71caad75aaae5daf23eb2d2db5d5 (patch)
tree1dc67f293c165038a9f9a0b21601c97080f36667
parent57a504da9dbedc835d432bc420551c4f6349e1d0 (diff)
2025 day 1 part 1
-rw-r--r--.gitignore2
-rw-r--r--2025/day_01.cbl51
-rw-r--r--README.md7
3 files changed, 59 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1a48760
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+input.txt
+input_test.txt
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.
+
diff --git a/README.md b/README.md
index f1902bc..7aabf1c 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,12 @@
# Advent of Code Repo
This repository contains my solutions to the Advent of Code challenges.
+## 2025 - COBOL
+You'll need to install GNUCobol to run these solutions.
+
+On MacOS you can install it with Homebrew: `brew install gnucobol`
+
## 2024 - Fortran
You'll need GNUFortran to run these solutions.
-On MacOS, you can install it with Homebrew with `brew install gcc`.
+On MacOS, you can install it with Homebrew: `brew install gcc`.