Call two arms equally strong if the heaviest weights they each are able to lift are equal.
Call two people equally strong if their strongest arms are equally strong (the strongest arm can be both the right and the left), and so are their weakest arms.
Given your and your friend’s arms’ lifting capabilities find out if you two are equally strong.
# 맨 처음엔 둘의 합을 가지고 계산하는 조건을 넣으려고 했으나, 생각해보니 강한 팔과 약한 팔의 값이 같으면 합은 당연히 같은 거라서 따로 조건을 넣어줄 필요가 업성서 뺐음 # yourWeight = yourLeft + yourRight # friendsWeight = friendsLeft + friendsRight
# 나의 강한 팔 값 찾기 if yourLeft >= yourRight: yourStrong = yourLeft yourWeak = yourRight else: yourStrong = yourRight yourWeak = yourLeft
# 친구의 강한 팔 값 찾기 if friendsLeft >= friendsRight: friendsStrong = friendsLeft friendsWeak = friendsRight else: friendsStrong = friendsRight friendsWeak = friendsLeft
# 비교해서 값 리턴하기 if (yourStrong == friendsStrong) and (yourWeak == friendsWeak): print("true") else: print("false")
Given an array of integers, find the maximal absolute difference between any two of its adjacent elements.
제출 코드
1 2 3 4 5 6
defarrayMaximalAdjacentDifference(inputArray): difflist = [] for i in range(len(inputArray)-1): difflist.append(abs(inputArray[i]-inputArray[i+1])) return max(difflist)