Ad
Code
Diff
  • from functools import reduce
    prod =lambda n:reduce(lambda x,y:x*y,n if n else[0])
    • from itertools import product
    • def prod(n):
    • if not n:return 0
    • n = n[-1]
    • fact = lambda x: x if x <= 2 else x*fact(x-1)
    • return fact(n)
    • from functools import reduce
    • prod =lambda n:reduce(lambda x,y:x*y,n if n else[0])
Algorithms
Logic
Code
Diff
  • get_nth_words = lambda string, n: "" if n<=0 else " ".join(string.split()[n-1::n])
    • def get_nth_words(string, n):
    • return " ".join(string.split()[n-1::n]) if n>0 else ""
    • get_nth_words = lambda string, n: "" if n<=0 else " ".join(string.split()[n-1::n])