Skip to content

Instantly share code, notes, and snippets.

@popey456963
Created November 4, 2015 18:15
Show Gist options
  • Select an option

  • Save popey456963/2d97723c1549152e8c30 to your computer and use it in GitHub Desktop.

Select an option

Save popey456963/2d97723c1549152e8c30 to your computer and use it in GitHub Desktop.
Stepping Stones
import math
start = int(input())
end = int(input())
amount = int(input()) - 1
if amount == -1 and start == 0 and end == 0:
print("NONE")
else:
difference = end-start
step = difference/amount
c=[]
for i in range(amount + 1):
if start+i*step < 0:
c.append(str(math.ceil(start+i*step)))
else:
c.append(str(math.floor(start+i*step)))
print(" ".join(c))
@popey456963
Copy link
Copy Markdown
Author

Different Format

import math
a = input().split()
start = int(a[0])
end = int(a[1])
amount = int(a[2]) - 1

if amount == -1 and start == 0 and end == 0:
    print("NONE")
else:
    difference = end-start
    step = difference/amount
    c=[]
    for i in range(amount + 1):
        if start+i*step < 0:
            c.append(str(math.ceil(start+i*step)))
        else:
            c.append(str(math.floor(start+i*step)))
    print(" ".join(c))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment