Renamed all folders
This commit is contained in:
53
033/main.py
Normal file
53
033/main.py
Normal file
@@ -0,0 +1,53 @@
|
||||
'''
|
||||
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s.
|
||||
|
||||
We shall consider fractions like, 30/50 = 3/5, to be trivial examples.
|
||||
|
||||
There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator.
|
||||
|
||||
If the product of these four fractions is given in its lowest common terms, find the value of the denominator.
|
||||
'''
|
||||
|
||||
def listify(i):
|
||||
return [int(x) for x in str(i)]
|
||||
|
||||
def check(num, denom):
|
||||
result = False
|
||||
|
||||
frac = num / denom
|
||||
|
||||
lnum = listify(num)
|
||||
ldenom = listify(denom)
|
||||
|
||||
if lnum[0] == ldenom[0] and ldenom[1] != 0:
|
||||
result = lnum[1] / ldenom[1] == frac
|
||||
elif lnum[1] == ldenom[0] and ldenom[1] != 0:
|
||||
result = lnum[0] / ldenom[1] == frac
|
||||
elif lnum[0] == ldenom[1]:
|
||||
result = lnum[1] / ldenom[0] == frac
|
||||
elif lnum[1] == ldenom[1]:
|
||||
result = lnum[0] / ldenom[0] == frac
|
||||
|
||||
return result
|
||||
|
||||
def main():
|
||||
print("Hello, this is Patrick")
|
||||
|
||||
numres = 1
|
||||
denomres = 1
|
||||
|
||||
for denom in range(11, 100):
|
||||
for num in range(10, denom):
|
||||
if not (denom % 10 == 0 and num % 10 == 0) and check(num, denom):
|
||||
numres *= num
|
||||
denomres *= denom
|
||||
|
||||
print(num, denom)
|
||||
|
||||
print(f"{numres}/{denomres}")
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user