
please wait
24 50 17 -17 52 7 61 41 45 47 -12 28 64 10 44 74 78 25 10 19 74 -13 -15 36 75 65 4 -1 1 78 30 9 54 21 52 -5 50 82 18 77 -14 -6 5 16 56 47 24 -6 36 51 30 27 45 40 20 42 6 24 12 61 -1 18 73 25 71 -11 23 25 47 31 29 -12 73 12 53 33 -11 -16 76 31 12 6 67 37 39 23 49 59 14 -9 27 22 9 6 20 21 1 65 12 24 16 -2 22 41 -13 13 60 -11 56 69 4 28 7 55 53 12 60 56 80 -5 69 73 44 19 38 50 38 57 14 35 33 33 24 7 49 13 -10 74 -10 20 40 70 36 66 28 -8 -8 41 4 71 5 29 -11 13 -4 51 -17 74 45 38 -7 42 7 20 31 66 78 24 -15 33 74 19 57 3 79 4 31 82 51 67 64 17 36 82 1 21 -17 71 10 50 11 76 31 66 -10 4 -7 0 -4 -3 -8 -1 18 34 -17 32 2 39 81 -14 7 -9 27 -8 72 -15 78 68 76 26 6 70 -3 -14 31 |
|
|
*--- /|\ / | \ / | \ |
|
|
Sum Vertical: 1 161 Sum Vertical: 1 89 Sum Vertical: 1 170 Sum Vertical: 1 -13415 //every 4th number is wrong Sum Vertical: 2 90 Sum Vertical: 2 55 Sum Vertical: 2 131 Sum Vertical: 2 63 Sum Vertical: 3 50 Sum Vertical: 3 163 Sum Vertical: 3 7 Sum Vertical: 3 -2145620874 on horizontal the last number on row 4 is 171, it should be 138 on row 7 the last number is 200, it should be 191 on row 9 the last number is 121, it should be 112 on row 11 the last number is 264, it should be 200 |
|
|
i += 4
suggests to me that your starting values are going up in 4s.Best quadruplet: 69 50 70 74 Biggest sum: 263 24 50 17 -17 52 7 61 41 45 47 -12 28 64 10 44 74 78 25 10 19 74 -13 -15 36 75 65 4 -1 1 78 30 9 54 21 52 -5 50 82 18 77 -14 -6 5 16 56 47 24 -6 36 51 30 27 45 40 20 42 6 24 12 61 -1 18 73 25 71 -11 23 25 47 31 29 -12 73 12 53 33 -11 -16 76 31 12 6 67 37 39 23 49 59 14 -9 27 22 9 6 20 21 1 65 12 24 16 -2 22 41 -13 13 60 -11 56 69 4 28 7 55 53 12 60 56 80 -5 69 73 44 19 38 50 38 57 14 35 33 33 24 7 49 13 -10 74 -10 20 40 70 36 66 28 -8 -8 41 4 71 5 29 -11 13 -4 51 -17 74 45 38 -7 42 7 20 31 66 78 24 -15 33 74 19 57 3 79 4 31 82 51 67 64 17 36 82 1 21 -17 71 10 50 11 76 31 66 -10 4 -7 0 -4 -3 -8 -1 18 34 -17 32 2 39 81 -14 7 -9 27 -8 72 -15 78 68 76 26 6 70 -3 -14 31 |
XboxOne2019 wrote: |
---|
could someone show me a loop to demonstrate what they are saying? |
program bestquad implicit none integer, parameter :: N = 15 integer A(N,N) integer bestline(4), largest, i, j, r open( 10, file="input.txt" ) read( 10, * ) A bestline = A(1:4,1) largest = sum( bestline ) do i = 1, N do j = 1, N if ( i + 3 <= N ) call test( A(i:i+3,j) ) if ( j + 3 <= N ) call test( A(i,j:j+3) ) if ( i + 3 <= N .and. j + 3 <= N ) call test( [ ( A(i+r,j+r), r = 0, 3 ) ] ) if ( i - 3 >= 1 .and. j + 3 <= N ) call test( [ ( A(i-r,j+r), r = 0, 3 ) ] ) end do end do write( *, "( 'Best quadruplet: ', 4( i0, 1x ) )" ) bestline write( *, "( 'Biggest sum: ', i0 )" ) largest contains subroutine test( line ) integer, intent(in) :: line(4) if ( sum( line ) > largest ) then largest = sum( line ) bestline = line end if end subroutine test end program bestquad |