+----+----+----+----+
| 23 | | | |
+----+----+----+----+
| | | 64 | |
+----+----+----+----+
| | N | | |
+----+----+----+----+
| | | |101 |
+----+----+----+----+
In the 4x4 grid provided above:
- Each the 16 values appearing in the 16 cells is a positive integer.
- The 4 values corresponding to each of the 4 rows are in arithmetic sequence.
- The 4 values corresponding to each of the 4 columns are in arithmetic sequence.
Determine the total number of
distinct positive integer values that N can assume.
clearvars,clc
N=[];
grid=zeros(4,4);
grid(1,1)=23;
grid(2,3)=64;
grid(4,4)=101;
for final=1:2000
incr=(final-23)/3;
if incr==round(incr)
incr2=(101-final)/3;
if incr2==round(incr2);
for c=2:4
grid(1,c)=23+incr*(c-1);
end
incr3=64-grid(1,3);
grid(4,3)=64+2*incr3;
if grid(4,3)>0
incr5=grid(4,3)-101;
grid(4,1)=101+3*incr5;
if grid(4,1)>0
incr6=(grid(4,1)-grid(1,1))/3;
if incr6==round(incr6)
grid(1,2)=23+incr;
grid(4,2)=101+2*incr5;
incr7=(grid(4,2)-grid(1,2))/3;
if incr7==round(incr7)
N(end+1)=grid(1,2)+2*incr7;
grid(3,2)=N(end)
end
end
end
end
end
end
end
disp(sort(N))
disp(length(N))
finds N has 27 possible values:
40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170
The top row can decrement by at most 7, as after that, its last element would be negative.
That row's increment can be no larger than 19 as higher numbers cause the first number in the bottom row to become negative, forced by the sequences in the last two columns and the subsequent bottom row sequence.
In context (numbers not involved in validation shown as zero):
grid =
23 16 9 2
0 0 64 0
0 170 0 0
320 247 174 101
grid =
23 17 11 5
0 0 64 0
0 165 0 0
308 239 170 101
grid =
23 18 13 8
0 0 64 0
0 160 0 0
296 231 166 101
grid =
23 19 15 11
0 0 64 0
0 155 0 0
284 223 162 101
grid =
23 20 17 14
0 0 64 0
0 150 0 0
272 215 158 101
grid =
23 21 19 17
0 0 64 0
0 145 0 0
260 207 154 101
grid =
23 22 21 20
0 0 64 0
0 140 0 0
248 199 150 101
grid =
23 23 23 23
0 0 64 0
0 135 0 0
236 191 146 101
grid =
23 24 25 26
0 0 64 0
0 130 0 0
224 183 142 101
grid =
23 25 27 29
0 0 64 0
0 125 0 0
212 175 138 101
grid =
23 26 29 32
0 0 64 0
0 120 0 0
200 167 134 101
grid =
23 27 31 35
0 0 64 0
0 115 0 0
188 159 130 101
grid =
23 28 33 38
0 0 64 0
0 110 0 0
176 151 126 101
grid =
23 29 35 41
0 0 64 0
0 105 0 0
164 143 122 101
grid =
23 30 37 44
0 0 64 0
0 100 0 0
152 135 118 101
grid =
23 31 39 47
0 0 64 0
0 95 0 0
140 127 114 101
grid =
23 32 41 50
0 0 64 0
0 90 0 0
128 119 110 101
grid =
23 33 43 53
0 0 64 0
0 85 0 0
116 111 106 101
grid =
23 34 45 56
0 0 64 0
0 80 0 0
104 103 102 101
grid =
23 35 47 59
0 0 64 0
0 75 0 0
92 95 98 101
grid =
23 36 49 62
0 0 64 0
0 70 0 0
80 87 94 101
grid =
23 37 51 65
0 0 64 0
0 65 0 0
68 79 90 101
grid =
23 38 53 68
0 0 64 0
0 60 0 0
56 71 86 101
grid =
23 39 55 71
0 0 64 0
0 55 0 0
44 63 82 101
grid =
23 40 57 74
0 0 64 0
0 50 0 0
32 55 78 101
grid =
23 41 59 77
0 0 64 0
0 45 0 0
20 47 74 101
grid =
23 42 61 80
0 0 64 0
0 40 0 0
8 39 70 101
Edited on February 12, 2023, 9:36 am
|
Posted by Charlie
on 2023-02-12 09:16:29 |