!759 static final int gridSize = 10; static int steps = 10; // steps limit sinterface Make { X make(); } asclass X { abstract Move get(); } asclass SelfMade extends X implements Make { public X make() { start(); ret this; } void start() {} // override me } asclass Move { } sclass ClearFixed extends Move { int i; *() {} *(int *i) {} } sclass Grid { int val = (1 << gridSize)-1; bool cleared() { ret val == 0; } void clear(int i) { if (i >= 0 && i < gridSize) val &= ~(1 << i); } int remaining() { ret countBits(val); } } static L pool; p { pool = new L; new Best best; while (licensed()) { ping(); updatePool(); new HashMap scores; for (Make maker : pool) { ping(); int score = play(maker.make()); scores.put(maker, score); best.put(maker, score); } Make winner = lowest(scores); print("Best score: " + scores.get(winner) + " - " + structure(winner) + ", all time: " + best.score); } } // collects LOWEST score sclass Best { A best; int score; void put(A a, int score) { if (best == null || score < this.score) { best = a; this.score = score; } } A get() { ret best; } } static int play(X x) { new Grid g; int i = 0; while (i++ < steps && move(x, g) && !g.cleared()) {} ret /*i +*/ g.remaining(); } // false = x exited static bool move(X x, Grid g) { Move m = x.get(); if (m == null) ret false; ClearFixed cf = cast m; g.clear(cf.i); ret true; } //// CONTESTANTS //// sclass C1 extends SelfMade { L positions; int i; *() {} *(L *positions) {} *(int... l) { positions = asList(l); } void start() { i = 0; } Move get() { if (i >= l(positions)) ret null; ret new ClearFixed(positions.get(i++)); } } // updatePool static void updatePool() { pool.clear(); if (random(2) == 0) pool.add(new C1(random(gridSize), random(gridSize))); else pool.add(new C1(random(gridSize), random(gridSize), random(gridSize))); }