Generation

generate functionSun, 16 Apr 2023

caja fuerte de 6 dígitos, que imprima todas las combinaciones y que se detenga en la combinación 975943

using System; using System.Collections.Generic; public class Safe { public static void Main() { var safe = new Safe(new List<int> { 9, 7, 5, 9, 4, 3}); for(var i = 0; i < 999999; i++) { if (safe.TryOpen(new List<int> { i/100000, i/10000%10, i/1000%10, i/100%10, i/10%10, i%10 })) break; } } public Safe(List<int> key) => Key = key; public List<int> Key {get; set;} public bool TryOpen(List<int> combination) { if (combination == Key) { Console.WriteLine("Abrir la caja fuerte"); return true; } else { Console.WriteLine($"Código: {combination[0]}{combination[1]}{combination[

Questions about programming?Chat with your personal AI assistant