Mars Exploration

  • + 0 comments

    python3 simple easy intuitive

    def marsExploration(s): # Define the original SOS message original_sos = "SOS"

    # Use list comprehension and enumerate to count altered letters
    # Iterate over each index i and character char in the input string s
    # Check if the character is different from the corresponding character in the original SOS message
    # The use of i % 3 ensures cycling through the characters of the original SOS message
    # Increment the altered_count for each altered letter
    altered_count = sum(1 for i, char in enumerate(s) if char != original_sos[i % 3])
    
    return altered_count