Even more obfuscation.
This commit is contained in:
parent
90cf5a8335
commit
9e7ac0057b
@ -55,6 +55,7 @@ MMMISSJEEE
|
||||
val grid = CharGrid(input)
|
||||
var sum = 0
|
||||
val magic = listOf(3, 5, 10, 12)
|
||||
val star = CharGrid.PLUS_POS.plus(CharGrid.CROSS_POS)
|
||||
for (p in grid.generateGridPos()) {
|
||||
val c = grid[p]
|
||||
if (c != '.') {
|
||||
@ -70,10 +71,9 @@ MMMISSJEEE
|
||||
newPos = newSeeds
|
||||
}
|
||||
val corners = areaPos.sumOf {
|
||||
val plusCode = CharGrid.PLUS_POS.mapIndexed { index, relPos -> if (areaPos.contains(it.translate(relPos))) 1 shl index else 0 }.sum()
|
||||
val crossCode = CharGrid.CROSS_POS.mapIndexed { index, relPos -> if (areaPos.contains(it.translate(relPos))) 1 shl index else 0 }.sum()
|
||||
val outer = magic.count { plusCode and it == 0 }
|
||||
val inner = magic.filterIndexed { i, m -> (plusCode and m == m) && (crossCode and (1 shl i) == 0) }.count()
|
||||
val b = star.mapIndexed { i, rp -> if (areaPos.contains(it.translate(rp))) 1 shl i else 0 }.sum()
|
||||
val outer = magic.count { b and it == 0 }
|
||||
val inner = magic.filterIndexed { i, m -> (b and m == m) && (b and (16 shl i) == 0) }.count()
|
||||
outer + inner
|
||||
}
|
||||
sum += areaPos.size * corners
|
||||
|
Loading…
Reference in New Issue
Block a user