Skip to main content
added 78 characters in body
Source Link
Shieru Asakoto
  • 6.3k
  • 16
  • 40

Python 2, 193 ... 179 178 bytes

d=10
u=d**2000
v=u*u
def s(n,a=d,i=9):
 while a-i:i,a=a,(a+n/a)/2
 return a
p,q,r,t=s(2*v),s(3*v),1,0
while p:t+=(p+q)%d*r;p/=d;q/=d;r*=d
for i in range(1000):print t/u;t=v/(t%u)

Try it online!

Calculating sqrt(2) and sqrt(3) to such a precision with a short code is a tough job in Python and other languages.

2000 digits is needed2000 digits is needed to ensure the expansion is correct (1020 suffices, but I'm not going to ensure the expansion is correctmodify it because no improvement), and lines 4-6 is the integer square root.

193 > 180 : The digit-wise modulo sum is now carried by a loop instead of array manipulation

180 > 179 : Replaced the 6 occurrences of 10 using d with the cost of defining with 5 bytes, cutting 1 byte in total

179 > 178 : Just realized that a!=i can be replaced by a-i

Python 2, 193 ... 179 178 bytes

d=10
u=d**2000
v=u*u
def s(n,a=d,i=9):
 while a-i:i,a=a,(a+n/a)/2
 return a
p,q,r,t=s(2*v),s(3*v),1,0
while p:t+=(p+q)%d*r;p/=d;q/=d;r*=d
for i in range(1000):print t/u;t=v/(t%u)

Try it online!

Calculating sqrt(2) and sqrt(3) to such a precision with a short code is a tough job in Python and other languages.

2000 digits is needed to ensure the expansion is correct, and lines 4-6 is the integer square root.

193 > 180 : The digit-wise modulo sum is now carried by a loop instead of array manipulation

180 > 179 : Replaced the 6 occurrences of 10 using d with the cost of defining with 5 bytes, cutting 1 byte in total

179 > 178 : Just realized that a!=i can be replaced by a-i

Python 2, 193 ... 179 178 bytes

d=10
u=d**2000
v=u*u
def s(n,a=d,i=9):
 while a-i:i,a=a,(a+n/a)/2
 return a
p,q,r,t=s(2*v),s(3*v),1,0
while p:t+=(p+q)%d*r;p/=d;q/=d;r*=d
for i in range(1000):print t/u;t=v/(t%u)

Try it online!

Calculating sqrt(2) and sqrt(3) to such a precision with a short code is a tough job in Python and other languages.

2000 digits is needed to ensure the expansion is correct (1020 suffices, but I'm not going to modify it because no improvement), and lines 4-6 is the integer square root.

193 > 180 : The digit-wise modulo sum is now carried by a loop instead of array manipulation

180 > 179 : Replaced the 6 occurrences of 10 using d with the cost of defining with 5 bytes, cutting 1 byte in total

179 > 178 : Just realized that a!=i can be replaced by a-i

added 71 characters in body
Source Link
Shieru Asakoto
  • 6.3k
  • 16
  • 40

Python 2, 193 ... 180179 179178 bytes

d=10
u=d**2000
v=u*u
def s(n,a=d,i=9):
 while a!=i-i:i,a=a,(a+n/a)/2
 return a
p,q,r,t=s(2*v),s(3*v),1,0
while p:t+=(p+q)%d*r;p/=d;q/=d;r*=d
for i in range(1000):print t/u;t=v/(t%u)

Try it online!Try it online!

Calculating sqrt(2) and sqrt(3) to such a precision with a short code is a tough job in Python and other languages.

2000 digits is needed to ensure the expansion is correct, and lines 4-6 is the integer square root.

193 > 180 : The digit-wise modulo sum is now carried by a loop instead of array manipulation

180 > 179 : Replaced the 6 occurrences of 10 using d with the cost of defining with 5 bytes, cutting 1 byte in total

179 > 178 : Just realized that a!=i can be replaced by a-i

Python 2, 193 180 179 bytes

d=10
u=d**2000
v=u*u
def s(n,a=d,i=9):
 while a!=i:i,a=a,(a+n/a)/2
 return a
p,q,r,t=s(2*v),s(3*v),1,0
while p:t+=(p+q)%d*r;p/=d;q/=d;r*=d
for i in range(1000):print t/u;t=v/(t%u)

Try it online!

Calculating sqrt(2) and sqrt(3) to such a precision with a short code is a tough job in Python and other languages.

2000 digits is needed to ensure the expansion is correct, and lines 4-6 is the integer square root.

193 > 180 : The digit-wise modulo sum is now carried by a loop instead of array manipulation

180 > 179 : Replaced the 6 occurrences of 10 using d with the cost of defining with 5 bytes, cutting 1 byte in total

Python 2, 193 ... 179 178 bytes

d=10
u=d**2000
v=u*u
def s(n,a=d,i=9):
 while a-i:i,a=a,(a+n/a)/2
 return a
p,q,r,t=s(2*v),s(3*v),1,0
while p:t+=(p+q)%d*r;p/=d;q/=d;r*=d
for i in range(1000):print t/u;t=v/(t%u)

Try it online!

Calculating sqrt(2) and sqrt(3) to such a precision with a short code is a tough job in Python and other languages.

2000 digits is needed to ensure the expansion is correct, and lines 4-6 is the integer square root.

193 > 180 : The digit-wise modulo sum is now carried by a loop instead of array manipulation

180 > 179 : Replaced the 6 occurrences of 10 using d with the cost of defining with 5 bytes, cutting 1 byte in total

179 > 178 : Just realized that a!=i can be replaced by a-i

added 242 characters in body
Source Link
Shieru Asakoto
  • 6.3k
  • 16
  • 40

Python 2, 193 180180 179 bytes

u=10**2000d=10
u=d**2000
v=u*u
def s(n,a=10a=d,i=9):
 while a!=i:i,a=a,(a+n/a)/2
 return a
p,q,r,t=s(2*v),s(3*v),1,0
while p:t+=(p+q)%10*r;p%d*r;p/=10;q=d;q/=10;r*=10=d;r*=d
for i in range(1000):print t/u;t=v/(t%u)

Try it online!Try it online!

Calculating sqrt(2)sqrt(2) and sqrt(3)sqrt(3) to such a precision with a short code is a tough job in Python and other languages. 2000

2000 digits is needed to ensure the expansion is correct, and the middle 3 lines 4-6 is the integer square root.

193 > 180 : The digit-wise modulo sum is now carried by a loop instead of array manipulation

180 > 179 : Replaced the 6 occurrences of 10 using d with the cost of defining with 5 bytes, cutting 1 byte in total

Python 2, 193 180 bytes

u=10**2000
v=u*u
def s(n,a=10,i=9):
 while a!=i:i,a=a,(a+n/a)/2
 return a
p,q,r,t=s(2*v),s(3*v),1,0
while p:t+=(p+q)%10*r;p/=10;q/=10;r*=10
for i in range(1000):print t/u;t=v/(t%u)

Try it online!

Calculating sqrt(2) and sqrt(3) to such a precision with a short code is a tough job in Python and other languages. 2000 digits is needed to ensure the expansion is correct, and the middle 3 lines is the integer square root.

Python 2, 193 180 179 bytes

d=10
u=d**2000
v=u*u
def s(n,a=d,i=9):
 while a!=i:i,a=a,(a+n/a)/2
 return a
p,q,r,t=s(2*v),s(3*v),1,0
while p:t+=(p+q)%d*r;p/=d;q/=d;r*=d
for i in range(1000):print t/u;t=v/(t%u)

Try it online!

Calculating sqrt(2) and sqrt(3) to such a precision with a short code is a tough job in Python and other languages.

2000 digits is needed to ensure the expansion is correct, and lines 4-6 is the integer square root.

193 > 180 : The digit-wise modulo sum is now carried by a loop instead of array manipulation

180 > 179 : Replaced the 6 occurrences of 10 using d with the cost of defining with 5 bytes, cutting 1 byte in total

deleted 681 characters in body
Source Link
Shieru Asakoto
  • 6.3k
  • 16
  • 40
Loading
added 18 characters in body
Source Link
Shieru Asakoto
  • 6.3k
  • 16
  • 40
Loading
added 141 characters in body
Source Link
Shieru Asakoto
  • 6.3k
  • 16
  • 40
Loading
Source Link
Shieru Asakoto
  • 6.3k
  • 16
  • 40
Loading