Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ParanoidUser committed Aug 7, 2024
1 parent b210e2f commit e0974c0
Show file tree
Hide file tree
Showing 6 changed files with 92 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)
[![Completed kata 👌](https://img.shields.io/badge/completed%20kata-68.6%25-red.svg)](https://www.codewars.com/kata/search/java?xids=completed)
[![Completed kata 👌](https://img.shields.io/badge/completed%20kata-68.5%25-red.svg)](https://www.codewars.com/kata/search/java?xids=completed)
[![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) |
|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:---------------------------:|:---------------------------------:|
| 0 | 1 | 2 | 26 | 48 | 426 | 577 | 210 | 56 | 79 |
| 0 | 1 | 2 | 26 | 48 | 427 | 577 | 210 | 56 | 79 |

**Note:** The source code is written in Java 17 and may use language features that are incompatible
with Java 8, 11.
Expand Down
26 changes: 26 additions & 0 deletions kata/6-kyu/if-you-can-read-this-dot-dot-dot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# [If you can read this...](https://www.codewars.com/kata/if-you-can-read-this-dot-dot-dot "https://www.codewars.com/kata/586538146b56991861000293")

[![The lyrics to \"Never gonna give you up\" by Rick Astley encoded in the NATO phonetic alphabet](https://9gag.com/photo/amrb4r9_700b.jpg)](http://9gag.com/gag/amrb4r9)

## Task

You'll have to translate a string to Pilot's
alphabet ([NATO phonetic alphabet](https://en.wikipedia.org/wiki/NATO_phonetic_alphabet)).

**Input:**

`If, you can read?`

**Output:**

`India Foxtrot , Yankee Oscar Uniform Charlie Alfa November Romeo Echo Alfa Delta ?`

**Note:**

- There is a preloaded dictionary that you can use, named `NATO`. It uses uppercase keys, e.g. `NATO['A']` is `"Alfa"`.
See comments in the initial code to see how to access it in your language.
- The set of used punctuation is `,.!?`.
- Punctuation should be kept in your return string, but spaces should not.
- __Xray__ should not have a dash within.
- Every word and punctuation mark should be seperated by a space ' '.
- There should be no trailing whitespace
36 changes: 36 additions & 0 deletions kata/6-kyu/if-you-can-read-this-dot-dot-dot/main/Helper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import static java.util.Map.entry;

import java.util.Map;

final class Helper {
static final Map<Character, String> NATO = Map.ofEntries(
entry('A', "Alfa"),
entry('B', "Bravo"),
entry('C', "Charlie"),
entry('D', "Delta"),
entry('E', "Echo"),
entry('F', "Foxtrot"),
entry('G', "Golf"),
entry('H', "Hotel"),
entry('I', "India"),
entry('J', "Juliett"),
entry('K', "Kilo"),
entry('L', "Lima"),
entry('M', "Mike"),
entry('N', "November"),
entry('O', "Oscar"),
entry('P', "Papa"),
entry('Q', "Quebec"),
entry('R', "Romeo"),
entry('S', "Sierra"),
entry('T', "Tango"),
entry('U', "Uniform"),
entry('V', "Victor"),
entry('W', "Whiskey"),
entry('X', "Xray"),
entry('Y', "Yankee"),
entry('Z', "Zulu")
);

private Helper() {}
}
8 changes: 8 additions & 0 deletions kata/6-kyu/if-you-can-read-this-dot-dot-dot/main/Kata.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import static java.util.stream.Collectors.joining;

interface Kata {
static String toNATO(String string) {
return string.replace(" ", "").toUpperCase().chars()
.mapToObj(c -> Helper.NATO.getOrDefault((char) c, (char) c + "")).collect(joining(" "));
}
}
19 changes: 19 additions & 0 deletions kata/6-kyu/if-you-can-read-this-dot-dot-dot/test/SolutionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

class SolutionTest {
@ParameterizedTest
@CsvSource(delimiter = '|', textBlock = """
If you can read | India Foxtrot Yankee Oscar Uniform Charlie Alfa November Romeo Echo Alfa Delta
Did not see that coming | Delta India Delta November Oscar Tango Sierra Echo Echo Tango Hotel Alfa Tango Charlie Oscar Mike India November Golf
go for it! | Golf Oscar Foxtrot Oscar Romeo India Tango !
the five boxing wizards jump quickly. | Tango Hotel Echo Foxtrot India Victor Echo Bravo Oscar Xray India November Golf Whiskey India Zulu Alfa Romeo Delta Sierra Juliett Uniform Mike Papa Quebec Uniform India Charlie Kilo Lima Yankee .
PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS? | Papa Alfa Charlie Kilo Mike Yankee Bravo Oscar Xray Whiskey India Tango Hotel Foxtrot India Victor Echo Delta Oscar Zulu Echo November Lima India Quebec Uniform Oscar Romeo Juliett Uniform Golf Sierra ?
p ? u . n c t u , a t i o n ! | Papa ? Uniform . November Charlie Tango Uniform , Alfa Tango India Oscar November !
""")
void sample(String input, String expected) {
assertEquals(expected, Kata.toNATO(input));
}
}
1 change: 1 addition & 0 deletions kata/6-kyu/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
- [HTML Complementary Color](html-complementary-color)
- [HTML dynamic color string generation](html-dynamic-color-string-generation)
# I
- [If you can read this...](if-you-can-read-this-dot-dot-dot)
- [Image host filename generator](image-host-filename-generator)
- [Integer depth](integer-depth)
- [Integers: Recreation Two](integers-recreation-two)
Expand Down

0 comments on commit e0974c0

Please sign in to comment.