Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

3.8 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
69738771fb5a7b8b24cca2a0 Challenge 174: Zodiac Finder 29 challenge-174

--description--

Given a date string in the format "YYYY-MM-DD", return the zodiac sign for that date using the following chart:

Date Range Zodiac Sign
March 21 - April 19 "Aries"
April 20 - May 20 "Taurus"
May 21 - June 20 "Gemini"
June 21 - July 22 "Cancer"
July 23 - August 22 "Leo"
August 23 - September 22 "Virgo"
September 23 - October 22 "Libra"
October 23 - November 21 "Scorpio"
November 22 - December 21 "Sagittarius"
December 22 - January 19 "Capricorn"
January 20 - February 18 "Aquarius"
February 19 - March 20 "Pisces"
  • Zodiac signs are based only on the month and day, you can ignore the year.

--hints--

get_sign("2026-01-31") should return "Aquarius".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_sign("2026-01-31"), "Aquarius")`)
}})

get_sign("2001-06-10") should return "Gemini".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_sign("2001-06-10"), "Gemini")`)
}})

get_sign("1985-09-07") should return "Virgo".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_sign("1985-09-07"), "Virgo")`)
}})

get_sign("2023-03-19") should return "Pisces".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_sign("2023-03-19"), "Pisces")`)
}})

get_sign("2045-11-05") should return "Scorpio".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_sign("2045-11-05"), "Scorpio")`)
}})

get_sign("1985-12-06") should return "Sagittarius".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_sign("1985-12-06"), "Sagittarius")`)
}})

get_sign("2025-12-30") should return "Capricorn".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_sign("2025-12-30"), "Capricorn")`)
}})

get_sign("2018-10-08") should return "Libra".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_sign("2018-10-08"), "Libra")`)
}})

get_sign("1958-05-04") should return "Taurus".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_sign("1958-05-04"), "Taurus")`)
}})

--seed--

--seed-contents--

def get_sign(date_str):

    return date_str

--solutions--

def get_sign(date_str):
    _, month_str, day_str = date_str.split("-")
    month = int(month_str)
    day = int(day_str)

    if (month == 3 and day >= 21) or (month == 4 and day <= 19):
        return "Aries"
    if (month == 4 and day >= 20) or (month == 5 and day <= 20):
        return "Taurus"
    if (month == 5 and day >= 21) or (month == 6 and day <= 20):
        return "Gemini"
    if (month == 6 and day >= 21) or (month == 7 and day <= 22):
        return "Cancer"
    if (month == 7 and day >= 23) or (month == 8 and day <= 22):
        return "Leo"
    if (month == 8 and day >= 23) or (month == 9 and day <= 22):
        return "Virgo"
    if (month == 9 and day >= 23) or (month == 10 and day <= 22):
        return "Libra"
    if (month == 10 and day >= 23) or (month == 11 and day <= 21):
        return "Scorpio"
    if (month == 11 and day >= 22) or (month == 12 and day <= 21):
        return "Sagittarius"
    if (month == 12 and day >= 22) or (month == 1 and day <= 19):
        return "Capricorn"
    if (month == 1 and day >= 20) or (month == 2 and day <= 18):
        return "Aquarius"
    if (month == 2 and day >= 19) or (month == 3 and day <= 20):
        return "Pisces"