Skip to content

Instantly share code, notes, and snippets.

@OzTamir
Last active August 29, 2015 13:56
Show Gist options
  • Save OzTamir/9168983 to your computer and use it in GitHub Desktop.
Save OzTamir/9168983 to your computer and use it in GitHub Desktop.
Find the number of options to paint m (or more) pixels in a pixel row with n pixels
def number_of_paint_options(n, m):
def find_num_options(n, m):
'''Find the number of options to paint m (or more) pixels in a pixel row with n pixels'''
return 1 + sum((k - m + 1) * find_num_options(n - k - 1, m) for k in range(m, n + 1))
if m > n or m == 0:
return 0
elif n == m:
return 1
return find_num_options(n, m)
@OzTamir
Copy link
Author

OzTamir commented Feb 23, 2014

if m == 0: return 0
Personal preference, different then question requirements.

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