A new poetry club has opened in town, and you're thinking of attending. Because there have been incidents in the past, the club has a very specific door policy which you'll need to master, before attempting entry.
There are two doors at the poetry club, both are guarded. In order to gain entry, you'll need to work out the password of that day:
The first thing you need to do is split the poem into individual lines. The guard will recite a poem, and you will have to split it into lines.
Implement the function splitOnNewlines that takes a string and splits it into an array of strings, using the newline character as the delimiter.
The function should return an array of strings, where each string is a line from the poem.
splitOnNewlines("Hello.\nHow are you?\n\nI'm doing fine.")
// returns ["Hello." ,"How are you?", "", "I'm doing fine"]._ instead.For example, one of their favorite writers is Michael Lockwood, who's written the following acrostic poem, which means that the first letter of each sentence form a word:
Stands so high
Huge hooves too
Impatiently waits for
Reins and harness
Eager to leaveWhen the guard recites the poem, you will split it into individual lines and respond with the first letters of each line, i.e. ["S", "H", "I", "R", "E"].
The guard will then give you the word formed by the array of letters you replied with for you to put into capitalized word form.
Finally the password you return is "SHIRE", and you'll get in.
Implement the function frontDoorPassword that takes a string which represents the poem.
The function should return the password that you would give to the guard.
frontDoorPassword("Stands so high\nHuge hooves too\nImpatiently waits for\nReins and harness\nEager to leave")
// returns "SHIRE"In the back of the club you'll find the most renowned poets, which is like the VIP area. Because this is not for everyone, the back door process is a bit more convoluted.
", please" to the end of the word formed by the letters.For example, the poem mentioned before is also telestich, which means that the last letter of each sentence form a word:
Stands so high
Huge hooves too
Impatiently waits for
Reins and harness
Eager to leaveWhen the guard recites the poem, you will split it into individual lines, strip off any trailing spaces, and respond with the first letters of each line, i.e. ["h", "o", "r", "s", "e"].
The guard will then give you the word formed by the array of letters you replied with for you to put into capitalized word form and append ", please".
Finally the password you return is "horse, please", and you'll get in.
Implement the function backDoorPassword that takes a string which represents the poem.
The function should return the password that you would give to the guard.
backDoorPassword("Stands so high\nHuge hooves too\nImpatiently waits for\nReins and harness\nEager to leave")
// returns "horse, please"Inside the back room of the club is another door that leads to the secret room that only the very top poets may enter.
"!" to the end of the word formed by the letters.For example, a modified version of the poem mentioned before fits this pattern:
Stands so high
Huge hooves too
Impatiently waits for
Rider with harness
Eager to leaveWhen the guard recites the poem, you will split it into individual lines, strip off any trailing spaces, and respond with the i<sup>th</sup> letters of each line, i.e. ["S", "u", "p", "e", "r"].
The guard will then give you the word formed by the array of letters you replied with for you to put into uppercased word form and append "!".
Finally the password you return is SUPER!, and you'll get in.
Implement the function secretRoomPassword that takes a string which represents the poem.
The function should return the password that you would give to the guard.
secretRoomPassword("Stands so high\nHuge hooves too\nImpatiently waits for\nRider with harness\nEager to leave")
// returns "SUPER!"A new poetry club has opened in town, and you're thinking of attending. Because there have been incidents in the past, the club has a very specific door policy which you'll need to master, before attempting entry.
There are two doors at the poetry club, both are guarded. In order to gain entry, you'll need to work out the password of that day:
The first thing you need to do is split the poem into individual lines. The guard will recite a poem, and you will have to split it into lines.
Implement the function splitOnNewlines that takes a string and splits it into an array of strings, using the newline character as the delimiter.
The function should return an array of strings, where each string is a line from the poem.
splitOnNewlines("Hello.\nHow are you?\n\nI'm doing fine.")
// returns ["Hello." ,"How are you?", "", "I'm doing fine"]._ instead.For example, one of their favorite writers is Michael Lockwood, who's written the following acrostic poem, which means that the first letter of each sentence form a word:
Stands so high
Huge hooves too
Impatiently waits for
Reins and harness
Eager to leaveWhen the guard recites the poem, you will split it into individual lines and respond with the first letters of each line, i.e. ["S", "H", "I", "R", "E"].
The guard will then give you the word formed by the array of letters you replied with for you to put into capitalized word form.
Finally the password you return is "SHIRE", and you'll get in.
Implement the function frontDoorPassword that takes a string which represents the poem.
The function should return the password that you would give to the guard.
frontDoorPassword("Stands so high\nHuge hooves too\nImpatiently waits for\nReins and harness\nEager to leave")
// returns "SHIRE"In the back of the club you'll find the most renowned poets, which is like the VIP area. Because this is not for everyone, the back door process is a bit more convoluted.
", please" to the end of the word formed by the letters.For example, the poem mentioned before is also telestich, which means that the last letter of each sentence form a word:
Stands so high
Huge hooves too
Impatiently waits for
Reins and harness
Eager to leaveWhen the guard recites the poem, you will split it into individual lines, strip off any trailing spaces, and respond with the first letters of each line, i.e. ["h", "o", "r", "s", "e"].
The guard will then give you the word formed by the array of letters you replied with for you to put into capitalized word form and append ", please".
Finally the password you return is "horse, please", and you'll get in.
Implement the function backDoorPassword that takes a string which represents the poem.
The function should return the password that you would give to the guard.
backDoorPassword("Stands so high\nHuge hooves too\nImpatiently waits for\nReins and harness\nEager to leave")
// returns "horse, please"Inside the back room of the club is another door that leads to the secret room that only the very top poets may enter.
"!" to the end of the word formed by the letters.For example, a modified version of the poem mentioned before fits this pattern:
Stands so high
Huge hooves too
Impatiently waits for
Rider with harness
Eager to leaveWhen the guard recites the poem, you will split it into individual lines, strip off any trailing spaces, and respond with the i<sup>th</sup> letters of each line, i.e. ["S", "u", "p", "e", "r"].
The guard will then give you the word formed by the array of letters you replied with for you to put into uppercased word form and append "!".
Finally the password you return is SUPER!, and you'll get in.
Implement the function secretRoomPassword that takes a string which represents the poem.
The function should return the password that you would give to the guard.
secretRoomPassword("Stands so high\nHuge hooves too\nImpatiently waits for\nRider with harness\nEager to leave")
// returns "SUPER!"