Решил задачку на C# Получилось 169 проходов. )
В main запустить следующее:
Thumblers thmblrs = new Thumblers(); thmblrs.run();
Класс Thumblers.cs:
using System; using System.Linq; using System.Collections.Generic; using System.Text;
namespace ConsoleApp1 { public class Thumbler { public int index; bool _value; public bool value { get { return _value; } set { if (thmblrs != null) { if (thmblrs != null && (index == 0 && thmblrs.Thumb2.value && !thmblrs.Thumb3.value && !thmblrs.Thumb4.value && !thmblrs.Thumb5.value && !thmblrs.Thumb6.value && !thmblrs.Thumb7.value || index == 1 && thmblrs.Thumb3.value && !thmblrs.Thumb4.value && !thmblrs.Thumb5.value && !thmblrs.Thumb6.value && !thmblrs.Thumb7.value || index == 2 && thmblrs.Thumb4.value && !thmblrs.Thumb5.value && !thmblrs.Thumb6.value && !thmblrs.Thumb7.value || index == 3 && thmblrs.Thumb5.value && !thmblrs.Thumb6.value && !thmblrs.Thumb7.value || index == 4 && thmblrs.Thumb6.value && !thmblrs.Thumb7.value || index == 5 && thmblrs.Thumb7.value || index == 6)) { _value = value; } else { throw new System.InvalidOperationException("Неверное расположение тумблеров (thmblrs)"); } } else { _value = value; } } } public Thumblers thmblrs; } public class Thumblers { public static Thumblers thumblers; public Thumbler Thumb1 = new Thumbler { index = 0, value = true, thmblrs = thumblers }; public Thumbler Thumb2 = new Thumbler { index = 1, value = true, thmblrs = thumblers }; public Thumbler Thumb3 = new Thumbler { index = 2, value = true, thmblrs = thumblers }; public Thumbler Thumb4 = new Thumbler { index = 3, value = true, thmblrs = thumblers }; public Thumbler Thumb5 = new Thumbler { index = 4, value = true, thmblrs = thumblers }; public Thumbler Thumb6 = new Thumbler { index = 5, value = true, thmblrs = thumblers }; public Thumbler Thumb7 = new Thumbler { index = 6, value = true, thmblrs = thumblers }; public static Thumbler GetThumblerByIndex(int index, Thumblers thmblrs) { if (thmblrs.Thumb1.index == index) { return thmblrs.Thumb1; } if (thmblrs.Thumb2.index == index) { return thmblrs.Thumb2; } if (thmblrs.Thumb3.index == index) { return thmblrs.Thumb3; } if (thmblrs.Thumb4.index == index) { return thmblrs.Thumb4; } if (thmblrs.Thumb5.index == index) { return thmblrs.Thumb5; } if (thmblrs.Thumb6.index == index) { return thmblrs.Thumb6; } if (thmblrs.Thumb7.index == index) { return thmblrs.Thumb7; } return null; } public int MoveCarretToStart(int preLastIndex) { try { preLastIndex = preLastIndex - 1; if (preLastIndex < 0) { preLastIndex = 6; } GetThumblerByIndex(preLastIndex, this).thmblrs = this; GetThumblerByIndex(preLastIndex, this).value = !GetThumblerByIndex(preLastIndex, this).value; } catch { return MoveCarretToStart(preLastIndex); } return preLastIndex; } public void run() { int preLastIndex = 6; int tempLastIndex; int i = 0; do { thumblers = this; try { preLastIndex = MoveCarretToStart(preLastIndex); } catch { GetThumblerByIndex(preLastIndex, this).value = !GetThumblerByIndex(preLastIndex, this).value; } Console.WriteLine(Convert.ToInt32(GetThumblerByIndex(0, this).value) + " " + Convert.ToInt32(GetThumblerByIndex(1, this).value) + " " + Convert.ToInt32(GetThumblerByIndex(2, this).value) + " " + Convert.ToInt32(GetThumblerByIndex(3, this).value) + " " + Convert.ToInt32(GetThumblerByIndex(4, this).value) + " " + Convert.ToInt32(GetThumblerByIndex(5, this).value) + " " + Convert.ToInt32(GetThumblerByIndex(6, this).value)); tempLastIndex = 0; if (!GetThumblerByIndex(0, this).value) { tempLastIndex = tempLastIndex + 1; } if (!GetThumblerByIndex(1, this).value) { tempLastIndex = tempLastIndex + 1; } if (!GetThumblerByIndex(2, this).value) { tempLastIndex = tempLastIndex + 1; } if (!GetThumblerByIndex(3, this).value) { tempLastIndex = tempLastIndex + 1; } if (!GetThumblerByIndex(4, this).value) { tempLastIndex = tempLastIndex + 1; } if (!GetThumblerByIndex(5, this).value) { tempLastIndex = tempLastIndex + 1; } if (!GetThumblerByIndex(6, this).value) { tempLastIndex = tempLastIndex + 1; } i = i + 1; } while (tempLastIndex < 7); if (tempLastIndex > 6) { Console.WriteLine(i); } } } }