Ejemplo n.º 1
0
def countRT(p, limit): # counts right triangles OPQ where Q is to the left of OP
	# for a right angle, Q must lie on line perpendicular to OP
	# get the shortest integer vector on that line in the counter-clockwise direction
	# count how many times we can add it to P before going out of bounds
	if p[1] == 0: return limit
	dx, dy = reduceFrac(*p)
	return min(p[0] // dy, (limit - p[1]) // dx)
Ejemplo n.º 2
0
def countRT(p,
            limit):  # counts right triangles OPQ where Q is to the left of OP
    # for a right angle, Q must lie on line perpendicular to OP
    # get the shortest integer vector on that line in the counter-clockwise direction
    # count how many times we can add it to P before going out of bounds
    if p[1] == 0: return limit
    dx, dy = reduceFrac(*p)
    return min(p[0] // dy, (limit - p[1]) // dx)
Ejemplo n.º 3
0
def main():
	# this is a terrible question
	def seq():
		for d in range(11, 100):
			da, db = d // 10, d % 10
			if db > 0 and da != db:
				for n in range(10, d):
					na, nb = n // 10, n % 10
					if nb > 0 and na != nb and (da == na and n * db == nb * d or da == nb and n * db == na * d or db == na and n * da == nb * d or db == nb and n * da == na * d):
						yield n, d
	n, d = 1, 1
	for a, b in seq():
		n, d = a * n, b * d
	n, d = reduceFrac(n, d)
	return d
Ejemplo n.º 4
0
def main():
    # this is a terrible question
    def seq():
        for d in range(11, 100):
            da, db = d // 10, d % 10
            if db > 0 and da != db:
                for n in range(10, d):
                    na, nb = n // 10, n % 10
                    if nb > 0 and na != nb and (
                            da == na and n * db == nb * d
                            or da == nb and n * db == na * d
                            or db == na and n * da == nb * d
                            or db == nb and n * da == na * d):
                        yield n, d

    n, d = 1, 1
    for a, b in seq():
        n, d = a * n, b * d
    n, d = reduceFrac(n, d)
    return d