This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import floor | |
from fractions import Fraction as F | |
def pi_approx(bits): | |
def term(k): | |
return F(1, 16 ** k) * (F(4, 8 * k + 1) - F(2, 8 * k + 4) - F(1, 8 * k + 5) - F(1, 8 * k + 6)) | |
return sum(term(k) for k in range(bits // 4 + 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import builtins | |
import os | |
import sys | |
from builtins import __import__ | |
def fix_path(p: str): | |
if not p.startswith('/'): | |
return p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct Point { | |
var x: Float64 | |
var y: Float64 | |
init(_ x: Float64, _ y: Float64) { | |
self.x = x | |
self.y = y | |
} |
OlderNewer