A and B are base-α digits from 1 to α-1. Determine all triplets (A,B,α) with 2 ≤ α ≤ 36 that satisfy this relationship:
(AB)base α degrees Celsius
= (BA)base α degrees Fahrenheit
Notes:
(1) F = (9/5)*C + 32base 10, where F denotes degree(s) Fahrenheit and C denotes degrees Celsius.
(2) Each of AB and BA denotes concatenation of digits.
(3) α is a positive integer.
For exact matches:
clearvars, clc
digSource= ['0':'9' 'A':'Z'];
for base = 2:36
digs=extractBefore(digSource,base+1) ;
for a=1:base
for b=1:base
c=[digs(a) digs(b)];
celsius=base2dec(c,base);
f=flip(c);
fahr=base2dec(f,base);
if fahr==celsius*9/5+32
disp([c(1) ' ' c(2) ' ' char(string(base))])
disp([celsius fahr])
end
end
end
end
The format is
A B base
Celsius Fahrenheit (decimal)
in each grouping.
6 E 16
110 230
2 6 17
40 104
8 H 21
185 365
3 7 26
85 185
A K 29
310 590
8 G 33
280 536
Notice there were no base-10 results. The base 10 results in the original Temperature Reflection were dependent on rounding.
Allowing rounding, the second part of the program:
disp(' ')
for base = 2:36
digs=extractBefore(digSource,base+1) ;
for a=1:base
for b=1:base
c=[digs(a) digs(b)];
celsius=base2dec(c,base);
f=flip(c);
fahr=base2dec(f,base);
minFfromC=(celsius-.5)*9/5+32;
maxFfromC=(celsius+.5)*9/5+32;
minFahr=fahr-.5;
maxFahr=fahr+.5;
if minFahr<=maxFfromC && maxFahr>=minFfromC
disp([c(1) ' ' c(2) ' ' char(string(base))])
disp([celsius fahr])
end
end
end
end
(some have leading zeros; ignore them, such as 4 and 40 in decimal base.)
0 6 7
6 42
0 5 8
5 40
0 4 10
4 40
1 6 10
16 61
2 8 10
28 82
0 3 12
3 36
4 A 16
74 164
5 C 16
92 197
6 E 16
110 230
1 4 17
21 69
2 6 17
40 104
3 8 17
59 139
0 2 18
2 36
1 4 18
22 73
9 J 20
199 389
8 H 21
185 365
6 D 22
145 292
7 F 22
169 337
5 B 23
126 258
6 D 23
151 305
4 9 24
105 220
5 B 24
131 269
4 9 25
109 229
3 7 26
85 185
C O 26
336 636
2 5 27
59 137
B M 27
319 605
2 5 28
61 142
B M 28
330 627
A K 29
310 590
1 3 30
33 91
9 I 30
288 549
1 3 31
34 94
9 I 31
297 567
G V 32
543 1008
0 1 33
1 33
8 G 33
280 536
G V 33
559 1039
0 1 34
1 34
F T 34
539 1001
0 1 35
1 35
7 E 35
259 497
F T 35
554 1030
7 E 36
266 511
Note that some may look wrong, such as (in decimal)
554*9/5+32 = 1029.2, which doesn't round to 1030
but what reads as 554, or its base-35 equivalent, may be as high as an exact temperature as nearly 554.5, which is 1030.1 Farenheit.
|
Posted by Charlie
on 2022-01-19 11:32:08 |