Skip to content

Instantly share code, notes, and snippets.

@nmakeenkov
Created October 10, 2019 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmakeenkov/7ef9f24f4f3e0356e55d91e98c7e1518 to your computer and use it in GitHub Desktop.
Save nmakeenkov/7ef9f24f4f3e0356e55d91e98c7e1518 to your computer and use it in GitHub Desktop.
3 numbers
def get_easy_res(n):
ans = 0
for a in range(1, n):
for b in range(1, n):
c = n - a - b
if c <= 0 or a == b or a == c or b == c:
continue
ans += 1
return ans
def get_formula_res(n):
res = ((n-2) * (n-1))//2 - 3 * ((n - 1) // 2)
if n % 3 == 0:
res += 2
return res
for n in range(6, 150):
er = get_easy_res(n)
hr = get_formula_res(n)
if er != hr:
print('fail', n, er, hr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment