Skip to content

Instantly share code, notes, and snippets.

@riceissa
Created August 4, 2020 07:17
Show Gist options
  • Save riceissa/104a31bb50b9e1d50e2a22ae78d4d000 to your computer and use it in GitHub Desktop.
Save riceissa/104a31bb50b9e1d50e2a22ae78d4d000 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
x = 99901
y = 6994
m = 3
x1 = x // (10**m)
x0 = x % (10**m)
y1 = y // (10**m)
y0 = y % (10**m)
z2 = x1 * y1
z0 = x0 * y0
# z1 = x1 * y0 + x0 * y1
z1 = (x1 + x0)*(y1 + y0) - z2 - z0
result = z2 * 10**(2*m) + z1 * 10**m + z0
print("""x = {}
y = {}
x1 = {}
x0 = {}
x1 + x0 = {}
y1 = {}
y0 = {}
y1 + y0 = {}
z2 = {}
z1 = {}
z0 = {}
result = {}
result_correct = {}""".format(x, y, x1, x0, x1 + x0, y1, y0, y1 + y0, z2, z1, z0, result, x*y))
@riceissa
Copy link
Author

riceissa commented Aug 4, 2020

Output:

x = 99901
y = 6994
x1 = 99
x0 = 901
x1 + x0 = 1000
y1 = 6
y0 = 994
y1 + y0 = 1000
z2 = 594
z1 = 103812
z0 = 895594
result = 698707594
result_correct = 698707594

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment