Euler Problem 71

A lot of simplification and reduction. Not too complicated. Nice and short. Runs fast.

#Euler71
class Problem71:
    def __init__(self, limit):
        self.limit = limit
    def Solution(self):
        min = 0
        min_n = 0
        for n in range (int(min*self.limit), int(self.limit*float(3)/7)):
            f = float(n)/self.limit
            if f < float(3)/7:
                if f > min:
                    min = f
                    min_n = n
        return "Answer:"+str(min_n)
if __name__ == '__main__':
    P = Problem71(1000000)
    print P.Solution()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s