T.T.T.23: Silly birds
Description:
Story
Maybe you've been asked a question about the bird: there are eight birds in the tree. "Bang!", a man shot and killed a bird. How many birds are there in the tree now? If you are a child, you may answer 7. We are not children. We know that the bird will fly away after hearing the sound of the gun, there are 0 birds in the tree. Unless, they are silly birds ;-)
Task
Complete function sillyBirds()
that accept an array updown
that contains two strings, and a string shot
. We can imagine the string in updown
are two parallel wires, some silly birds stand on the wire.
updown = [
"____B____",
"_________"
]
They hear shots don't fly away, only to change their position. They always fly in the direction of 45 degrees (up or down). They always fly to the right (if there is no other bird in that position).
shot="Bang!" //Shoot 1 time
return value === [
"_________",
"_____B___"
]
//another example of shoot 2 times:
updown = [
"____B____",
"_________"
]
shot="Bang!Bang!" //Shoot 2 times
return value === [
"______B__",
"_________"
]
If there is another bird on the right, it will fly to the left.
updown = [
"____B____",
"_____B___"
]
shot="Bang!" //Shoot 1 time
return value === [
"______B__",
"___B_____"
]
If there is another bird on both sides, it will fly away.(not too silly ;-)
updown = [
"____B____",
"___B_B___"
]
shot="Bang!" //Shoot 1 time
return value === [
"__B___B__",
"_________"
]
If the bird's position is on the border, it will fly close to the middle.
updown = [
"B_______B",
"_________"
]
shot="Bang!" //Shoot 1 time
return value === [
"_________",
"_B_____B_"
]
If there are obstacles (other birds), it will fly away.
updown = [
"B________",
"_B_______"
]
shot="Bang!" //Shoot 1 time
return value === [
"__B______",
"_________"
]
If there are no birds, return two wires ;-)
updown = [
"_________",
"_________"
]
shot="Bang!" //Shoot 1 time
return value === [
"_________",
"_________"
]
Finally, I want to say is that this is just a game, I do not want to kill the birds with a gun, we should take care of birds and other animals ;-)
Similar Kata:
Stats:
Created | Aug 9, 2016 |
Published | Aug 9, 2016 |
Warriors Trained | 223 |
Total Skips | 19 |
Total Code Submissions | 475 |
Total Times Completed | 62 |
JavaScript Completions | 41 |
Python Completions | 26 |
Total Stars | 5 |
% of votes with a positive feedback rating | 94% of 25 |
Total "Very Satisfied" Votes | 23 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |