Ad
Code
Diff
  • add = lambda x,y: x+y
    • # Write here your code
    • def add(x,y):
    • return x+y
    • add = lambda x,y: x+y
Code
Diff
  • find_max = max
    • def find_max(arr):
    • arr.sort()
    • return arr[-1]
    • find_max = max
Code
Diff
  • findMax = a => Math.max(...a)
    • const findMax = (a) => {
    • if (a !== undefined && a !== null) {
    • return a.sort((a, b) => a - b)[a.length - 1];
    • } else return;
    • };
    • findMax = a => Math.max(...a)
Logic
Mathematics
Algorithms
Numbers
Code
Diff
  • power_distance = lambda x: 2 * x - 1
    • def power_distance(x):
    • return x * 2 - 1
    • power_distance = lambda x: 2 * x - 1

shorter

Code
Diff
  • reverse = lambda x: x[::-1] if type(x) is str else int(str(x)[::-1])
    • reverse = lambda x: x[::-1] if isinstance(x, str) else int(str(x)[::-1])
    • reverse = lambda x: x[::-1] if type(x) is str else int(str(x)[::-1])
Fundamentals
Loops
Control Flow
Basic Language Features
Code
Diff
  • s=sorted
    • x=sorted
    • s=sorted
Fundamentals
Loops
Control Flow
Basic Language Features
Code
Diff
  • x=sorted
    • d=sorted
    • x=sorted
Fundamentals
Loops
Control Flow
Basic Language Features
Code
Diff
  • s=sorted
    • r=sorted
    • s=sorted
Fundamentals
Loops
Control Flow
Basic Language Features
Code
Diff
  • f=sorted
    • sort=sorted
    • f=sorted
Code
Diff
  • add=lambda a,b:sum([a,b])
    • add = lambda a,b: sum([a,b])
    • add=lambda a,b:sum([a,b])
Fundamentals
Loops
Control Flow
Basic Language Features
Code
Diff
  • sort_arr=sorted
    • sort_arr = sorted
    • sort_arr=sorted
Code
Diff
  • add = lambda a,b: sum([a,b])
    • def add(a, b):
    • return a + b
    • add = lambda a,b: sum([a,b])
Code
Diff
  • reverse = lambda x: x[::-1] if type(x) is str else int(str(x)[::-1])
    • def reverse(intOrStr):
    • return intOrStr[::-1] if repr(intOrStr)[0] == "'" else int(str(intOrStr)[::-1])
    • reverse = lambda x: x[::-1] if type(x) is str else int(str(x)[::-1])
Fundamentals
Loops
Control Flow
Basic Language Features
Code
Diff
  • sort_arr = sorted
    • def sort_arr(arr):
    • old_arr, new_arr, test = arr, [], 0
    • while len(old_arr) > 0:
    • for i in range(len(arr)):
    • test = i if old_arr[i] < old_arr[test] else test
    • new_arr.append(old_arr[test])
    • old_arr.pop(test)
    • test = 0
    • return new_arr
    • sort_arr = sorted