curriculum/challenges/english/blocks/daily-coding-challenges-python/699c8e045ee7cb94ed2322dd.md
Today is the equinox, when the sun is directly above the equator and perfectly overhead at noon. Given a time, determine the shadow cast by a 4-foot vertical pole.
"HH:MM" 24-hour format (for example, "15:00" is 3pm).Rules:
"east", and sets at 6pm directly "west".Return:
"(length)ft (direction)". For example, "8ft west"."No shadow".For example, given "10:00", return "8ft west" because 10am is 2 hours from noon, so 2<sup>3</sup> = 8 feet, and the shadow points west because the sun is in the east at 10am.
get_shadow("10:00") should return "8ft west".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_shadow("10:00"), "8ft west")`)
}})
get_shadow("15:00") should return "27ft east".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_shadow("15:00"), "27ft east")`)
}})
get_shadow("12:00") should return "No shadow".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_shadow("12:00"), "No shadow")`)
}})
get_shadow("17:30") should return "166.375ft east".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_shadow("17:30"), "166.375ft east")`)
}})
get_shadow("05:00") should return "No shadow".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_shadow("05:00"), "No shadow")`)
}})
get_shadow("06:00") should return "216ft west".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_shadow("06:00"), "216ft west")`)
}})
get_shadow("18:00") should return "No shadow".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_shadow("18:00"), "No shadow")`)
}})
get_shadow("07:30") should return "91.125ft west".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_shadow("07:30"), "91.125ft west")`)
}})
get_shadow("00:00") should return "No shadow".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_shadow("00:00"), "No shadow")`)
}})
def get_shadow(time):
return time
def get_shadow(time):
hour_str, minute_str = time.split(":")
hours = int(hour_str)
minutes = int(minute_str)
time_in_hours = hours + minutes / 60
if time_in_hours < 6 or time_in_hours >= 18 or time_in_hours == 12:
return "No shadow"
hours_from_noon = abs(12 - time_in_hours)
length = hours_from_noon ** 3
direction = "west" if time_in_hours < 12 else "east"
return f"{length:g}ft {direction}"