-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(7-kyu): kata/two-numbers-are-positive
- Loading branch information
1 parent
9a35d01
commit 369078e
Showing
5 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# [Two numbers are positive](https://www.codewars.com/kata/two-numbers-are-positive "https://www.codewars.com/kata/602db3215c22df000e8544f0") | ||
|
||
## Task: | ||
|
||
Your job is to write a function, which takes three integers `a`, `b`, and `c` as arguments, and returns `True` if | ||
exactly two of the three integers are positive numbers (greater than zero), and `False` - otherwise. | ||
|
||
## Examples: | ||
|
||
``` | ||
twoArePositive(2, 4, -3) == true | ||
twoArePositive(-4, 6, 8) == true | ||
twoArePositive(4, -6, 9) == true | ||
twoArePositive(-4, 6, 0) == false | ||
twoArePositive(4, 6, 10) == false | ||
twoArePositive(-14, -3, -4) == false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
interface Kata { | ||
static boolean twoArePositive(int a, int b, int c) { | ||
return a > 0 ? b > 0 != c > 0 : b > 0 && c > 0; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
kata/7-kyu/two-numbers-are-positive/test/SolutionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class SolutionTest { | ||
@Test | ||
void sample() { | ||
assertTrue(Kata.twoArePositive(2, 4, -3)); | ||
assertTrue(Kata.twoArePositive(-4, 6, 8)); | ||
assertTrue(Kata.twoArePositive(4, -6, 9)); | ||
assertTrue(Kata.twoArePositive(4, 6, 0)); | ||
assertFalse(Kata.twoArePositive(-4, 6, 0)); | ||
assertFalse(Kata.twoArePositive(4, 6, 10)); | ||
assertFalse(Kata.twoArePositive(-14, -3, -4)); | ||
} | ||
} |