# another attempt at code golf

This article is originally published at https://xianblog.wordpress.com

**I** had another lazy weekend go at code golf, trying to code in the most condensed way the following task. Provided with a square matrix *A* of positive integers, keep iterating the steps

- take the highest square
*𝑥²*in*A*. - find the smallest adjacent neighbour 𝑛
- replace
*x²*with x and n with*nx*

until no square is left (with neighbour defined as either horizontally or vertically and without wrapping around). While I managed a 217 bytes solution, compared with Robin’s 179b improvement, which remains surprising readable!, the puzzle offers two further questions:

- is there a non-iterative way to find the final matrix B?
- the puzzle assumes that A satisfies that at each step, the highest square
*x²*and the smallest neighbour*n*will be unique, and that the sequence will not repeat forever. Is there a fool-proof way to check this is the case?

Thanks for visiting r-craft.org

This article is originally published at https://xianblog.wordpress.com

Please visit source website for post related comments.