Thanks to the effects of El Nino this year my holiday snorkelling trip was akin to being in a washing machine... Not fun at all.
Given a string made up of '~' and '\_' representing waves and calm respectively, your job is to check whether a person would become seasick.
Remember, only the process of change from wave to calm (and vice versa) will add to the effect (really wave peak to trough but this will do). Find out how many changes in level the string has and if that figure is more than 20% of the string, return "Throw Up", if less, return "No Problem".
from operator import truediv


def sea_sick(s):
    result = sum(s[a:a + 2] in '_~_' for a in range(len(s) - 1))
    if truediv(result, len(s)) > 0.2:
        return 'Throw Up'
    return 'No Problem'

from operator import truediv


def sea_sick(s):
    result = sum(s[a:a + 2] in '_~_' for a in range(len(s) - 1))
    if truediv(result, len(s)) > 0.2:
        return 'Throw Up'
    return 'No Problem'
