{}
CODE VISUALIZER
Master DSA, Python and C with step-by-step code visualization.
See it in action
CODE VISUALIZER
Master DSA, Python and C with step-by-step code visualization.
See it in action
run-icon
main.py
# the fact im normally the only one in the week's challenge completers that isnt using github shows that i really need to learn it at some point def isShuffledWell(inputArray): count = 1 lastDigit = -1 direction = "none" countThree = True for i in inputArray: if (lastDigit + 1) == i: if direction != "down": direction = "up" count = count + 1 if count == 3: countThree = False return countThree elif (lastDigit - 1) == i: if direction != "up": direction = "down" count = count + 1 if count == 3: countThree = False return countThree else: count = 1 direction == "none" lastDigit = i return countThree print(isShuffledWell([1, 2, 3, 5, 8, 6, 9, 10, 7, 4])) # output = false # 1, 2, 3 appear consecutively print(isShuffledWell([3, 5, 1, 9, 8, 7, 6, 4, 2, 10])) # output = false # 9, 8, 7, 6 appear consecutively print(isShuffledWell([1, 5, 3, 8, 10, 2, 7, 6, 4, 9])) # output = true # No consecutive numbers appear print(isShuffledWell([1, 3, 5, 7, 9, 2, 4, 6, 8, 10])) # output = true # No consecutive numbers appear
Output