Post Reply 
Fifteen puzzle solvability, Numworks Python
04-09-2020, 03:23 PM
Post: #9
RE: Fifteen puzzle solvability, Numworks Python
Oh, you are right again.
I was sloppy.
Code:
def fifteen(a):
  b = 0
  for i in range(16):
    if a[i] == 0:
      b = 1 + i // 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 03:23 PM



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