Skip to content

Commit

Permalink
more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zehengl committed Sep 25, 2023
1 parent 6582889 commit 43a3102
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/easy/completingthesquare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
x1, y1 = [int(d) for d in input().split()]
x2, y2 = [int(d) for d in input().split()]
x3, y3 = [int(d) for d in input().split()]

d12 = (x1 - x2) ** 2 + (y1 - y2) ** 2
d13 = (x1 - x3) ** 2 + (y1 - y3) ** 2
d23 = (x2 - x3) ** 2 + (y2 - y3) ** 2

if d12 == d13:
x, y = x2 + x3 - x1, y2 + y3 - y1
elif d12 == d23:
x, y = x1 + x3 - x2, y1 + y3 - y2
else:
x, y = x1 + x2 - x3, y1 + y2 - y3

print(x, y)
15 changes: 15 additions & 0 deletions src/easy/samedigitshard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
a, b = [int(d) for d in input().split()]
pairs = []
for x in range(a, b + 1):
for y in range(x, b + 1):
xy = x * y
if x * y > b:
break
if sorted(str(xy)) == sorted(str(x) + str(y)):
pairs.append((x, y, xy))
if x * x > b:
break

print(f"{len(pairs)} digit-preserving pair(s)")
for x, y, xy in pairs:
print(f"x = {x}, y = {y}, xy = {xy}")

0 comments on commit 43a3102

Please sign in to comment.