From 57cc373f8332ec8ea5925c889289d8ee1661f421 Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Fri, 25 Dec 2015 13:42:33 +0100 Subject: [PATCH] Solution to day 25. --- day-25/solution.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 day-25/solution.py diff --git a/day-25/solution.py b/day-25/solution.py new file mode 100644 index 0000000..0718e61 --- /dev/null +++ b/day-25/solution.py @@ -0,0 +1,18 @@ +from __future__ import print_function + +def findCode(n): + modBase = 33554393 + base = 252533 + start = 20151125 + + code = start * pow(base, n - 1, modBase) + return code % modBase + +row = 2947 +col = 3029 + +triangleNo = row + col - 1 +subTriangleSurface = ((triangleNo - 1) * triangleNo) // 2 +n = subTriangleSurface + col + +print(findCode(n))