From fdac2e8c79693b99cc31be280110a1f36a4a6dba Mon Sep 17 00:00:00 2001 From: Atharv Patil Date: Tue, 26 Aug 2025 16:26:25 +0530 Subject: [PATCH 1/2] alphametics, anagram, armstrong-numbers, atbash-cipher --- .../src/test/java/AlphameticsTest.java | 11 +++++++++++ .../anagram/src/test/java/AnagramTest.java | 19 +++++++++++++++++++ .../src/test/java/ArmstrongNumbersTest.java | 10 ++++++++++ .../src/test/java/AtbashTest.java | 15 +++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/exercises/practice/alphametics/src/test/java/AlphameticsTest.java b/exercises/practice/alphametics/src/test/java/AlphameticsTest.java index 93aef51be..c83aa0158 100644 --- a/exercises/practice/alphametics/src/test/java/AlphameticsTest.java +++ b/exercises/practice/alphametics/src/test/java/AlphameticsTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static java.util.Map.entry; @@ -8,6 +9,7 @@ public class AlphameticsTest { @Test + @DisplayName("puzzle with three letters") public void testThreeLetters() throws UnsolvablePuzzleException { assertThat(new Alphametics("I + BB == ILL").solve()) .containsOnly( @@ -18,6 +20,7 @@ public void testThreeLetters() throws UnsolvablePuzzleException { @Disabled("Remove to run test") @Test + @DisplayName("solution must have unique value for each letter") public void testUniqueValue() { Alphametics alphametics = new Alphametics("A == B"); @@ -27,6 +30,7 @@ public void testUniqueValue() { @Disabled("Remove to run test") @Test + @DisplayName("leading zero solution is invalid") public void testLeadingZero() { Alphametics alphametics = new Alphametics("ACA + DD == BD"); @@ -36,6 +40,7 @@ public void testLeadingZero() { @Disabled("Remove to run test") @Test + @DisplayName("puzzle with two digits final carry") public void testTwoDigitsFinalCarry() throws UnsolvablePuzzleException { assertThat(new Alphametics("A + A + A + A + A + A + A + A + A + A + A + B == BCC").solve()) .containsOnly( @@ -46,6 +51,7 @@ public void testTwoDigitsFinalCarry() throws UnsolvablePuzzleException { @Disabled("Remove to run test") @Test + @DisplayName("puzzle with four letters") public void testFourLetters() throws UnsolvablePuzzleException { assertThat(new Alphametics("AS + A == MOM").solve()) .containsOnly( @@ -57,6 +63,7 @@ public void testFourLetters() throws UnsolvablePuzzleException { @Disabled("Remove to run test") @Test + @DisplayName("puzzle with six letters") public void testSixLetters() throws UnsolvablePuzzleException { assertThat(new Alphametics("NO + NO + TOO == LATE").solve()) .containsOnly( @@ -70,6 +77,7 @@ public void testSixLetters() throws UnsolvablePuzzleException { @Disabled("Remove to run test") @Test + @DisplayName("puzzle with seven letters") public void testSevenLetters() throws UnsolvablePuzzleException { assertThat(new Alphametics("HE + SEES + THE == LIGHT").solve()) .containsOnly( @@ -84,6 +92,7 @@ public void testSevenLetters() throws UnsolvablePuzzleException { @Disabled("Remove to run test") @Test + @DisplayName("puzzle with eight letters") public void testEightLetters() throws UnsolvablePuzzleException { assertThat(new Alphametics("SEND + MORE == MONEY").solve()) .containsOnly( @@ -99,6 +108,7 @@ public void testEightLetters() throws UnsolvablePuzzleException { @Disabled("Remove to run test") @Test + @DisplayName("puzzle with ten letters") public void testTenLetters() throws UnsolvablePuzzleException { assertThat(new Alphametics("AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE").solve()) .containsOnly( @@ -116,6 +126,7 @@ public void testTenLetters() throws UnsolvablePuzzleException { @Disabled("Remove to run test") @Test + @DisplayName("puzzle with ten letters and 199 addends") public void testTenLetters41Addends() throws UnsolvablePuzzleException { assertThat(new Alphametics("THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + " + "TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + " + diff --git a/exercises/practice/anagram/src/test/java/AnagramTest.java b/exercises/practice/anagram/src/test/java/AnagramTest.java index e5434291a..79a3a261b 100644 --- a/exercises/practice/anagram/src/test/java/AnagramTest.java +++ b/exercises/practice/anagram/src/test/java/AnagramTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -9,6 +10,7 @@ public class AnagramTest { @Test + @DisplayName("no matches") public void testNoMatches() { Anagram detector = new Anagram("diaper"); @@ -20,6 +22,7 @@ public void testNoMatches() { @Disabled("Remove to run test") @Test + @DisplayName("detects two anagrams") public void testDetectsTwoAnagrams() { Anagram detector = new Anagram("solemn"); @@ -29,6 +32,7 @@ public void testDetectsTwoAnagrams() { @Disabled("Remove to run test") @Test + @DisplayName("does not detect anagram subsets") public void testEliminateAnagramSubsets() { Anagram detector = new Anagram("good"); @@ -37,6 +41,7 @@ public void testEliminateAnagramSubsets() { @Disabled("Remove to run test") @Test + @DisplayName("detects anagram") public void testDetectLongerAnagram() { Anagram detector = new Anagram("listen"); @@ -48,6 +53,7 @@ public void testDetectLongerAnagram() { @Disabled("Remove to run test") @Test + @DisplayName("detects three anagrams") public void testDetectMultipleAnagramsForLongerWord() { Anagram detector = new Anagram("allergy"); assertThat( @@ -64,6 +70,7 @@ public void testDetectMultipleAnagramsForLongerWord() { @Disabled("Remove to run test") @Test + @DisplayName("detects multiple anagrams with different case") public void testDetectsMultipleAnagramsWithDifferentCase() { Anagram detector = new Anagram("nose"); @@ -73,6 +80,7 @@ public void testDetectsMultipleAnagramsWithDifferentCase() { @Disabled("Remove to run test") @Test + @DisplayName("does not detect non-anagrams with identical checksum") public void testEliminateAnagramsWithSameChecksum() { Anagram detector = new Anagram("mass"); @@ -82,6 +90,7 @@ public void testEliminateAnagramsWithSameChecksum() { @Disabled("Remove to run test") @Test + @DisplayName("detects anagrams case-insensitively") public void testCaseInsensitiveWhenBothAnagramAndSubjectStartWithUpperCaseLetter() { Anagram detector = new Anagram("Orchestra"); @@ -93,6 +102,7 @@ public void testCaseInsensitiveWhenBothAnagramAndSubjectStartWithUpperCaseLetter @Disabled("Remove to run test") @Test + @DisplayName("detects anagrams using case-insensitive subject") public void testCaseInsensitiveWhenSubjectStartsWithUpperCaseLetter() { Anagram detector = new Anagram("Orchestra"); @@ -104,6 +114,7 @@ public void testCaseInsensitiveWhenSubjectStartsWithUpperCaseLetter() { @Disabled("Remove to run test") @Test + @DisplayName("detects anagrams using case-insensitive possible matches") public void testCaseInsensitiveWhenAnagramStartsWithUpperCaseLetter() { Anagram detector = new Anagram("orchestra"); @@ -115,6 +126,7 @@ public void testCaseInsensitiveWhenAnagramStartsWithUpperCaseLetter() { @Disabled("Remove to run test") @Test + @DisplayName("does not detect an anagram if the original word is repeated") public void testIdenticalWordRepeatedIsNotAnagram() { Anagram detector = new Anagram("go"); @@ -124,6 +136,7 @@ public void testIdenticalWordRepeatedIsNotAnagram() { @Disabled("Remove to run test") @Test + @DisplayName("anagrams must use all letters exactly once") public void testAnagramMustUseAllLettersExactlyOnce() { Anagram detector = new Anagram("tapper"); @@ -133,6 +146,7 @@ public void testAnagramMustUseAllLettersExactlyOnce() { @Disabled("Remove to run test") @Test + @DisplayName("words are not anagrams of themselves") public void testWordsAreNotAnagramsOfThemselvesCaseInsensitive() { Anagram detector = new Anagram("BANANA"); @@ -142,6 +156,7 @@ public void testWordsAreNotAnagramsOfThemselvesCaseInsensitive() { @Disabled("Remove to run test") @Test + @DisplayName("words are not anagrams of themselves even if letter case is partially different") public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDifferent() { Anagram detector = new Anagram("BANANA"); @@ -151,6 +166,7 @@ public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDiffer @Disabled("Remove to run test") @Test + @DisplayName("words are not anagrams of themselves even if letter case is completely different") public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyDifferent() { Anagram detector = new Anagram("BANANA"); @@ -160,6 +176,7 @@ public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyDiffe @Disabled("Remove to run test") @Test + @DisplayName("words other than themselves can be anagrams") public void testWordsOtherThanThemselvesCanBeAnagrams() { Anagram detector = new Anagram("LISTEN"); @@ -169,6 +186,7 @@ public void testWordsOtherThanThemselvesCanBeAnagrams() { @Disabled("Remove to run test") @Test + @DisplayName("handles case of greek letters") public void testHandlesCaseOfGreekLetters() { Anagram detector = new Anagram("ΑΒΓ"); @@ -178,6 +196,7 @@ public void testHandlesCaseOfGreekLetters() { @Disabled("Remove to run test") @Test + @DisplayName("different characters may have the same bytes") public void testDifferentCharactersWithSameBytes() { Anagram detector = new Anagram("a⬂"); diff --git a/exercises/practice/armstrong-numbers/src/test/java/ArmstrongNumbersTest.java b/exercises/practice/armstrong-numbers/src/test/java/ArmstrongNumbersTest.java index ea08d7259..ca890915d 100644 --- a/exercises/practice/armstrong-numbers/src/test/java/ArmstrongNumbersTest.java +++ b/exercises/practice/armstrong-numbers/src/test/java/ArmstrongNumbersTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -14,6 +15,7 @@ public void setup() { } @Test + @DisplayName("Zero is an Armstrong number") public void zeroIsArmstrongNumber() { assertThat(armstrongNumbers.isArmstrongNumber(0)) .isTrue(); @@ -21,6 +23,7 @@ public void zeroIsArmstrongNumber() { @Disabled("Remove to run test") @Test + @DisplayName("Single-digit numbers are Armstrong numbers") public void singleDigitsAreArmstrongNumbers() { assertThat(armstrongNumbers.isArmstrongNumber(5)) .isTrue(); @@ -28,6 +31,7 @@ public void singleDigitsAreArmstrongNumbers() { @Disabled("Remove to run test") @Test + @DisplayName("There are no two-digit Armstrong numbers") public void noTwoDigitArmstrongNumbers() { assertThat(armstrongNumbers.isArmstrongNumber(10)) .isFalse(); @@ -35,6 +39,7 @@ public void noTwoDigitArmstrongNumbers() { @Disabled("Remove to run test") @Test + @DisplayName("Three-digit number that is an Armstrong number") public void threeDigitNumberIsArmstrongNumber() { assertThat(armstrongNumbers.isArmstrongNumber(153)) .isTrue(); @@ -42,6 +47,7 @@ public void threeDigitNumberIsArmstrongNumber() { @Disabled("Remove to run test") @Test + @DisplayName("Three-digit number that is not an Armstrong number") public void threeDigitNumberIsNotArmstrongNumber() { assertThat(armstrongNumbers.isArmstrongNumber(100)) .isFalse(); @@ -49,6 +55,7 @@ public void threeDigitNumberIsNotArmstrongNumber() { @Disabled("Remove to run test") @Test + @DisplayName("Four-digit number that is an Armstrong number") public void fourDigitNumberIsArmstrongNumber() { assertThat(armstrongNumbers.isArmstrongNumber(9474)) .isTrue(); @@ -56,6 +63,7 @@ public void fourDigitNumberIsArmstrongNumber() { @Disabled("Remove to run test") @Test + @DisplayName("") public void fourDigitNumberIsNotArmstrongNumber() { assertThat(armstrongNumbers.isArmstrongNumber(9475)) .isFalse(); @@ -63,6 +71,7 @@ public void fourDigitNumberIsNotArmstrongNumber() { @Disabled("Remove to run test") @Test + @DisplayName("Four-digit number that is not an Armstrong number") public void sevenDigitNumberIsArmstrongNumber() { assertThat(armstrongNumbers.isArmstrongNumber(9926315)) .isTrue(); @@ -70,6 +79,7 @@ public void sevenDigitNumberIsArmstrongNumber() { @Disabled("Remove to run test") @Test + @DisplayName("Seven-digit number that is not an Armstrong number") public void sevenDigitNumberIsNotArmstrongNumber() { assertThat(armstrongNumbers.isArmstrongNumber(9926314)) .isFalse(); diff --git a/exercises/practice/atbash-cipher/src/test/java/AtbashTest.java b/exercises/practice/atbash-cipher/src/test/java/AtbashTest.java index f656a69dc..c914f8b28 100644 --- a/exercises/practice/atbash-cipher/src/test/java/AtbashTest.java +++ b/exercises/practice/atbash-cipher/src/test/java/AtbashTest.java @@ -1,5 +1,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -14,36 +15,42 @@ public void setup() { } @Test + @DisplayName("encode yes") public void testEncodeYes() { assertThat(atbash.encode("yes")).isEqualTo("bvh"); } @Disabled("Remove to run test") @Test + @DisplayName("encode no") public void testEncodeNo() { assertThat(atbash.encode("no")).isEqualTo("ml"); } @Disabled("Remove to run test") @Test + @DisplayName("encode OMG") public void testEncodeOmgInCapital() { assertThat(atbash.encode("OMG")).isEqualTo("lnt"); } @Disabled("Remove to run test") @Test + @DisplayName("encode spaces") public void testEncodeOmgWithSpaces() { assertThat(atbash.encode("O M G")).isEqualTo("lnt"); } @Disabled("Remove to run test") @Test + @DisplayName("encode mindblowingly") public void testEncodeMindBlowingly() { assertThat(atbash.encode("mindblowingly")).isEqualTo("nrmwy oldrm tob"); } @Disabled("Remove to run test") @Test + @DisplayName("encode numbers") public void testEncodeNumbers() { assertThat(atbash.encode("Testing,1 2 3, testing.")) .isEqualTo("gvhgr mt123 gvhgr mt"); @@ -51,6 +58,7 @@ public void testEncodeNumbers() { @Disabled("Remove to run test") @Test + @DisplayName("encode deep thought") public void testEncodeDeepThought() { assertThat(atbash.encode("Truth is fiction.")) .isEqualTo("gifgs rhurx grlm"); @@ -58,6 +66,7 @@ public void testEncodeDeepThought() { @Disabled("Remove to run test") @Test + @DisplayName("encode all the letters") public void testEncodeAllTheLetters() { assertThat(atbash.encode("The quick brown fox jumps over the lazy dog.")) .isEqualTo("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"); @@ -65,12 +74,14 @@ public void testEncodeAllTheLetters() { @Disabled("Remove to run test") @Test + @DisplayName("decode exercism") public void testDecodeExercism() { assertThat(atbash.decode("vcvix rhn")).isEqualTo("exercism"); } @Disabled("Remove to run test") @Test + @DisplayName("decode a sentence") public void testDecodeASentence() { assertThat(atbash.decode("zmlyh gzxov rhlug vmzhg vkkrm thglm v")) .isEqualTo("anobstacleisoftenasteppingstone"); @@ -78,6 +89,7 @@ public void testDecodeASentence() { @Disabled("Remove to run test") @Test + @DisplayName("decode numbers") public void testDecodeNumbers() { assertThat(atbash.decode("gvhgr mt123 gvhgr mt")) .isEqualTo("testing123testing"); @@ -85,6 +97,7 @@ public void testDecodeNumbers() { @Disabled("Remove to run test") @Test + @DisplayName("decode all the letters") public void testDecodeAllTheLetters() { assertThat(atbash.decode("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt")) .isEqualTo("thequickbrownfoxjumpsoverthelazydog"); @@ -92,12 +105,14 @@ public void testDecodeAllTheLetters() { @Disabled("Remove to run test") @Test + @DisplayName("decode with too many spaces") public void testDecodeWithTooManySpaces() { assertThat(atbash.decode("vc vix r hn")).isEqualTo("exercism"); } @Disabled("Remove to run test") @Test + @DisplayName("decode with no spaces") public void testDecodeWithNoSpaces() { assertThat(atbash.decode("zmlyhgzxovrhlugvmzhgvkkrmthglmv")) .isEqualTo("anobstacleisoftenasteppingstone"); From 9a915e02ad5593c16ae5fa6d5eda4d47e421e7e1 Mon Sep 17 00:00:00 2001 From: Atharv Patil Date: Wed, 27 Aug 2025 14:15:58 +0530 Subject: [PATCH 2/2] alphametics, armstrong-numbers --- .../practice/alphametics/src/test/java/AlphameticsTest.java | 2 +- .../armstrong-numbers/src/test/java/ArmstrongNumbersTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/practice/alphametics/src/test/java/AlphameticsTest.java b/exercises/practice/alphametics/src/test/java/AlphameticsTest.java index c83aa0158..8661a8de3 100644 --- a/exercises/practice/alphametics/src/test/java/AlphameticsTest.java +++ b/exercises/practice/alphametics/src/test/java/AlphameticsTest.java @@ -127,7 +127,7 @@ public void testTenLetters() throws UnsolvablePuzzleException { @Disabled("Remove to run test") @Test @DisplayName("puzzle with ten letters and 199 addends") - public void testTenLetters41Addends() throws UnsolvablePuzzleException { + public void testTenLetters199Addends() throws UnsolvablePuzzleException { assertThat(new Alphametics("THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + " + "TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + " + "HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE + HORRORS + THE + LAST + FREE + " + diff --git a/exercises/practice/armstrong-numbers/src/test/java/ArmstrongNumbersTest.java b/exercises/practice/armstrong-numbers/src/test/java/ArmstrongNumbersTest.java index ca890915d..8977970dc 100644 --- a/exercises/practice/armstrong-numbers/src/test/java/ArmstrongNumbersTest.java +++ b/exercises/practice/armstrong-numbers/src/test/java/ArmstrongNumbersTest.java @@ -63,7 +63,7 @@ public void fourDigitNumberIsArmstrongNumber() { @Disabled("Remove to run test") @Test - @DisplayName("") + @DisplayName("Four-digit number that is not an Armstrong number") public void fourDigitNumberIsNotArmstrongNumber() { assertThat(armstrongNumbers.isArmstrongNumber(9475)) .isFalse(); @@ -71,7 +71,7 @@ public void fourDigitNumberIsNotArmstrongNumber() { @Disabled("Remove to run test") @Test - @DisplayName("Four-digit number that is not an Armstrong number") + @DisplayName("Seven-digit number that is an Armstrong number") public void sevenDigitNumberIsArmstrongNumber() { assertThat(armstrongNumbers.isArmstrongNumber(9926315)) .isTrue();