Tap here to switch tabs
Problem
Submissions

Problem: Cracking the Safe

Cracking the Safe asks for the shortest digit string that guarantees opening the safe: every possible password of length n over k digits must appear as a consecutive substring.

Statement

There is a safe protected by a password consisting of a sequence of n digits, where each digit is chosen from the first k digits from 00 to k−1k - 1.

The safe keypad tracks the most recently entered digits. Entering a new digit causes the safe to check the last n entered digits. If this sequence matches the password, the safe unlocks.

Return any string of the minimum possible length that is guaranteed to unlock the safe at some point during the sequence of typed digits.

Constraints:

  • 1≤1 \leq n ≤4\leq 4

  • 1≤1 \leq k ≤10\leq 10

  • 1≤1 \leq k‘n‘≤4096^{`n`} \leq 4096

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Cracking the Safe

Cracking the Safe asks for the shortest digit string that guarantees opening the safe: every possible password of length n over k digits must appear as a consecutive substring.

Statement

There is a safe protected by a password consisting of a sequence of n digits, where each digit is chosen from the first k digits from 00 to k−1k - 1.

The safe keypad tracks the most recently entered digits. Entering a new digit causes the safe to check the last n entered digits. If this sequence matches the password, the safe unlocks.

Return any string of the minimum possible length that is guaranteed to unlock the safe at some point during the sequence of typed digits.

Constraints:

  • 1≤1 \leq n ≤4\leq 4

  • 1≤1 \leq k ≤10\leq 10

  • 1≤1 \leq k‘n‘≤4096^{`n`} \leq 4096