Skip to content

Commit

Permalink
feat(7-kyu): kata/find-min-and-max (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParanoidUser committed Jul 31, 2023
1 parent d93f0df commit 2a1d391
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Codewars Handbook ☕️🚀

[![Views statistics +1 👀](https://img.shields.io/badge/dynamic/xml?color=success&label=views&query=//*[name()=%27text%27][3]&url=https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FParanoidUser%2Fcodewars-handbook)](https://hits.seeyoufarm.com/api/count/graph/dailyhits.svg?url=https://github.com/ParanoidUser/codewars-handbook)
[![Solved kata 👌](https://img.shields.io/badge/solved%20kata-1347-red.svg)](https://www.codewars.com/kata/search/java)
[![Solved kata 👌](https://img.shields.io/badge/solved%20kata-1348-red.svg)](https://www.codewars.com/kata/search/java)
[![CI pipeline 🛠](https://img.shields.io/github/actions/workflow/status/ParanoidUser/codewars-handbook/build.yml?branch=main)](https://github.com/ParanoidUser/codewars-handbook/actions/workflows/build.yml)
[![Quality gate 🔎](https://img.shields.io/sonar/alert_status/codewars-handbook?server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/dashboard?id=codewars-handbook)
[![Let's have a chat! 📞](https://img.shields.io/gitter/room/ParanoidUser/codewars-handbook?color=49c39e)](https://gitter.im/ParanoidUser/codewars-handbook)
Expand All @@ -25,7 +25,7 @@ slug.

| [1 kyu](/kata/1-kyu/index.md) | [2 kyu](/kata/2-kyu/index.md) | [3 kyu](/kata/3-kyu/index.md) | [4 kyu](/kata/4-kyu/index.md) | [5 kyu](/kata/5-kyu/index.md) | [6 kyu](/kata/6-kyu/index.md) | [7 kyu](/kata/7-kyu/index.md) | [8 kyu](/kata/8-kyu/index.md) | [beta](/kata/beta/index.md) | [retired](/kata/retired/index.md) |
|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:---------------------------:|:---------------------------------:|
| - | 1 | 2 | 18 | 36 | 410 | 547 | 200 | 57 | 76 |
| - | 1 | 2 | 18 | 36 | 410 | 548 | 200 | 57 | 76 |

**Note:** The source code is written in Java 17 and may use language features that are incompatible
with Java 8, 11.
Expand Down
3 changes: 3 additions & 0 deletions kata/7-kyu/find-min-and-max/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# [Find min and max](https://www.codewars.com/kata/find-min-and-max "https://www.codewars.com/kata/57a1ae8c7cb1f31e4e000130")

Implement a function that returns the minimal and the maximal value of a list (in this order).
8 changes: 8 additions & 0 deletions kata/7-kyu/find-min-and-max/main/MinMax.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import java.util.List;

interface MinMax {
static int[] getMinMax(List<Integer> list) {
var stats = list.stream().mapToInt(i -> i).summaryStatistics();
return new int[]{stats.getMin(), stats.getMax()};
}
}
14 changes: 14 additions & 0 deletions kata/7-kyu/find-min-and-max/test/SolutionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import org.junit.jupiter.api.Test;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;

class SolutionTest {
@Test
void sample() {
assertArrayEquals(new int[]{1, 1}, MinMax.getMinMax(List.of(1)));
assertArrayEquals(new int[]{1, 2}, MinMax.getMinMax(List.of(1, 2)));
assertArrayEquals(new int[]{1, 2}, MinMax.getMinMax(List.of(2, 1)));
}
}
1 change: 1 addition & 0 deletions kata/7-kyu/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
- [Find Count of Most Frequent Item in an Array](find-count-of-most-frequent-item-in-an-array)
- [Find Fibonacci last digit](find-fibonacci-last-digit)
- [Find Max Tree Node](find-max-tree-node)
- [Find min and max](find-min-and-max)
- [Find Screen Size](find-screen-size)
- [Find sum of top-left to bottom-right diagonals](find-sum-of-top-left-to-bottom-right-diagonals)
- [Find the index of the second occurrence of a letter in a string](find-the-index-of-the-second-occurrence-of-a-letter-in-a-string)
Expand Down

0 comments on commit 2a1d391

Please sign in to comment.