We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Mars Exploration
You are viewing a single comment's thread. Return to all comments →
python3 simple easy intuitive
def marsExploration(s): # Define the original SOS message original_sos = "SOS"