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.7 KiB
1.7 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 69cfca90e8a0a6d4d6871c51 | Challenge 267: Parsec Converter | 29 | challenge-267 |
--description--
In a distant galaxy, parsecs are used to measure both time and distance. Given an integer number of parsecs, return its equivalent in time or distance.
- If the given integer is odd, it represents time. If it's even, it represents distance.
Use these conversion rates:
| Parsecs | Time/Distance |
|---|---|
| 1 | 2 hours |
| 2 | 6 light years |
Return the converted value as an integer.
--hints--
convert_parsecs(1) should return 2.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(1), 2)`)
}})
convert_parsecs(2) should return 6.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(2), 6)`)
}})
convert_parsecs(31) should return 62.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(31), 62)`)
}})
convert_parsecs(88) should return 264.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(88), 264)`)
}})
convert_parsecs(17) should return 34.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(17), 34)`)
}})
convert_parsecs(14) should return 42.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(14), 42)`)
}})
--seed--
--seed-contents--
def convert_parsecs(parsecs):
return parsecs
--solutions--
def convert_parsecs(parsecs):
if parsecs % 2 != 0:
return parsecs * 2
else:
return parsecs * 3