@@ -0,0 +1,723 @@
+import math%0A%0A%0Adef count_tris_and_squares(n):%0A    c = 0%0A%0A    for i in range(n + 1):%0A        t = int(i * (i + 1) / 2)%0A%0A        for v in rollin_rollin_rollin(t):%0A            sqr = math.sqrt(v)%0A%0A            # works for small enough numbers%0A            if int(sqr)**2 == v:%0A                c += 1%0A                break%0A%0A    return c%0A%0A%0Adef rollin_rollin_rollin(n):%0A    s = list(str(n))%0A%0A    for i in range(len(s)):%0A        s.append(s.pop(0))%0A        yield int(''.join(s))%0A%0A%0Adef test_rollin_rollin_rollin():%0A    assert %5B2301, 3012, 123, 1230 %5D == list(rollin_rollin_rollin(1230))%0A%0A%0Adef test_count_tris_and_squares():%0A    assert 3 == count_tris_and_squares(5)%0A%0A%0Aif __name__ == '__main__':%0A    print(count_tris_and_squares(1000000))

Solve Knowit2019/17