Skip to content

Commit 24bf21d

Browse files
committed
daily
1 parent 4d8e14b commit 24bf21d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

my-submissions/m2698 v2.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def pot_sums(self, sqr: str, target_val: int) -> bool :
3+
if not sqr :
4+
return target_val == 0
5+
6+
return any(self.pot_sums(sqr[i + 1:], target_val - int(sqr[:i + 1]))
7+
for i in range(0, len(sqr)))
8+
9+
def punishmentNumber(self, n: int) -> int:
10+
return sum(x ** 2 for x in range(1, n + 1) if self.pot_sums(str(x ** 2), x))

my-submissions/m2698.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution:
2+
def pot_sums(self, sqr: str, target_val: int) -> bool :
3+
if not sqr :
4+
return target_val == 0
5+
6+
return any(self.pot_sums(sqr[i + 1:], target_val - int(sqr[:i + 1]))
7+
for i in range(0, len(sqr)))
8+
9+
10+
def punishmentNumber(self, n: int) -> int:
11+
output = 0
12+
for i in range(1, n + 1) :
13+
sqr = i ** 2
14+
if self.pot_sums(str(sqr), i) :
15+
output += sqr
16+
17+
return output

0 commit comments

Comments
 (0)