We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 50d7ed8 commit 53568cfCopy full SHA for 53568cf
project_euler/problem_206/__init__.py
project_euler/problem_206/sol1.py
@@ -0,0 +1,30 @@
1
+"""
2
+Problem Statement:
3
+Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0,
4
+where each “_” is a single digit.
5
6
+
7
+from itertools import product
8
9
10
+def solution() -> int:
11
+ """
12
+ Returns the positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0 using
13
+ itertool product to generate all possible digit combinations 0...9 for the nine "_"
14
+ to fill.
15
16
+ >>> solution()
17
+ 1389019170
18
19
20
+ for p in product("0123456789"[::-1], repeat=9):
21
+ squared = int("1{}2{}3{}4{}5{}6{}7{}8{}9{}0".format(*p))
22
23
+ root_integer = int(squared ** 0.5)
24
25
+ if root_integer ** 2 == squared:
26
+ return root_integer
27
28
29
+if __name__ == "__main__":
30
+ print(solution())
0 commit comments