Ad
Code
Diff
  • def test():
        return "".join(map(lambda i: {'1': 't', '2': 'e', '3': 's', '4': 't'}[str(i)], range(1, 5)))
    
    • def test():
    • something = {1: 't', 2: 'e', 3: "s", 4: "t"}
    • result = [something[i] for i in range(1, 5)]
    • return "".join(result)
    • return "".join(map(lambda i: {'1': 't', '2': 'e', '3': 's', '4': 't'}[str(i)], range(1, 5)))
Code
Diff
  • def test():
        something = {1: 't', 2: 'e', 3: "s", 4: "t"}
        result = [something[i] for i in range(1, 5)]
        return "".join(result)
    • def test():
    • test = []
    • i = 0
    • while i < 5:
    • i += 1
    • match i:
    • case 1:
    • test.append("t")
    • case 2:
    • test.append("e")
    • case 3:
    • test.append("s")
    • case 4:
    • test.append("t")
    • return ''.join(test)
    • something = {1: 't', 2: 'e', 3: "s", 4: "t"}
    • result = [something[i] for i in range(1, 5)]
    • return "".join(result)
Code
Diff
  • def test():
        test = []
        i = 0
        while i < 5:
            i += 1
            if i == 1:
                test.append("t")
            elif i == 2:
                test.append("e")
            elif i == 3:
                test.append("s")
            elif i == 4:
                test.append("t")
    
        return ''.join(test)
        
    
    • def test():
    • words = ['t', 'e', 's', 't']
    • result = ''
    • for word in words:
    • result += word
    • return result
    • test = []
    • i = 0
    • while i < 5:
    • i += 1
    • if i == 1:
    • test.append("t")
    • elif i == 2:
    • test.append("e")
    • elif i == 3:
    • test.append("s")
    • elif i == 4:
    • test.append("t")
    • return ''.join(test)
Code
Diff
  • def est_height(gender,dad_height,mom_height):
        n = 1 if gender == "boy" else - 1
        return (dad_height + mom_height + n) /2
        
    • def est_height(gender,dad_height,mom_height):
    • return (dad_height+mom_height+1)/2 if gender == "boy" else (dad_height+mom_height-1)/2
    • n = 1 if gender == "boy" else - 1
    • return (dad_height + mom_height + n) /2