

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Brute force solution to Push Button Lock: A Test is one possible assignment of buttons ร combinations: Recursively build all possible button ร combination assignments (including invalid ones). Check if a button ร combination assignment is valid: struct Test { int x[11]; int n; Test(int _n) { n = _n; } Test(const Test& o) { n=o.n; for (int i=0; i<o.n; i++) x[i]=o.x[i]; } }; void make_tests(int n, int max, vector
Solve the problem for a specific number of buttons: Official judgeโs solution to Push Button Lock (not brute force?): int solve(int num_buttons) { // make vector containing all possible assignments vector