Optimization in solving a problem with a neighbor

 

v20240901