Skip to content

Instantly share code, notes, and snippets.

@sughodke
Created February 23, 2014 04:41
Show Gist options
  • Select an option

  • Save sughodke/9166902 to your computer and use it in GitHub Desktop.

Select an option

Save sughodke/9166902 to your computer and use it in GitHub Desktop.
#!/bin/python
def myFun(ar, cols=3):
le = len(ar)
rem = le % cols
binSize = cols - rem
line = 0
i = 0
count = 0
while line < le / cols + rem:
print ar[i],
count = count + 1
if rem > 0:
jump = binSize + 1
rem = rem - 1
else:
jump = binSize
i = i + jump
if (count >= cols):
print
rem = le % cols
line = line + 1
i = line
count = 0
def badFun(ar, cols=3):
start = 0
i = start
while i < le:
print ar[i],
#if (rem > 0):
#i = i + 1
#rem = rem - 1
i = i + cols
if (i >= le):
print
start = start + 1
i = start
if __name__=="__main__":
arr = range(1,8)
myFun(arr, 3)
print
print
myFun(arr, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment