Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let [a, b, maxPassGenerated] = input.map(Number);
- let combinationsCounter = 0;
- let output = "";
- let maxComb_a_b = a * b;
- let haveQuit = false;
- for (let i = 35; i <= 55; i++) {
- let _A = i;
- let _B = i + 29;
- for (let x = 1; x <= a; x++) {
- for (let y = 1; y <= b; y++) {
- if (output.includes(String.fromCharCode(_A))) {
- _A++;
- }
- if (_A > 55) {
- _A = 35;
- }
- if (output.includes(String.fromCharCode(_B))) {
- _B++;
- }
- if (_B > 96) {
- _B = 64;
- }
- combinationsCounter++;
- output += `${String.fromCharCode(_A)}${String.fromCharCode(
- _B
- )}${x}${y}${String.fromCharCode(_B)}${String.fromCharCode(_A)}|`;
- if (maxComb_a_b > maxPassGenerated) {
- if (maxPassGenerated === combinationsCounter) {
- haveQuit = true;
- break;
- }
- } else {
- if (maxComb_a_b === combinationsCounter) {
- haveQuit = true;
- break;
- }
- }
- }
- if (haveQuit) {
- break;
- }
- }
- if (haveQuit) {
- break;
- }
- }
- console.log(output);
- }
Advertisement
Add Comment
Please, Sign In to add comment