Created
October 10, 2019 09:01
-
-
Save nmakeenkov/7ef9f24f4f3e0356e55d91e98c7e1518 to your computer and use it in GitHub Desktop.
3 numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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