Skip to content

Commit

Permalink
Code compression
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Oct 2, 2024
1 parent 9d62bfc commit 70dc500
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
2 changes: 2 additions & 0 deletions docs/src/fortran/lib/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ View source code :source:`fortran/include/constants.f90`
.. f:variable:: i1t
:type: integer
.. f:variable:: i2t
:type: integer
.. f:variable:: i4t
:type: integer
.. f:variable:: i18t
Expand Down
1 change: 1 addition & 0 deletions fortran/src/include/constants.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module constants
implicit none

integer, parameter :: i1t = selected_int_kind(1)
integer, parameter :: i2t = selected_int_kind(2)
integer, parameter :: i4t = selected_int_kind(4)
integer, parameter :: i18t = selected_int_kind(18)

Expand Down
5 changes: 1 addition & 4 deletions fortran/src/p0002.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ module Problem0002
implicit none
contains
integer function p0002() result(answer)
integer :: a
integer :: b
integer :: i
integer :: tmp
integer :: a, b, i, tmp
answer = 0
a = 1
b = 2
Expand Down
4 changes: 1 addition & 3 deletions fortran/src/p0006.f90
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ module Problem0006
implicit none
contains
integer function p0006() result(answer)
integer :: sum
integer :: sum_of_squares
integer :: i
integer :: sum, sum_of_squares, i
answer = 0
sum = 1
sum_of_squares = 1
Expand Down
9 changes: 5 additions & 4 deletions fortran/src/p0008.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
! Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product?

module Problem0008
use constants
implicit none
contains
integer(kind=8) function p0008() result(answer)
integer(kind=4) :: i, j
integer(kind=8) :: tmp
integer(kind=1), dimension(1000) :: digits
integer(i18t) function p0008() result(answer)
integer :: i, j
integer(i18t) :: tmp
integer(i1t), dimension(1000) :: digits
character(len=1000) :: plain_digits
answer = 0
plain_digits = ("73167176531330624919225119674426574742355349194934" // &
Expand Down
7 changes: 4 additions & 3 deletions fortran/src/p0011.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
! the 20×20 grid?

module Problem0011
use constants
implicit none

contains

integer(kind=8) function p0011() result(answer)
integer(kind=2), dimension(20, 20) :: grid
integer(kind=8) :: tmp
integer(i18t) function p0011() result(answer)
integer(i2t), dimension(20, 20) :: grid
integer(i18t) :: tmp
integer :: i, j

! Manually initialize the grid
Expand Down
11 changes: 6 additions & 5 deletions fortran/src/p0013.f90
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,16 @@
! 53503534226472524250874054075591789781264330331690

module Problem0013
use constants
implicit none

contains

integer(kind=8) function p0013() result(answer)
integer(kind=8), dimension(3, 100) :: numbers
integer(kind=8), dimension(3) :: arr
integer(kind=8) :: ten18 = 1000000000000000000_8
integer(kind=8) :: ten10 = 10000000000_8
integer(i18t) function p0013() result(answer)
integer(i18t), dimension(3, 100) :: numbers
integer(i18t), dimension(3) :: arr
integer(i18t) :: ten18 = 1000000000000000000_8
integer(i18t) :: ten10 = 10000000000_8
integer :: i, j

! Manually initialize the grid
Expand Down

0 comments on commit 70dc500

Please sign in to comment.