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
1.8 KiB
1.8 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 696655d24b614176d4c9b78d | Challenge 170: Odd or Even Day | 29 | challenge-170 |
--description--
Given a timestamp (number of milliseconds since the Unix epoch), return:
"odd"if the day of the month for that timestamp is odd."even"if the day of the month for that timestamp is even.
For example, given 1769472000000, a timestamp for January 27th, 2026, return "odd" because the day number (27) is an odd number.
Note: The timestamp is in milliseconds and you should use the date in the UTC timezone, not in your local time.
--hints--
odd_or_even_day(1769472000000) should return "odd".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(odd_or_even_day(1769472000000), "odd")`)
}})
odd_or_even_day(1769444440000) should return "even".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(odd_or_even_day(1769444440000), "even")`)
}})
odd_or_even_day(6739456780000) should return "odd".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(odd_or_even_day(6739456780000), "odd")`)
}})
odd_or_even_day(1) should return "odd".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(odd_or_even_day(1), "odd")`)
}})
odd_or_even_day(86400000) should return "even".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(odd_or_even_day(86400000), "even")`)
}})
--seed--
--seed-contents--
def odd_or_even_day(timestamp):
return timestamp
--solutions--
from datetime import datetime
def odd_or_even_day(timestamp):
dt = datetime.utcfromtimestamp(timestamp / 1000)
day = dt.day
return "even" if day % 2 == 0 else "odd"