Runtime Error in Python

0

I made a backtracking program in Python to find an M-size set of binary strings where any string has a distance greater than d for any other string in the set.

But it does not work well when testing for n = 8. The message:

  

"Runtime error! This application has requested the runtime to   terminate it in an unusual way "

Does anyone know why?

Code:

def dist(a,b):
 k = 0 
 for i in range (0,20):
    if a%2 != b%2:
      k = k + 1
    a = a/2
    b = b/2 
 return k 

def bin(n):
 nd = 0
 pot = 1
 while (n  0):
    nd = nd + n%2 * pot
    n = n/2
    pot = pot * 10
 return nd

o = []
o = o + [0]
M = 4
n = 5
d = 3
Tam = 2**n - 1

def cod(ult):
 j = ult
 while j < Tam+1: 
  aux = 0
  for i in range (0,len(o)): 
     if dist(o[i],j+1)  d-1: 
       aux += 1 
  if aux == len(o): 
     o.append(j+1) 
     j +=1
  else:
     j+=1
 return (o)   

cod(0)

while len(o) < M+1:
  if len(o)  M-1:
     for i in range (0,len(o)):
       print bin(o[i])
     print o
     print len(o)
     break
  else:
     ult = o.pop() 
     cod(ult)
    
asked by anonymous 03.03.2017 / 03:30

1 answer

1

According to the report there is a bug present in the Python version 2.6, basically a solution to this problem was changing the path of the environment variable pythonhome from python26 to python32

    
03.03.2017 / 05:08