Created
November 6, 2021 16:39
-
-
Save vijfhoek/1bf1ca4aa29042b8f4d68e30131416ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| identification division. | |
| program-id. aoc03part1. | |
| data division. | |
| working-storage section. | |
| 01 ws-input pic x(10000). | |
| 01 ws-char pic x. | |
| 01 ws-i pic 9(10). | |
| 01 ws-x pic 9(10). | |
| 01 ws-y pic 9(10). | |
| 01. | |
| 05 occurs 200 times. | |
| 10 occurs 200 times. | |
| 15 ws-houses pic 9 value 0. | |
| 01 ws-count pic 9(10). | |
| procedure division. | |
| main-para. | |
| initialize ws-i. | |
| move 100 to ws-x. | |
| move 100 to ws-y. | |
| move 1 to ws-houses(100, 100). | |
| move 1 to ws-count. | |
| accept ws-input. | |
| perform loop-para with test after until ws-char = ' '. | |
| display ws-count. | |
| stop run. | |
| loop-para. | |
| add 1 to ws-i. | |
| move ws-input(ws-i:ws-i) to ws-char. | |
| if ws-char = 'v' then | |
| add 1 to ws-y. | |
| if ws-char = '^' then | |
| subtract 1 from ws-y. | |
| if ws-char = '>' then | |
| add 1 to ws-x. | |
| if ws-char = '<' then | |
| subtract 1 from ws-x. | |
| if ws-houses(ws-x, ws-y) = 0 then | |
| add 1 to ws-count | |
| move 1 to ws-houses(ws-x, ws-y) | |
| end-if. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment