-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMexicanWave.cpp
More file actions
104 lines (76 loc) · 2.54 KB
/
MexicanWave.cpp
File metadata and controls
104 lines (76 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include <string>
#include <sstream>
#include <climits>
using namespace std;
vector<string> wave(string y) {
vector<string>result;
string resulttemp;
int count = 0;
for (int i = 0; i < y.size(); i++)
{
string resulttemp = y;
resulttemp[i] = toupper(resulttemp[i]);
result.push_back(resulttemp);
}
return result;
}
int main()
{
vector<string>ss = wave("hello");
for (int i = 0; i < ss.size(); i++)
{
cout << ss[i] << endl;
}
return 0;
}
/*Description:
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
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.
Rank
Maze Runner
Rank
Scooby Doo Puzzle
Rank
Driving License
Rank
Connect 4
Rank
Vending Machine
Rank
Snakes and Ladders
Rank
Mastermind
Rank
Guess Who?
Rank
Am I safe to drive?
Rank
Mexican Wave
Rank
Pigs in a Pen
Rank
Hungry Hippos
Rank
Plenty of Fish in the Pond
Rank
Fruit Machine
Rank
Car Park Escape
Arrays
Strings
Fundamentals*/