> For the complete documentation index, see [llms.txt](https://anton-veselskyi.gitbook.io/codding-problems-solutions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://anton-veselskyi.gitbook.io/codding-problems-solutions/codewars/6-kyu/mexican-wave.md).

# Mexican Wave

### [Mexican Wave](https://www.codewars.com/kata/58f5c63f1e26ecda7e000029)

## Introduction

```

The wave (known as the Mexican wave in the English-speaking world outside North America) is an example of metachronal rhythm achieved in a packed stadium when successive groups of spectators briefly stand, yell, and raise their arms. Immediately upon stretching to full height, the spectator returns to the usual seated position.

The result is a wave of standing spectators that travels through the crowd, even though individual spectators never move away from their seats. In many large arenas the crowd is seated in a contiguous circuit all the way around the sport field, and so the wave is able to travel continuously around the arena; in discontiguous seating arrangements, the wave can instead reflect back and forth through the crowd. When the gap in seating is narrow, the wave can sometimes pass through it. Usually only one wave crest will be present at any given time in an arena, although simultaneous, counter-rotating waves have been produced. (Source Wikipedia)
```

## Task

```

In this simple Kata your task is to create a function that turns a string into a Mexican Wave. You will be passed a string and you must return that string in an array where an uppercase letter is a person standing up. 
```

## Rules

```

 1.  The input string will always be lower case but maybe empty.

 2.  If the character in the string is whitespace then pass over it as if it was an empty seat
```

## Example

```go
wave("hello") => []string{"Hello", "hEllo", "heLlo", "helLo", "hellO"}
```

```
(wave "hello") ; returns '("Hello" "hEllo" "heLlo" "helLo" "hellO")
```

```javascript
wave("hello") => ["Hello", "hEllo", "heLlo", "helLo", "hellO"]
```

```ruby
wave("hello") => ["Hello", "hEllo", "heLlo", "helLo", "hellO"]
```

```python
wave("hello") => ["Hello", "hEllo", "heLlo", "helLo", "hellO"]
```

```rust
wave("hello") => ["Hello", "hEllo", "heLlo", "helLo", "hellO"]
```

Good luck and enjoy!

## Kata Series

If you enjoyed this, then please try one of my other Katas. Any feedback, translations and grading of beta Katas are greatly appreciated. Thank you.

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Maze Runner](https://www.codewars.com/kata/5866px3693b359c4a6560001d6)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Scooby Doo Puzzle](https://www.codewars.com/kata/58693bbfd7da144164000d05)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/7KYU.png) [Driving License](https://www.codewars.com/kata/586a1af1c66pxd18ad81000134)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Connect 4](https://www.codewars.com/kata/586c0909c1923fdb89002031)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Vending Machine](https://www.codewars.com/kata/586e6d4cb98de09e3800014f)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Snakes and Ladders](https://www.codewars.com/kata/587136ba2eefcb92a9000027)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Mastermind](https://www.codewars.com/kata/58a848258a6909dd35000003)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Guess Who?](https://www.codewars.com/kata/58b2c5de4cf8b90723000051)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Am I safe to drive?](https://www.codewars.com/kata/58f5c63f1e26ecda7e000029)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Mexican Wave](https://www.codewars.com/kata/58f5c63f1e26ecda7e000029)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Pigs in a Pen](https://www.codewars.com/kata/58fdcc51b4f81a0b1e00003e)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Hungry Hippos](https://www.codewars.com/kata/590300eb378a9282ba000095)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Plenty of Fish in the Pond](https://www.codewars.com/kata/5904be220881cb68be00007d)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Fruit Machine](https://www.codewars.com/kata/590adadea658017d90000039)

![](https://raw.githubusercontent.com/adrianeyre/codewars/master/Ruby/Authored/6KYU.png) [Car Park Escape](https://www.codewars.com/kata/591eab1d192fe0435e000014)

### Solutions

#### 🐍 Python

```python
def wave(str):
    return [str[:n]+str[n].upper()+str[n+1:] for n in range(len(str)) if str[n].isalpha() ]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://anton-veselskyi.gitbook.io/codding-problems-solutions/codewars/6-kyu/mexican-wave.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
