Ad
Code
Diff
  • {-# Language ViewPatterns #-}
    
    module Code (powerfulArray) where
    
    powerfulArray :: Int -> [Int]
    powerfulArray 0 = []
    powerfulArray (pred -> n) = arrayN ++ 2^n : arrayN
      where arrayN = powerfulArray n
    • {-# Language ViewPatterns #-}
    • module Code (powerfulArray) where
    • powerfulArray :: Int -> [Int]
    • powerfulArray 0 = []
    • powerfulArray (pred -> n) = powerfulArray n ++ 2^n : powerfulArray n
    • powerfulArray (pred -> n) = arrayN ++ 2^n : arrayN
    • where arrayN = powerfulArray n
Fundamentals
Code
Diff
  • from itertools import chain
    numberprint = lambda n: int(''.join([str(x) for x in chain(range(1,n+1), range(n-1,0,-1))]))
    • numberprint=lambda n: int(''.join(str(x) for x in (list(range(1, n+1)) + list(range(n-1, 0, -1)))))
    • from itertools import chain
    • numberprint = lambda n: int(''.join([str(x) for x in chain(range(1,n+1), range(n-1,0,-1))]))
Code
Diff
  • const isDivisible = (n,...args) => args.every(arg => n % arg == 0);
    • const isDivisible = (n,...args) => args.every(arg => Number.isInteger(n / arg));
    • const isDivisible = (n,...args) => args.every(arg => n % arg == 0);