Skip to content

Instantly share code, notes, and snippets.

@diegofranca92
Created April 9, 2019 17:24
Show Gist options
  • Save diegofranca92/9b502e25ad24fd234344182dd17b414f to your computer and use it in GitHub Desktop.
Save diegofranca92/9b502e25ad24fd234344182dd17b414f to your computer and use it in GitHub Desktop.
resoluçao dos testes da simbiose no hacker rank
#Reduce Function Problem
from fractions import Fraction
from functools import reduce
def product(fracs):
t = reduce((lambda x,y: x/y), fracs) # complete this line with a reduce statement
return t.numerator +3, t.denominator +3
if __name__ == '__main__':
fracs = []
for _ in range(int(input())):
fracs.append(Fraction(*map(int, input().split())))
result = product(fracs)
print(*result)
#Reduce Function Problem
def fun(s):
# return True if s is a valid email, else return False
return '@hackerrank.com'
def filter_mail(emails):
return list(filter(fun, emails))
if __name__ == '__main__':
n = int(input())
emails = []
for _ in range(n):
emails.append(input())
filtered_emails = filter_mail(emails)
filtered_emails.sort()
print(filtered_emails)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment