#89 Mexican Wave


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!




#88 Which are in?


Given two arrays of strings a1 and a2 return a sorted array r in lexicographical order of the strings of a1 which are substrings of strings of a2.


#Example 1: a1 = ["arp", "live", "strong"]


a2 = ["lively", "alive", "harp", "sharp", "armstrong"]


returns ["arp", "live", "strong"]


#Example 2: a1 = ["tarp", "mice", "bull"]


a2 = ["lively", "alive", "harp", "sharp", "armstrong"]


returns []


Notes:

Arrays are written in "general" notation. See "Your Test Cases" for examples in your language.


In Shell bash a1 and a2 are strings. The return is a string where words are separated by commas.


Beware: r must be without duplicates.

Don't mutate the inputs.


#87 Extract the IDs from the data set 



Complete the method so that it returns an array of all ID's passed in. The data structure will be similar to the following:


var data = {
  id: 1,
  items: [
    {id: 2},
    {id: 3, items: [
      {id: 4},
      {id: 5}
    ]}
  ]
}



extractIds(data) // should return [1,2,3,4,5]

The method should be able to handle the case of empty data being passed in.


Note: The only arrays that need to be traversed are those assigned to the "items" property.


+ Recent posts