问HN:哪些人工智能能够编写出这个难题的正确解决方案?
给定一个 n x n 的整数数组。<p>目标是使得数组中的所有元素都相等。<p>允许进行四种操作:<p>(1) 旋转一行<p>(2) 旋转一列<p>(3) 将一行中的所有元素加 1<p>(4) 将一列中的所有元素加 1<p>证明当且仅当初始配置中数字的总和对 n 取模为 0 时,目标是可达成的。<p>同时编写一个 Python 程序来解决这个难题(如果可能的话)。
查看原文
You are given an array of n x n integers.<p>The goal is to end up with an array in which all entries are equal.<p>Four kinds of moves are allowed:<p>(1) rotate a row<p>(2) rotate a column<p>(3) add 1 to all entries in a row<p>(4) add 1 to all entries in a column<p>Show the goal is achievable if and only if the sum of the numbers
in the initial configuration is congruent to 0 mod n.<p>Also write a python program to solve the puzzle whenever it is possible to do so.