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
88 lines
1.8 KiB
Markdown
88 lines
1.8 KiB
Markdown
---
|
|
id: 6a2037a68a0bc2aef0006007
|
|
title: "Challenge 345: Word Blender"
|
|
challengeType: 29
|
|
dashedName: challenge-345
|
|
---
|
|
|
|
# --description--
|
|
|
|
Given two words, return a new word by combining the first half of the first word with the second half of the second word.
|
|
|
|
- For odd-length words, the first half is the shorter half.
|
|
|
|
# --hints--
|
|
|
|
`blend_words("turtle", "toucan")` should return `"turcan"`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(blend_words("turtle", "toucan"), "turcan")`)
|
|
}})
|
|
```
|
|
|
|
`blend_words("chipmunk", "flamingo")` should return `"chipingo"`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(blend_words("chipmunk", "flamingo"), "chipingo")`)
|
|
}})
|
|
```
|
|
|
|
`blend_words("falcon", "pelican")` should return `"falican"`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(blend_words("falcon", "pelican"), "falican")`)
|
|
}})
|
|
```
|
|
|
|
`blend_words("hyena", "iguana")` should return `"hyana"`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(blend_words("hyena", "iguana"), "hyana")`)
|
|
}})
|
|
```
|
|
|
|
`blend_words("scorpion", "gorilla")` should return `"scorilla"`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(blend_words("scorpion", "gorilla"), "scorilla")`)
|
|
}})
|
|
```
|
|
|
|
`blend_words("platypus", "wolverine")` should return `"platerine"`.
|
|
|
|
```js
|
|
({test: () => { runPython(`
|
|
from unittest import TestCase
|
|
TestCase().assertEqual(blend_words("platypus", "wolverine"), "platerine")`)
|
|
}})
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```py
|
|
def blend_words(word1, word2):
|
|
|
|
return word1
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```py
|
|
def blend_words(word1, word2):
|
|
first_half = word1[:len(word1) // 2]
|
|
second_half = word2[len(word2) // 2:]
|
|
return first_half + second_half
|
|
```
|