diff options
| author | Bond_009 <bond.009@outlook.com> | 2022-12-01 22:30:22 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2022-12-01 22:30:22 +0100 |
| commit | baf4910870a6e8999802b9a4a22eabd4142a34e3 (patch) | |
| tree | 2d11443dc21e53bd0d99d015cf789937d6d95862 /9/part2.f90 | |
| parent | 49d0c908f24b2c193c9deed1716fe36061ba26a1 (diff) | |
Move all Advent of Codes into one repo
Diffstat (limited to '9/part2.f90')
| -rw-r--r-- | 9/part2.f90 | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/9/part2.f90 b/9/part2.f90 deleted file mode 100644 index b7e65de..0000000 --- a/9/part2.f90 +++ /dev/null @@ -1,60 +0,0 @@ -integer function has_sum(arg, arr) - implicit none - - integer, parameter :: arr_len = 25 - - integer (kind=8) :: arg - integer (kind=8), dimension(25) :: arr - integer :: i, j - - do i = 1, arr_len - do j = 1, arr_len - if (arr(i) + arr(j) == arg) then - has_sum = 1 - return - end if - end do - end do - - has_sum = 0 - return -end function has_sum - -program day9 - implicit none - - integer, parameter :: input_len = 1000 - - integer :: has_sum, i, j, tmp - integer (kind=8), dimension(input_len) :: input - integer (kind=8) :: search = -1, sum - - open(10, file='input', status='old') - do i = 1, input_len - read(10, *) input(i) - end do - close(10) - - do i = 26, input_len - tmp = has_sum(input(i), input(i - 25)) - if (tmp == 0) then - search = input(i) - exit - end if - end do - - do i = 1, input_len - sum = 0 - do j = i, input_len - sum = sum + input(j) - if (sum >= search) then - exit - end if - end do - if (sum == search) then - print *, minval(input(i:j)) + maxval(input(i:j)) - stop - end if - end do - -end program day9 |
