Skip to content

Commit abd06b9

Browse files
* docs: kata description * feat: kata/drone-fly-by --------- Co-authored-by: ParanoidUser <5120290+ParanoidUser@users.noreply.github.com>
1 parent 15fe351 commit abd06b9

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

kata/7-kyu/drone-fly-by/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# [Drone Fly-By](https://www.codewars.com/kata/drone-fly-by "https://www.codewars.com/kata/58356a94f8358058f30004b5")
2+
3+
![](http://www.grindtv.com/wp-content/uploads/2015/08/drone.jpg)
4+
5+
The other day I saw an amazing video where a guy hacked some Wi-Fi controlled lightbulbs by flying a drone past them. Brilliant.
6+
7+
In this kata we will recreate that stunt... sort of.
8+
9+
You will be given two strings: `lamps` and `drone`. `lamps` represents a row of lamps, currently off, each represented by `x`. When these lamps are on, they should be represented by `o`.
10+
11+
The `drone` string represents the position of the drone `T` (any better suggestion for character??) and its flight path up until this point `=`. The drone always flies left to right, and always begins at the start of the row of lamps. Anywhere the drone has flown, including its current position, will result in the lamp at that position switching on.
12+
13+
Return the resulting `lamps` string. See example tests for more clarity.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Kata {
2+
static String flyBy(String lamps, String drone) {
3+
return "o".repeat(Math.min(lamps.length(), drone.length())) + "x".repeat(Math.max(0, lamps.length() - drone.length()));
4+
}
5+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import static org.junit.jupiter.api.Assertions.assertEquals;
2+
3+
import org.junit.jupiter.params.ParameterizedTest;
4+
import org.junit.jupiter.params.provider.CsvSource;
5+
6+
class DroneFlyByTest {
7+
@ParameterizedTest
8+
@CsvSource(textBlock = """
9+
xxxxxx, ====T, ooooox
10+
xxxxxxxxx, ==T, oooxxxxxx
11+
xxxxxxxxxxxxxxx, =========T, ooooooooooxxxxx
12+
""")
13+
void sample(String lamps, String drone, String expected) {
14+
assertEquals(expected, Kata.flyBy(lamps, drone));
15+
}
16+
}

kata/7-kyu/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
- [Double value every next call](double-value-every-next-call "632408defa1507004aa4f2b5")
157157
- [Driving Licence](driving-licence "586a1af1c66d18ad81000134")
158158
- [Driving School Series #2](driving-school-series-number-2 "589b1c15081bcbfe6700017a")
159+
- [Drone Fly-By](drone-fly-by "58356a94f8358058f30004b5")
159160
- [Drying Potatoes](drying-potatoes "58ce8725c835848ad6000007")
160161
- [EAN Validation](ean-validation "55563df50dda59adf900004d")
161162
- [Easy Line](easy-line "56e7d40129035aed6c000632")

0 commit comments

Comments
 (0)