Post Reply 
Fifteen puzzle solvability, Numworks Python
04-09-2020, 01:24 PM
Post: #6
RE: Fifteen puzzle solvability, Numworks Python
May be like this, but not so concise.
Code:
def fifteen(a):
  b = 0
  for i in range(16):
    if a[i] == 0:
      b += (i + 3) // 4
  for i in range(15):
    for j in range(i+1, 16):
      b += (a[j] < a[i]) * (a[j] != 0)
  return b
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Fifteen puzzle solvability, Numworks Python - stored - 04-09-2020 01:24 PM



User(s) browsing this thread: 2 Guest(s)