79191708

Date: 2024-11-15 09:19:07
Score: 1.5
Natty:
Report link

why don't you just count different adjacent values and add one finally. That's it.

count = 1

# Iterate through the list starting from the second element
for i in range(1, len(X)):
    # If the current element is different from the previous one, it's alternating
    if X[i] != X[i - 1]:
        count += 1

return count
Reasons:
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Starts with a question (0.5): why don't you
  • Low reputation (1):
Posted by: Abenezar zegeye