• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 08:49
CET 14:49
KST 22:49
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Winners10Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
StarCraft, SC2, HotS, WC3, Returning to Blizzcon!44$5,000+ WardiTV 2025 Championship7[BSL21] RO32 Group Stage4Weekly Cups (Oct 26-Nov 2): Liquid, Clem, Solar win; LAN in Philly2Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win10
StarCraft 2
General
Mech is the composition that needs teleportation t StarCraft, SC2, HotS, WC3, Returning to Blizzcon! RotterdaM "Serral is the GOAT, and it's not close" TL.net Map Contest #21: Winners Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament Constellation Cup - Main Event - Stellar Fest $5,000+ WardiTV 2025 Championship Merivale 8 Open - LAN - Stellar Fest Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion Where's CardinalAllin/Jukado the mapmaker? [ASL20] Ask the mapmakers — Drop your questions [BSL21] RO32 Group Stage
Tourneys
[ASL20] Grand Finals [BSL21] RO32 Group A - Saturday 21:00 CET [Megathread] Daily Proleagues [BSL21] RO32 Group B - Sunday 21:00 CET
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Should offensive tower rushing be viable in RTS games? Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
The Games Industry And ATVI US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine YouTube Thread
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Learning my new SC2 hotkey…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Our Last Hope in th…
KrillinFromwales
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1160 users

Lock Hack Problem

Blogs > Velocirapture
Post a Reply
Velocirapture
Profile Blog Joined December 2010
United States983 Posts
September 17 2015 18:50 GMT
#1
Recently during an interview process I was given a series of question and asked to give the best answers I could. I am allowed to consult anybody I wish and thought it might be fun to post it here. The questions are supposed to be hard and draw on a wide variety of specialties. This is the one that I don't know how to start.

You are given a lock with 4 letters (A,B,C,D) as input options and a 3 letter code. Order is important and repetition is allowed so obviously this means you have 64 permutations as seen below.

{a,a,a} {a,a,b} {a,a,c} {a,a,d} {a,b,a} {a,b,b} {a,b,c} {a,b,d} {a,c,a} {a,c,b} {a,c,c} {a,c,d} {a,d,a} {a,d,b} {a,d,c} {a,d,d} {b,a,a} {b,a,b} {b,a,c} {b,a,d} {b,b,a} {b,b,b} {b,b,c} {b,b,d} {b,c,a} {b,c,b} {b,c,c} {b,c,d} {b,d,a} {b,d,b} {b,d,c} {b,d,d} {c,a,a} {c,a,b} {c,a,c} {c,a,d} {c,b,a} {c,b,b} {c,b,c} {c,b,d} {c,c,a} {c,c,b} {c,c,c} {c,c,d} {c,d,a} {c,d,b} {c,d,c} {c,d,d} {d,a,a} {d,a,b} {d,a,c} {d,a,d} {d,b,a} {d,b,b} {d,b,c} {d,b,d} {d,c,a} {d,c,b} {d,c,c} {d,c,d} {d,d,a} {d,d,b} {d,d,c} {d,d,d}

Now here is the challenge. The lock does not track a registry so an input of AAAB counts as both AAA and AAB. Given this information I need to find the shortest possible string of inputs that includes all 64 permutations.

I am not a programmer so I would love to know if there is a conventional logic to finding the solution rather than brute forcing it computationally.

Sn0_Man
Profile Blog Joined October 2012
Tebellong44238 Posts
Last Edited: 2015-09-17 19:41:42
September 17 2015 19:30 GMT
#2
Rules for maximum efficiency:
1)Each attempt should borrow the last 2 letters of the preceeding permutation
2)Each pairing can only occur 4 times (after using *BC, we can only repeat BC three more times)

if we can find a string that follows those rules, we achieve a 66 letter string that will open the lock. I'm assumign the rules are possible but I'm not certain. While there *must* be options (since swapping A and B in all instances produces a different string with the same result) I'm not sure that there are meaningfully different ones (aka truly different orders).

an attempt where we start with AAA and choose the next letter in the sequence (A, B, C, D) to make a new triplet that also isn't the 4th repetition of any pairing:

aaabbbcccdddaaccaaddbbddccbbabcdabdacdbcabacacbcbdbdcdcadadbadcbaa

which i'm fairly sure works
which would indicate that there are a lot of results that work but w/e

thats my process

note how you have to end on the same pairing as you begin so in this case AA is the only pairing that appears 5 times (counting AAA as 2 appearances of AA) since it represents the necessary inefficiency for 64 triplets to take 66 letters. In that way, this is cyclical so you could start at any arbitrary point in the sequence above, after first removing the AA from the end and instead duplicating your start pairing at the end.
LiquidDota StaffSCIENTISTS BAFFLED | 3275929302
DarkPlasmaBall
Profile Blog Joined March 2010
United States45017 Posts
September 18 2015 01:28 GMT
#3
I like Sn0's response and I'm really tired, so I apologize but I'm going to ask a related question (just not to the actual problem):

You had a take-home interview quiz? That seems kind of odd, considering you could just Google the answer/ ask your friends/ ask TLers. How is that supposed to assess you in any way as a future employee, if they don't even know if your solutions are really your own? You don't have to even be able to be creative or a good problem solver... you just need to find someone else who is!
"There is nothing more satisfying than looking at a crowd of people and helping them get what I love." ~Day[9] Daily #100
Nemesis
Profile Blog Joined May 2009
Canada2568 Posts
Last Edited: 2015-09-18 03:19:39
September 18 2015 03:16 GMT
#4
A simple way to think about is you have three _ in which you can put 4 different letters.
_ _ _


Since order and repetition does not matter, each _ can take 4 different letters. So in total you have 4x4x4 or 4^3 possible combinations.

Edit: Oops, didn't fully read the OP, you were asking about something else. In that case Sn0_Man's solution seems to be best for now. I'll think of my own solution later if I can find another one.
Lee Young Ho fighting! KT P are just CHINTOSSTIC.
Velocirapture
Profile Blog Joined December 2010
United States983 Posts
September 18 2015 05:18 GMT
#5
To answer dark, this is one of may questions spanning mathematics, chemistry, physics, biology and more. The idea is that you have to be able to work with subjects outside your comfort zone and take the necessary step to come to a solution. Follow up questions are asked to ensure you gained some understanding of the material rather than simply outsourcing.

To get back to the question, I don't feel I really have a true understanding of the logic of how an answer is derived. Both of the rules you set out by sn0 were obvious to me and I was spending hours trying to find the pattern between different clusters of permutations following "last two" or "first two" groupings. After a lot of time I stumbled upon the following 66 letter solution.

BAAABBACADAACBABCAADBADCABDACCCACDADDDBDBCBCDDCCDCBBBCCBDCDBBDDABA

I am 100% certain this solution works as I have checked it a couple times. I guess I understand that this question does not have many permutations and the solutions will be short enough that it can be managed by hand but what if it was much harder. I would want a process that clearly manages the variables and prescribes an order. Maybe I am just missing it because I am tired.
Sn0_Man
Profile Blog Joined October 2012
Tebellong44238 Posts
Last Edited: 2015-09-18 14:52:26
September 18 2015 14:32 GMT
#6
I guess what you need is a logical proof that any method of generation that follows those two rules will complete?
If we follow the generation method, we understand then that our termination point would be a point where the current end pairing has no unused future letter, and as such any letter we add to the end will break us out of "optimal" status by repeating a triplet. yes?
For that to happen, the current pairing must have already occurred 4 times previously PLUS this time since otherwise there will certainly be an allowable letter (one of the 4). In that case, we have already broken our rule of "only use a pairing 4 times". Hence, for a rule to be impossible to follow before the end pairing of the string generation, we must have already broken one of our rules. So simply following the pair of rules above guarantees generation of a winning string assuming you write in the necessary exception for the start/end case (a 5-use pairing) in your method.

Which means that even selecting a random next letter works assuming you check to confirm that it follows the original rules every time before actually adding it to the string.

Computationally, this gets decently expensive as you are required to check every triplet and pair against previously used triplets and pairs however in a low-permutation system like this one it's not a big deal. I'm suspicious that in a system like "10 possible letters, 5 letter passwords" not only would those calculations be expensive but also you may have to track more than just quintuplets and quadruplets although I'd have to think about it. Obviously that case wouldn't be answerable outside a computer-generated answer anyway unless you like typing out pages of letters.

E: I'm not actually convinced that the way I stated my "proof" is even close to concrete but I don't think I'm wrong.
LiquidDota StaffSCIENTISTS BAFFLED | 3275929302
joshie0808
Profile Blog Joined March 2011
Canada1024 Posts
September 18 2015 15:53 GMT
#7
You could probably perhaps repost this in the programming thread and someone might derive an algorithm that could solve for such an answer given x spaces and y variables?
broodwarhd2
Profile Joined February 2015
8 Posts
September 18 2015 19:03 GMT
#8
as a programmer i would write a brute force script that would generate all the possible combinations and rank them frrom shortest to longest, then visually analyse the shortest one and try to figure out what mkes it unique
Velocirapture
Profile Blog Joined December 2010
United States983 Posts
September 18 2015 20:54 GMT
#9
On September 19 2015 04:03 broodwarhd2 wrote:
as a programmer i would write a brute force script that would generate all the possible combinations and rank them frrom shortest to longest, then visually analyse the shortest one and try to figure out what mkes it unique


When I first saw the question this is the first solution that came to mind. Programming simply isn't a skill I have acquired and so I was hoping there was some discrete mathematics I simply didn't know that I could apply. I have my own answer that I came to through my own process so I guess I have to be satisfied.

I would like to thank sn0 for all of his help. I was getting discouraged with my process and your answer really kept me going.
Nemesis
Profile Blog Joined May 2009
Canada2568 Posts
September 19 2015 01:41 GMT
#10
The solution is not unique. As mentioned before, the minimum solution has to be 66 characters.

A way you could do it via programming is put all the possible keys to the lock in an array or list. Take a single key, and save that in a string variable as the final solution key. Kick that key attempt out of the array.

Next step is to take the last two letters in the solution key and compare it with the first two letters of whatever you have left in the array, then just pick one of the key with the same first two letters and add the last letter to your final solution key string. Kick the key that you just used up once again.

Repeat that until you have no more keys left. And you should come up with a 66 character solution eventually.

Essentially you just do it inductively. That's how I would do it anyways.
Lee Young Ho fighting! KT P are just CHINTOSSTIC.
Ziggareto
Profile Joined March 2014
United Kingdom9 Posts
September 20 2015 17:40 GMT
#11
I just brute forced it with programming and got:
AAABAACAADABBABCABDACBACCACDADBADCADDBBBCBBDBCCBCDBDCBDDCCCDCDDDA

You can see for yourself that it is fairly straightforward to get just by hand if you only have A, B, and C at your disposal and you only need a two letter string. You first right out all the possible keys:
AA
AB
AC
BA
BB
BC
CA
CB
CC

then you start your string with AA, then add a letter to make the next highest ordered alphabetically two letter combination not already in your string. In the end you get:
AABACBBCCA
the only thing here is that after AABAC, if you were to add an A then you couldn't complete it, so instead you add a B then it is smooth going.
When you move up to 3 letter code with ABC it just takes longer by hand and there are two of these stepping backwards where the nearest move by the alphabet would leave you in a rut. Adding D doesn't make much difference.
Please log in or register to reply.
Live Events Refresh
WardiTV Korean Royale
12:00
Group Stage 1 - Group A
WardiTV1093
Rex157
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Reynor 314
RotterdaM 255
Rex 157
MindelVK 37
StarCraft: Brood War
firebathero 9439
Sea 5686
GuemChi 1051
actioN 721
Pusan 575
Barracks 486
Hyun 287
Mini 167
hero 166
Soma 165
[ Show more ]
Last 157
PianO 104
Larva 83
Backho 67
ToSsGirL 55
scan(afreeca) 11
Noble 9
Terrorterran 8
HiyA 7
Dota 2
Gorgc8408
singsing2495
qojqva731
Dendi590
XcaliburYe259
Pyrionflax258
Counter-Strike
x6flipin687
byalli309
Heroes of the Storm
Khaldor235
Other Games
B2W.Neo1258
Sick228
Hui .82
goatrope77
QueenE23
Organizations
StarCraft: Brood War
lovetv 15
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 3232
• WagamamaTV543
• Ler66
Upcoming Events
LAN Event
1h 11m
ByuN vs Zoun
TBD vs TriGGeR
Clem vs TBD
IPSL
4h 11m
JDConan vs WIZARD
WolFix vs Cross
BSL 21
6h 11m
spx vs rasowy
HBO vs KameZerg
Cross vs Razz
dxtr13 vs ZZZero
OSC
9h 11m
OSC
19h 11m
Wardi Open
22h 11m
Replay Cast
1d 9h
WardiTV Korean Royale
1d 22h
Replay Cast
2 days
Kung Fu Cup
2 days
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
[ Show More ]
Tenacious Turtle Tussle
3 days
The PondCast
3 days
RSL Revival
3 days
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
3 days
WardiTV Korean Royale
3 days
Replay Cast
4 days
RSL Revival
4 days
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
4 days
CranKy Ducklings
5 days
RSL Revival
5 days
herO vs Gerald
ByuN vs SHIN
Kung Fu Cup
5 days
BSL 21
6 days
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Sparkling Tuna Cup
6 days
RSL Revival
6 days
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
6 days
WardiTV Korean Royale
6 days
Liquipedia Results

Completed

BSL 21 Points
SC4ALL: StarCraft II
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
Stellar Fest: Constellation Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.