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

98 lines
1.7 KiB
Markdown

---
id: 69cfca90e8a0a6d4d6871c51
title: "Challenge 267: Parsec Converter"
challengeType: 29
dashedName: 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`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(1), 2)`)
}})
```
`convert_parsecs(2)` should return `6`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(2), 6)`)
}})
```
`convert_parsecs(31)` should return `62`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(31), 62)`)
}})
```
`convert_parsecs(88)` should return `264`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(88), 264)`)
}})
```
`convert_parsecs(17)` should return `34`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(17), 34)`)
}})
```
`convert_parsecs(14)` should return `42`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_parsecs(14), 42)`)
}})
```
# --seed--
## --seed-contents--
```py
def convert_parsecs(parsecs):
return parsecs
```
# --solutions--
```py
def convert_parsecs(parsecs):
if parsecs % 2 != 0:
return parsecs * 2
else:
return parsecs * 3
```