Skip to content

Instantly share code, notes, and snippets.

@parastuffs
Created May 12, 2020 13:33
Show Gist options
  • Save parastuffs/caee5728aeb05d294e6a9417dfc6ab21 to your computer and use it in GitHub Desktop.
Save parastuffs/caee5728aeb05d294e6a9417dfc6ab21 to your computer and use it in GitHub Desktop.
Print order for a book
TOTAL_PAGES = 292
leaflets = 73
n = 4 # pages per sheet
l = 5 # sheets per leaflet
firstPage = 197
order = list()
i = 0
a = b = c = d = 0
while i < l:
if i == 0:
# Init
a = firstPage
b = a + 1
d = a + n*l - 1
c = d - 1
else:
a = b + 1
b = a + 1
d = c - 1
c = d - 1
order.append(b)
order.append(c)
order.append(d)
order.append(a)
i += 1
print(order)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment