Jeremy is a store owner. He uses combination locks like the one below at all of his store locations to secure cabinets of semi-important documents. Each combination is made up of 3 numbers, each between 0 and 39, inclusively.
Over the years as he built more stores, Jeremy developed a system for remembering the combination at each store location. His secret: He associates a trip with each combination.
Here are a couple of examples:
For his original store, the trip he remembers is
Belgium --> Germany --> France, and the combination is 10-17-29.
For his second store, the trip he remembers is
Saudi Arabia--> Iran --> Qatar, and the combination is 38-13-35.
You work at Jeremy's new location, and the cabinet there has 2 combination locks on it. He is always looking for people with excellent problem-solving skills to promote to top managerial positions within the company. With that in mind, he has told you which trips he associates with each lock. Knowing his motivation, you would love to be able to figure out both of the combinations and get a much better job.
The trip for lock #1 is
Brazil --> Chile --> Argentina
The trip for lock #2 is
Everywhere --> Nowhere --> Home
The numbers correspond to the areas traveled, and they are in order. Each area traveled has one and only one number associated with it. The process is not super complicated. It doesn't require arithmetic mod and it doesn't require knowledge of provinces, states, zones, or regions. In response to Oren's comment, all countries and many other areas (except 5 of them, which is an unimportant detail), can be turned into a valid number.
Tip: Ignore lock #2 at first, and when you have figured out a method, apply it to lock #1. Then, apply a small amount of practical/creative/lateral thinking (not calculation, as for the other locks) to get lock #2.
EDIT: Extra Info: Jeremy is horrible at spelling, but he is great at remembering short nicknames, abbreviations, and the like.
What are the 2 combinations, and why?
Answer
Posting Cerberus' explanation verbatim to explain the rules required to understand lock 1 (and so multiple answers don't have to be referenced).
You need to take the three-letter code of each country and calculate the 'distance' (d) between 2 consecutive letters, and finally add them.
Belgium --> Germany --> France
BEL --> DEU --> FRA
d(B,E) + d(E,L) = 3 + 7 = 10
d(D,E) + d(E,U) = 1 + 16 = 17
d(F,R) + d(R,A) = 12 + 17 = 29
Saudi Arabia --> Iran --> Qatar
SAU --> IRN --> QAT
d(S,A) + d(A,U) = 18 + 20 = 38
d(I,R) + d(R,N) = 9 + 4 = 13
d(Q,A) + d(A,T) = 16 + 19 = 35
That means that Brazil --> Chile --> Argentina
BRA --> CHL --> ARG
d(B,R) + d(R,A) = 16 + 17 = 33
d(C,H) + d(H,L) = 5 + 4 = 9
d(A,R) + d(R,G) = 17 + 11 = 28
so the code is 33-9-28
Quark's solution to Lock 2:
Nowhere is 0, Everywhere is 39, and Home is 1.
/* Author: Quark */
#include
#include
int main()
{
char code[4];
int number[3];
int value;
int i;
int zero=0,one=0,two=0,three=0,four=0,five=0,six=0,seven=0,eight=0,nine=0,ten=0,
eleven=0,twelve=0,thirteen=0,fourteen=0,fifteen=0,sixteen=0,seventeen=0,
eighteen=0,nineteen=0,twenty=0,twentyone=0,twentytwo=0,twentythree=0,twentyfour=0,
twentyfive=0,twentysix=0,twentyseven=0,twentyeight=0,twentynine=0,thirty=0,
thirtyone=0,thirtytwo=0,thirtythree=0,thirtyfour=0,thirtyfive=0,thirtysix=0,
thirtyseven=0,thirtyeight=0,thirtynine=0,fourty=0,over = 0;
while(1){
gets(code);
if(code[0]=='0')
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", zero,one,two,three,four,five,six,seven,eight,nine,ten,
eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,
eighteen,nineteen,twenty,twentyone,twentytwo,twentythree,twentyfour,
twentyfive,twentysix,twentyseven,twentyeight,twentynine,thirty,
thirtyone,thirtytwo,thirtythree,thirtyfour,thirtyfive,thirtysix,
thirtyseven,thirtyeight,thirtynine,fourty,over);
for(i=0;i<3;i++)
{
if (code[i] >= 'A' && code[i] <= 'Z')
number[i] = code[i] - 'A' + 1;
else if (code[i] >= 'a' && code[i] <= 'z')
number[i] = code[i] - 'a';
}
value = abs(number[0]-number[1]) + abs(number[1]-number[2]);
printf("%d\n", value);
switch(value)
{
case 0:
zero++;
break;
case 1:
one++;
break;
case 2:
two++;
break;
case 3:
three++;
break;
case 4:
four++;
break;
case 5:
five++;
break;
case 6:
six++;
break;
case 7:
seven++;
break;
case 8:
eight++;
break;
case 9:
nine++;
break;
case 10:
ten++;
break;
case 11:
eleven++;
break;
case 12:
twelve++;
break;
case 13:
thirteen++;
break;
case 14:
fourteen++;
break;
case 15:
fifteen++;
break;
case 16:
sixteen++;
break;
case 17:
seventeen++;
break;
case 18:
eighteen++;
break;
case 19:
nineteen++;
break;
case 20:
twenty++;
break;
case 21:
twentyone++;
break;
case 22:
twentytwo++;
break;
case 23:
twentythree++;
break;
case 24:
twentyfour++;
break;
case 25:
twentyfive++;
break;
case 26:
twentysix++;
break;
case 27:
twentyseven++;
break;
case 28:
twentyeight++;
break;
case 29:
twentynine++;
break;
case 30:
thirty++;
break;
case 31:
thirtyone++;
break;
case 32:
thirtytwo++;
break;
case 33:
thirtythree++;
break;
case 34:
thirtyfour++;
break;
case 35:
thirtyfive++;
break;
case 36:
thirtysix++;
break;
case 37:
thirtyseven++;
break;
case 38:
thirtyeight++;
break;
case 39:
thirtynine++;
break;
case 40:
fourty++;
break;
default:
over++;
break;
}
}
return(1337);
}
Running this code with a list of country codes returns:
AFG
6
ALA
22
ALB
21
DZA
47
ASM
24
AND
23
AGO
14
AIA
16
ATG
32
ARG
28
ARM
22
ABW
22
AUS
22
AUT
21
AZE
46
BHS
17
BHR
16
BGD
8
BRB
32
BLR
16
BEL
10
BLZ
24
BEN
12
BMU
19
BTN
24
BOL
16
BIH
8
BWA
43
BRA
33
VGB
20
BRN
20
BGR
16
BFA
9
BDI
7
KHM
8
CMR
15
CAN
15
CPV
19
CYM
34
CAF
7
TCD
18
CHL
9
CHN
11
HKG
7
MAC
14
COL
15
COM
14
COG
20
COK
16
CRI
24
CIV
19
HRV
14
CUB
37
CYP
31
CZE
44
PRK
9
COD
23
DNK
13
DJI
7
DMA
21
DOM
13
ECU
20
EGY
20
SLV
17
GNQ
10
ERI
22
EST
15
ETH
27
FRO
15
FLK
7
FJI
5
FIN
8
FRA
29
GUF
29
PYF
28
GAB
7
GMB
17
GEO
12
DEU
17
GHA
8
GIB
9
GRC
26
GRL
17
GRD
25
GLP
9
GUM
22
GTM
20
GGY
18
GIN
7
GNB
19
GUY
18
HTI
23
VAT
40
HND
16
HUN
20
ISL
17
IND
15
IDN
15
IRN
13
IRQ
10
IRL
15
IMN
5
ISR
11
ITA
30
JAM
21
JPN
8
JEY
25
JOR
8
KAZ
35
KEN
15
KIR
11
KWT
15
KGZ
23
LAO
25
LVA
31
LBN
22
LSO
11
LBR
26
LBY
33
LIE
7
LTU
9
LUX
12
MDG
12
MWI
24
MYS
18
MDV
27
MLI
4
MLT
9
MHL
9
MTQ
10
MRT
7
MUS
10
MYT
17
MEX
27
FSM
19
MDA
12
MCO
22
MNG
8
MNE
10
MSR
7
MAR
29
MOZ
13
MMR
5
NAM
25
NRU
7
NPL
6
NLD
10
ANT
19
NCL
20
NZL
26
NIC
11
NER
22
NGA
13
NIU
17
NFK
13
MNP
3
NOR
4
PSE
17
OMN
3
PAK
25
PLW
15
PAN
28
PNG
9
PRY
9
PER
24
PHL
12
PCN
24
POL
4
PRT
4
PRI
11
QAT
35
KOR
7
REU
29
ROU
9
RUS
5
RWA
27
BLM
11
SHN
17
KNA
16
LCA
11
MAF
17
SPM
6
VCT
36
WSM
10
SMR
11
STP
5
SAU
38
SEN
23
SRB
17
SYC
28
SLE
14
SGP
21
SVK
14
SVN
11
SLB
17
SOM
6
ZAF
30
ESP
17
LKA
11
SDN
25
SUR
5
SJM
12
SWZ
7
SWE
22
CHE
8
SYR
13
TJK
11
THA
19
MKD
9
TLS
15
TGO
21
TKL
10
TON
6
TTO
5
TUN
8
TUR
4
TKM
11
TCA
19
TUV
2
UGA
20
UKR
17
ARE
30
GBR
21
TZA
31
USA
20
VIR
22
URY
10
UZB
29
VUT
2
VEN
26
VNM
9
WLF
17
ESH
25
YEM
28
ZMB
24
ZWE
21
0
0 0 2 2 5 7 5 13 10 13 10 13 7 7 6 12 8 16 4 8 10 8 11 5 8 7 4 4 5 5 3 3 2 2 1 2 1 1 1 0 1 4
21
Note: the leading 0 and following 21 is the command to print results and result of the print result commands respectively (this explanation is as messy as the code). TL;DR, the solutions from 0,1,2,...39,40,OVER, are listed in the long number line.
As you can see from my beautifully crafted code, (I bet this'll make some programmers puke, I did it just to test my regex skills), the only 0's are for variables zero, one, and thirtynine, meaning these are the only ones that can't be represented by a country code. Zero and thirtynine correspond to nowhere and everywhere intuitively being none and every, and one is the loneliest number sitting at home. (basically from process of elimination)
Answer for Lock 2:
For the system to work, every number has to be able to be represented otherwise he needs another system when combinations include 0/1 etc. Also, there should be no reason to break the pattern of using country code abbreviations if he didn't have to, so all three should represent numbers that can't be made with country abbreviations. Assuming this link is used for codes, 2 can be made with RSR, and 3 can be made with OMN, (the rest have multiple), meaning there is none for 0 or 1. To associate these with nowhere and everywhere, I'd say 0 is nowhere and 1 is everywhere. Home could then be either actually home, or one other number that can't be made. I don't know if I should write some code to convert these to numbers though without confirmation.
No comments:
Post a Comment