May-21-2020, 07:13 PM
Hello! I need to convert this C code I made to Python:
https://gist.github.com/anakk1n/dadf2216...10c3839af5
My python code looks like this:
https://gist.github.com/anakk1n/dadf2216...10c3839af5
My python code looks like this:
def algoritm2(v, n, d, c): p = 0 j = -3 k = 0 for i in range(n-1): if (j >= n - 2): break if (p == 1): print(v[j+1], " ", end='') u = k = v[j + 1] i = j + 1 c = c + 1 p = 0 else: u = -1 j = i aux = v[i] + d + 1 if (aux <= v[i + 1] and u == -1): print(v[i], " ", end='') k = v[i] c = c + 1 else: if (((v[i] - v[i - 1] >= d) and u != v[i]) or (i == 0)): k = v[i] print(v[i], " ", end='') c = c + 1 while (aux > v[j + 1] and j < n - 2): j = j + 1 p = 1 if (v[n - 1] - k >= d + 1): print(v[n-1], " ", end='') return cProblem is that it doesn't list 100% the same thing. Did i do anything wrong in the conversion? Also, I changed the 'l' variable in the C code with the 'c' variable in python and in Python I made it return 'c', but it shouldn't affect my result