• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 01:35
CEST 07:35
KST 14:35
  • 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
Team TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
StarCraft II 5.0.15 PTR Patch Notes72BSL 2025 Warsaw LAN + Legends Showmatch2Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8
StarCraft 2
General
StarCraft II 5.0.15 PTR Patch Notes #1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups Team Liquid Map Contest #21 - Presented by Monster Energy SpeCial on The Tasteless Podcast
Tourneys
SC2's Safe House 2 - October 18 & 19 RSL: Revival, a new crowdfunded tournament series Maestros of The Game—$20k event w/ live finals in Paris Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
Soulkey on ASL S20 ASL20 General Discussion BW General Discussion ASL TICKET LIVE help! :D NaDa's Body
Tourneys
BSL 2025 Warsaw LAN + Legends Showmatch [ASL20] Ro16 Group D [ASL20] Ro16 Group C Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Borderlands 3 Path of Exile Nintendo Switch Thread General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread UK Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Canadian Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
i'm really bored guys
Peanutsc
I <=> 9
KrillinFromwales
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2071 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 States44608 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
Next event in 4h 25m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 151
ProTech58
StarCraft: Brood War
PianO 752
soO 46
Noble 33
Sacsri 22
HiyA 17
ajuk12(nOOB) 16
SilentControl 7
Icarus 6
League of Legends
JimRising 702
Counter-Strike
Stewie2K474
Coldzera 208
Super Smash Bros
Mew2King38
Other Games
summit1g7648
C9.Mang0271
Hui .193
ViBE167
NeuroSwarm77
Trikslyr30
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• Berry_CruncH295
• Sammyuel 19
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Other Games
• Scarra1004
Upcoming Events
RSL Revival
4h 25m
Zoun vs Classic
Map Test Tournament
5h 25m
Korean StarCraft League
21h 25m
BSL Open LAN 2025 - War…
1d 2h
RSL Revival
1d 4h
Reynor vs Cure
BSL Open LAN 2025 - War…
2 days
RSL Revival
2 days
Online Event
2 days
Wardi Open
3 days
Monday Night Weeklies
3 days
[ Show More ]
Sparkling Tuna Cup
4 days
LiuLi Cup
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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.