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

89 lines
1.7 KiB
Markdown

---
id: 69a890af247de743333bd4ce
title: "Challenge 225: No Consecutive Repeats"
challengeType: 29
dashedName: challenge-225
---
# --description--
Given a string, determine if it has no repeating characters.
- A string has no repeats if it does not have the same character two or more times in a row.
# --hints--
`has_no_repeats("hi world")` should return `True`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("hi world"), True)`)
}})
```
`has_no_repeats("hello world")` should return `False`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("hello world"), False)`)
}})
```
`has_no_repeats("abcdefghijklmnopqrstuvwxyz")` should return `True`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("abcdefghijklmnopqrstuvwxyz"), True)`)
}})
```
`has_no_repeats("freeCodeCamp")` should return `False`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("freeCodeCamp"), False)`)
}})
```
`has_no_repeats("The quick brown fox jumped over the lazy dog.")` should return `True`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("The quick brown fox jumped over the lazy dog."), True)`)
}})
```
`has_no_repeats("Mississippi")` should return `False`.
```js
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("Mississippi"), False)`)
}})
```
# --seed--
## --seed-contents--
```py
def has_no_repeats(s):
return s
```
# --solutions--
```py
def has_no_repeats(s):
for i in range(1, len(s)):
if s[i] == s[i-1]:
return False
return True
```