File tree 4 files changed +32
-0
lines changed 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ # [ Area of an arrow] ( https://www.codewars.com/kata/area-of-an-arrow " https://www.codewars.com/kata/589478160c0f8a40870000bc ")
2
+
3
+ An arrow is formed in a rectangle with sides ` a ` and ` b ` by joining the bottom corners to the midpoint of the top edge and the centre of the
4
+ rectangle.
5
+
6
+ 
7
+
8
+ ` a ` and ` b ` are ` integers ` and ` > 0 `
9
+
10
+ Write a function which returns the area of the arrow.
Original file line number Diff line number Diff line change
1
+ interface Solution {
2
+ static double arrowArea (double a , double b ) {
3
+ return a * b / 4 ;
4
+ }
5
+ }
Original file line number Diff line number Diff line change
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 SolutionTest {
7
+ @ ParameterizedTest
8
+ @ CsvSource (textBlock = """
9
+ 4, 2, 2
10
+ 7, 6, 10.5
11
+ 25, 25, 156.25
12
+ """ )
13
+ void sample (int a , int b , double expected ) {
14
+ assertEquals (expected , Solution .arrowArea (a , b ), 1e-10 );
15
+ }
16
+ }
Original file line number Diff line number Diff line change 33
33
- [ Approaching enemies] ( approaching-enemies " 56d58a16e8f2d6957100093f ")
34
34
- [ Are the numbers in order?] ( are-the-numbers-in-order " 56b7f2f3f18876033f000307 ")
35
35
- [ Area of a Circle] ( area-of-a-circle " 537baa6f8f4b300b5900106c ")
36
+ - [ Area of an arrow] ( area-of-an-arrow " 589478160c0f8a40870000bc ")
36
37
- [ Arithmetic progression] ( arithmetic-progression " 55caf1fd8063ddfa8e000018 ")
37
38
- [ Arithmetic Sequence!] ( arithmetic-sequence " 540f8a19a7d43d24ac001018 ")
38
39
- [ Array element parity] ( array-element-parity " 5a092d9e46d843b9db000064 ")
You can’t perform that action at this time.
0 commit comments