Transfer-matrix method
 
x
OK