Ad

recursion

Code
Diff
  • def sum(arr):
        if not arr: return 0;
        return arr[0] + sum(arr[1:])
        
    • def sum(arr):
    • result = 0
    • for i in arr:
    • result += i
    • return result
    • if not arr: return 0;
    • return arr[0] + sum(arr[1:])
Code
Diff
  • const magick_message = x => ['codewarz', 'abracadabra!'][+x];
    
    • const magick_message = el => el ? 'abracadabra!' : 'codewarz';
    • const magick_message = x => ['codewarz', 'abracadabra!'][+x];