From f4f21470bebbee785bd8e86b517ba1c18979823a Mon Sep 17 00:00:00 2001 From: MathJAY10 Date: Fri, 31 Jul 2026 12:27:30 +0530 Subject: [PATCH 01/11] state-of-tic-tac-toe: add missing test cases for invalid board states --- .../src/reference/java/StateOfTicTacToe.java | 18 ++++++++++++++++- .../src/test/java/StateOfTicTacToeTest.java | 20 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java index 1fcee86d2..d8e500b57 100644 --- a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java +++ b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java @@ -51,6 +51,22 @@ public GameState determineState(String[] board) { } } + // --- NAYE CHECKS START --- + // Agar X jeeta hai, toh xCount zaroor (oCount + 1) hona chahiye. Agar barabar hai, matlab O ne extra move chala! + if (xWin > 0 && xCount != oCount + 1) { + throw new IllegalArgumentException( + "Impossible board: game should have ended after the game was won" + ); + } + + // Agar O jeeta hai, toh xCount zaroor oCount ke barabar hona chahiye. Agar xCount zyaada hai, matlab X ne extra move chala! + if (oWin > 0 && xCount != oCount) { + throw new IllegalArgumentException( + "Impossible board: game should have ended after the game was won" + ); + } + // --- NAYE CHECKS END --- + if (xWin > 0 || oWin > 0) { return GameState.WIN; } @@ -108,4 +124,4 @@ private int count(char mark, String[] board) { return result; } -} +} \ No newline at end of file diff --git a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java index d264db005..823c0636a 100644 --- a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java +++ b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java @@ -282,4 +282,24 @@ public void testInvalidBoardPlayersKeptPlayingAfterAWin() { .isThrownBy(() -> stateOfTicTacToe.determineState(new String[]{"XXX", "OOO", "XOX"})) .withMessage("Impossible board: game should have ended after the game was won"); } + + @Disabled("Remove to run test") + @Test + @DisplayName("Invalid board: O kept playing after X wins") + public void testInvalidBoardOKeptPlayingAfterXWins() { + + assertThatExceptionOfType(IllegalArgumentException.class) + .isThrownBy(() -> stateOfTicTacToe.determineState(new String[]{"XXX", "OO ", "O "})) + .withMessage("Impossible board: game should have ended after the game was won"); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Invalid board: X kept playing after O wins") + public void testInvalidBoardXKeptPlayingAfterOWins() { + + assertThatExceptionOfType(IllegalArgumentException.class) + .isThrownBy(() -> stateOfTicTacToe.determineState(new String[]{"OOO", "XX ", "XX "})) + .withMessage("Impossible board: game should have ended after the game was won"); + } } From c5707fe258a20380960a4e2e59133740556ff0bb Mon Sep 17 00:00:00 2001 From: MathJAY10 Date: Fri, 31 Jul 2026 18:46:38 +0530 Subject: [PATCH 02/11] fix: align test cases with canonical data and clean up comments --- .../.meta/src/reference/java/StateOfTicTacToe.java | 7 ++----- .../practice/state-of-tic-tac-toe/.meta/tests.toml | 2 +- .../src/test/java/StateOfTicTacToeTest.java | 10 +++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java index d8e500b57..9c0449142 100644 --- a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java +++ b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java @@ -51,21 +51,19 @@ public GameState determineState(String[] board) { } } - // --- NAYE CHECKS START --- - // Agar X jeeta hai, toh xCount zaroor (oCount + 1) hona chahiye. Agar barabar hai, matlab O ne extra move chala! + // If X wins, X must have played exactly one more move than O. if (xWin > 0 && xCount != oCount + 1) { throw new IllegalArgumentException( "Impossible board: game should have ended after the game was won" ); } - // Agar O jeeta hai, toh xCount zaroor oCount ke barabar hona chahiye. Agar xCount zyaada hai, matlab X ne extra move chala! + // If O wins, X and O must have played an equal number of moves. if (oWin > 0 && xCount != oCount) { throw new IllegalArgumentException( "Impossible board: game should have ended after the game was won" ); } - // --- NAYE CHECKS END --- if (xWin > 0 || oWin > 0) { return GameState.WIN; @@ -98,7 +96,6 @@ private List getDiagonals(String[] board) { String[] diags = new String[2]; for (int i = 0; i < 3; i++) { - if (diags[0] == null) { diags[0] = String.valueOf(board[i].charAt(i)); } else { diff --git a/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml b/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml index 8fc25e211..2b5c67c73 100644 --- a/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml +++ b/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml @@ -98,4 +98,4 @@ description = "Invalid boards -> Invalid board: X won and O kept playing" reimplements = "b1dc8b13-46c4-47db-a96d-aa90eedc4e8d" [4801cda2-f5b7-4c36-8317-3cdd167ac22c] -description = "Invalid boards -> Invalid board: players kept playing after a win" +description = "Invalid boards -> Invalid board: players kept playing after a win" \ No newline at end of file diff --git a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java index 823c0636a..6a60694e8 100644 --- a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java +++ b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java @@ -95,7 +95,7 @@ public void testFinishedGameWhereXWonViaMiddleRowVictory() { @Disabled("Remove to run test") @Test - @DisplayName("Finished game where X won via middle row victory") + @DisplayName("Finished game where X won via bottom row victory") public void testFinishedGameWhereXWonViaBottomRowVictory() { assertThat( @@ -207,7 +207,7 @@ public void testDraw() { @Test @DisplayName("Another draw") public void testAnotherDraw() { - + assertThat( stateOfTicTacToe.determineState(new String[]{"XXO", "OXX", "XOO"}) ).isEqualTo(GameState.DRAW); @@ -289,7 +289,7 @@ public void testInvalidBoardPlayersKeptPlayingAfterAWin() { public void testInvalidBoardOKeptPlayingAfterXWins() { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> stateOfTicTacToe.determineState(new String[]{"XXX", "OO ", "O "})) + .isThrownBy(() -> stateOfTicTacToe.determineState(new String[]{"OO ", "XXX", " O "})) .withMessage("Impossible board: game should have ended after the game was won"); } @@ -299,7 +299,7 @@ public void testInvalidBoardOKeptPlayingAfterXWins() { public void testInvalidBoardXKeptPlayingAfterOWins() { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> stateOfTicTacToe.determineState(new String[]{"OOO", "XX ", "XX "})) + .isThrownBy(() -> stateOfTicTacToe.determineState(new String[]{"XX ", "OOO", " XX"})) .withMessage("Impossible board: game should have ended after the game was won"); } -} +} \ No newline at end of file From 2f40668b3ca3b96fe7517fc2154bfb5e5c5b0c5b Mon Sep 17 00:00:00 2001 From: MathJAY10 Date: Sat, 1 Aug 2026 07:50:16 +0530 Subject: [PATCH 03/11] chore: sync tests.toml using configlet --- exercises/practice/state-of-tic-tac-toe/.meta/tests.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml b/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml index 2b5c67c73..5f574b2a1 100644 --- a/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml +++ b/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml @@ -98,4 +98,10 @@ description = "Invalid boards -> Invalid board: X won and O kept playing" reimplements = "b1dc8b13-46c4-47db-a96d-aa90eedc4e8d" [4801cda2-f5b7-4c36-8317-3cdd167ac22c] -description = "Invalid boards -> Invalid board: players kept playing after a win" \ No newline at end of file +description = "Invalid boards -> Invalid board: players kept playing after a win" + +[5a84757a-fc86-4328-aec9-a5759e6ed35d] +description = "Invalid boards -> Invalid board: O kept playing after X wins" + +[cf25543d-583a-4656-b9ab-f82dc00a4a02] +description = "Invalid boards -> Invalid board: X kept playing after O wins" From 3d7ca7632a89e876ab16fed0c2018b0420c3e438 Mon Sep 17 00:00:00 2001 From: MathJAY10 Date: Sun, 2 Aug 2026 13:14:28 +0530 Subject: [PATCH 04/11] fix: enable all tests and add trailing newline --- .../src/test/java/StateOfTicTacToeTest.java | 31 ++----------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java index 6a60694e8..419ff71b3 100644 --- a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java +++ b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java @@ -1,5 +1,6 @@ +package exercises.practice.state_of_tic_tac_toe; // Apne project ke according package line rehne dena agar lagi ho + import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -23,7 +24,6 @@ public void testFinishedGameWhereXWonViaLeftColumnVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via middle column victory") public void testFinishedGameWhereXWonViaMiddleColumnVictory() { @@ -33,7 +33,6 @@ public void testFinishedGameWhereXWonViaMiddleColumnVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via right column victory") public void testFinishedGameWhereXWonViaRightColumnVictory() { @@ -43,7 +42,6 @@ public void testFinishedGameWhereXWonViaRightColumnVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via left column victory") public void testFinishedGameWhereOWonViaLeftColumnVictory() { @@ -53,7 +51,6 @@ public void testFinishedGameWhereOWonViaLeftColumnVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via middle column victory") public void testFinishedGameWhereOWonViaMiddleColumnVictory() { @@ -63,7 +60,6 @@ public void testFinishedGameWhereOWonViaMiddleColumnVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via right column victory") public void testFinishedGameWhereOWonViaRightColumnVictory() { @@ -73,7 +69,6 @@ public void testFinishedGameWhereOWonViaRightColumnVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via top row victory") public void testFinishedGameWhereXWonViaTopRowVictory() { @@ -83,7 +78,6 @@ public void testFinishedGameWhereXWonViaTopRowVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via middle row victory") public void testFinishedGameWhereXWonViaMiddleRowVictory() { @@ -93,7 +87,6 @@ public void testFinishedGameWhereXWonViaMiddleRowVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via bottom row victory") public void testFinishedGameWhereXWonViaBottomRowVictory() { @@ -103,7 +96,6 @@ public void testFinishedGameWhereXWonViaBottomRowVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via top row victory") public void testFinishedGameWhereOWonViaTopRowVictory() { @@ -113,7 +105,6 @@ public void testFinishedGameWhereOWonViaTopRowVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via middle row victory") public void testFinishedGameWhereOWonViaMiddleRowVictory() { @@ -123,7 +114,6 @@ public void testFinishedGameWhereOWonViaMiddleRowVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via bottom row victory") public void testFinishedGameWhereOWonViaBottomRowVictory() { @@ -133,7 +123,6 @@ public void testFinishedGameWhereOWonViaBottomRowVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via falling diagonal victory") public void testFinishedGameWhereXWonViaFallingDiagonalVictory() { @@ -143,7 +132,6 @@ public void testFinishedGameWhereXWonViaFallingDiagonalVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via rising diagonal victory") public void testFinishedGameWhereXWonViaRisingDiagonalVictory() { @@ -153,7 +141,6 @@ public void testFinishedGameWhereXWonViaRisingDiagonalVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via falling diagonal victory") public void testFinishedGameWhereOWonViaFallingDiagonalVictory() { @@ -163,7 +150,6 @@ public void testFinishedGameWhereOWonViaFallingDiagonalVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via rising diagonal victory") public void testFinishedGameWhereOWonViaRisingDiagonalVictory() { @@ -173,7 +159,6 @@ public void testFinishedGameWhereOWonViaRisingDiagonalVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via a row and a column victory") public void testFinishedGameWhereXWonViaARowAndAColumnVictory() { @@ -183,7 +168,6 @@ public void testFinishedGameWhereXWonViaARowAndAColumnVictory() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via two diagonal victories") public void testFinishedGameWhereXWonViaTwoDiagonalVictories() { @@ -193,7 +177,6 @@ public void testFinishedGameWhereXWonViaTwoDiagonalVictories() { ).isEqualTo(GameState.WIN); } - @Disabled("Remove to run test") @Test @DisplayName("Drawn games") public void testDraw() { @@ -203,7 +186,6 @@ public void testDraw() { ).isEqualTo(GameState.DRAW); } - @Disabled("Remove to run test") @Test @DisplayName("Another draw") public void testAnotherDraw() { @@ -213,7 +195,6 @@ public void testAnotherDraw() { ).isEqualTo(GameState.DRAW); } - @Disabled("Remove to run test") @Test @DisplayName("Ongoing game: one move in") public void testOngoingGameOneMoveIn() { @@ -223,7 +204,6 @@ public void testOngoingGameOneMoveIn() { ).isEqualTo(GameState.ONGOING); } - @Disabled("Remove to run test") @Test @DisplayName("Ongoing game: two moves in") public void testOngoingGameTwoMovesIn() { @@ -233,7 +213,6 @@ public void testOngoingGameTwoMovesIn() { ).isEqualTo(GameState.ONGOING); } - @Disabled("Remove to run test") @Test @DisplayName("Ongoing game: five moves in") public void testOngoingGameFiveMovesIn() { @@ -243,7 +222,6 @@ public void testOngoingGameFiveMovesIn() { ).isEqualTo(GameState.ONGOING); } - @Disabled("Remove to run test") @Test @DisplayName("Invalid board: X went twice") public void testInvalidBoardXWentTwice() { @@ -253,7 +231,6 @@ public void testInvalidBoardXWentTwice() { .withMessage("Wrong turn order: X went twice"); } - @Disabled("Remove to run test") @Test @DisplayName("Invalid board: O started") public void testInvalidBoardOStarted() { @@ -263,7 +240,6 @@ public void testInvalidBoardOStarted() { .withMessage("Wrong turn order: O started"); } - @Disabled("Remove to run test") @Test @DisplayName("Invalid board") public void testInvalidBoard() { @@ -273,7 +249,6 @@ public void testInvalidBoard() { .withMessage("Impossible board: game should have ended after the game was won"); } - @Disabled("Remove to run test") @Test @DisplayName("Invalid board: players kept playing after a win") public void testInvalidBoardPlayersKeptPlayingAfterAWin() { @@ -283,7 +258,6 @@ public void testInvalidBoardPlayersKeptPlayingAfterAWin() { .withMessage("Impossible board: game should have ended after the game was won"); } - @Disabled("Remove to run test") @Test @DisplayName("Invalid board: O kept playing after X wins") public void testInvalidBoardOKeptPlayingAfterXWins() { @@ -293,7 +267,6 @@ public void testInvalidBoardOKeptPlayingAfterXWins() { .withMessage("Impossible board: game should have ended after the game was won"); } - @Disabled("Remove to run test") @Test @DisplayName("Invalid board: X kept playing after O wins") public void testInvalidBoardXKeptPlayingAfterOWins() { From 3191e64358a641d21da09d980f8e51591e8802ed Mon Sep 17 00:00:00 2001 From: MathJAY10 Date: Sun, 2 Aug 2026 13:25:28 +0530 Subject: [PATCH 05/11] fix: enable all tests and resolve checkstyle newline errors --- .../.meta/src/reference/java/StateOfTicTacToe.java | 3 ++- .../state-of-tic-tac-toe/src/main/java/StateOfTicTacToe.java | 1 + .../src/test/java/StateOfTicTacToeTest.java | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java index 9c0449142..8bf4fc6ce 100644 --- a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java +++ b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java @@ -121,4 +121,5 @@ private int count(char mark, String[] board) { return result; } -} \ No newline at end of file +} + diff --git a/exercises/practice/state-of-tic-tac-toe/src/main/java/StateOfTicTacToe.java b/exercises/practice/state-of-tic-tac-toe/src/main/java/StateOfTicTacToe.java index 7dee72960..5169ac3f5 100644 --- a/exercises/practice/state-of-tic-tac-toe/src/main/java/StateOfTicTacToe.java +++ b/exercises/practice/state-of-tic-tac-toe/src/main/java/StateOfTicTacToe.java @@ -3,3 +3,4 @@ public GameState determineState(String[] board) { throw new UnsupportedOperationException("Please implement the StateOfTicTacToe.determineState() method."); } } + diff --git a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java index 419ff71b3..326162757 100644 --- a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java +++ b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java @@ -275,4 +275,5 @@ public void testInvalidBoardXKeptPlayingAfterOWins() { .isThrownBy(() -> stateOfTicTacToe.determineState(new String[]{"XX ", "OOO", " XX"})) .withMessage("Impossible board: game should have ended after the game was won"); } -} \ No newline at end of file +} + From 0109b2fef87f358dd8a0f92fb2c250085519a1b5 Mon Sep 17 00:00:00 2001 From: MathJAY10 Date: Sun, 2 Aug 2026 16:17:08 +0530 Subject: [PATCH 06/11] remove comments --- .../.meta/src/reference/java/StateOfTicTacToe.java | 1 + .../src/test/java/StateOfTicTacToeTest.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java index 8bf4fc6ce..e3820f792 100644 --- a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java +++ b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java @@ -123,3 +123,4 @@ private int count(char mark, String[] board) { } } + diff --git a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java index 326162757..de8fd197b 100644 --- a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java +++ b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java @@ -1,4 +1,4 @@ -package exercises.practice.state_of_tic_tac_toe; // Apne project ke according package line rehne dena agar lagi ho +package exercises.practice.state_of_tic_tac_toe; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -277,3 +277,4 @@ public void testInvalidBoardXKeptPlayingAfterOWins() { } } + From a89e4289072e17f34f9073c4df8ff4d581400787 Mon Sep 17 00:00:00 2001 From: MathJAY10 Date: Sun, 2 Aug 2026 16:23:19 +0530 Subject: [PATCH 07/11] final commit for endlines --- .../.meta/src/reference/java/StateOfTicTacToe.java | 2 -- .../state-of-tic-tac-toe/src/main/java/StateOfTicTacToe.java | 1 - .../src/test/java/StateOfTicTacToeTest.java | 2 -- 3 files changed, 5 deletions(-) diff --git a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java index e3820f792..38f384315 100644 --- a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java +++ b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java @@ -122,5 +122,3 @@ private int count(char mark, String[] board) { return result; } } - - diff --git a/exercises/practice/state-of-tic-tac-toe/src/main/java/StateOfTicTacToe.java b/exercises/practice/state-of-tic-tac-toe/src/main/java/StateOfTicTacToe.java index 5169ac3f5..7dee72960 100644 --- a/exercises/practice/state-of-tic-tac-toe/src/main/java/StateOfTicTacToe.java +++ b/exercises/practice/state-of-tic-tac-toe/src/main/java/StateOfTicTacToe.java @@ -3,4 +3,3 @@ public GameState determineState(String[] board) { throw new UnsupportedOperationException("Please implement the StateOfTicTacToe.determineState() method."); } } - diff --git a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java index de8fd197b..895e1e0a4 100644 --- a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java +++ b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java @@ -276,5 +276,3 @@ public void testInvalidBoardXKeptPlayingAfterOWins() { .withMessage("Impossible board: game should have ended after the game was won"); } } - - From f61bd06bfd050b2e187c355b7a8e5997ae6f1a02 Mon Sep 17 00:00:00 2001 From: Jay Mathpal <147831494+MathJAY10@users.noreply.github.com> Date: Sun, 2 Aug 2026 18:16:15 +0530 Subject: [PATCH 08/11] Update exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java Co-authored-by: Jagdish Prajapati --- .../.meta/src/reference/java/StateOfTicTacToe.java | 1 - 1 file changed, 1 deletion(-) diff --git a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java index 38f384315..d42764555 100644 --- a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java +++ b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java @@ -58,7 +58,6 @@ public GameState determineState(String[] board) { ); } - // If O wins, X and O must have played an equal number of moves. if (oWin > 0 && xCount != oCount) { throw new IllegalArgumentException( "Impossible board: game should have ended after the game was won" From 0bf1a32d936cb3f29637dcf63412adae203168d0 Mon Sep 17 00:00:00 2001 From: Jay Mathpal <147831494+MathJAY10@users.noreply.github.com> Date: Sun, 2 Aug 2026 18:16:34 +0530 Subject: [PATCH 09/11] Update exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java Co-authored-by: Jagdish Prajapati --- .../.meta/src/reference/java/StateOfTicTacToe.java | 1 - 1 file changed, 1 deletion(-) diff --git a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java index d42764555..d3ed3ab82 100644 --- a/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java +++ b/exercises/practice/state-of-tic-tac-toe/.meta/src/reference/java/StateOfTicTacToe.java @@ -51,7 +51,6 @@ public GameState determineState(String[] board) { } } - // If X wins, X must have played exactly one more move than O. if (xWin > 0 && xCount != oCount + 1) { throw new IllegalArgumentException( "Impossible board: game should have ended after the game was won" From 400bfb8770ea4e9955fb578715b18183e5af846a Mon Sep 17 00:00:00 2001 From: Jay Mathpal <147831494+MathJAY10@users.noreply.github.com> Date: Sun, 2 Aug 2026 18:16:48 +0530 Subject: [PATCH 10/11] Update exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java Co-authored-by: Jagdish Prajapati --- .../src/test/java/StateOfTicTacToeTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java index 895e1e0a4..9c65c59b2 100644 --- a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java +++ b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java @@ -1,5 +1,3 @@ -package exercises.practice.state_of_tic_tac_toe; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; From 98756f02ae823b6718397e2aa0380ae0af8bda5d Mon Sep 17 00:00:00 2001 From: MathJAY10 Date: Sun, 2 Aug 2026 18:28:58 +0530 Subject: [PATCH 11/11] rectify code --- .../src/test/java/StateOfTicTacToeTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java index 9c65c59b2..5ae93502b 100644 --- a/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java +++ b/exercises/practice/state-of-tic-tac-toe/src/test/java/StateOfTicTacToeTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -22,6 +23,7 @@ public void testFinishedGameWhereXWonViaLeftColumnVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via middle column victory") public void testFinishedGameWhereXWonViaMiddleColumnVictory() { @@ -31,6 +33,7 @@ public void testFinishedGameWhereXWonViaMiddleColumnVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via right column victory") public void testFinishedGameWhereXWonViaRightColumnVictory() { @@ -40,6 +43,7 @@ public void testFinishedGameWhereXWonViaRightColumnVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via left column victory") public void testFinishedGameWhereOWonViaLeftColumnVictory() { @@ -49,6 +53,7 @@ public void testFinishedGameWhereOWonViaLeftColumnVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via middle column victory") public void testFinishedGameWhereOWonViaMiddleColumnVictory() { @@ -58,6 +63,7 @@ public void testFinishedGameWhereOWonViaMiddleColumnVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via right column victory") public void testFinishedGameWhereOWonViaRightColumnVictory() { @@ -67,6 +73,7 @@ public void testFinishedGameWhereOWonViaRightColumnVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via top row victory") public void testFinishedGameWhereXWonViaTopRowVictory() { @@ -76,6 +83,7 @@ public void testFinishedGameWhereXWonViaTopRowVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via middle row victory") public void testFinishedGameWhereXWonViaMiddleRowVictory() { @@ -85,6 +93,7 @@ public void testFinishedGameWhereXWonViaMiddleRowVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via bottom row victory") public void testFinishedGameWhereXWonViaBottomRowVictory() { @@ -94,6 +103,7 @@ public void testFinishedGameWhereXWonViaBottomRowVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via top row victory") public void testFinishedGameWhereOWonViaTopRowVictory() { @@ -103,6 +113,7 @@ public void testFinishedGameWhereOWonViaTopRowVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via middle row victory") public void testFinishedGameWhereOWonViaMiddleRowVictory() { @@ -112,6 +123,7 @@ public void testFinishedGameWhereOWonViaMiddleRowVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via bottom row victory") public void testFinishedGameWhereOWonViaBottomRowVictory() { @@ -121,6 +133,7 @@ public void testFinishedGameWhereOWonViaBottomRowVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via falling diagonal victory") public void testFinishedGameWhereXWonViaFallingDiagonalVictory() { @@ -130,6 +143,7 @@ public void testFinishedGameWhereXWonViaFallingDiagonalVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via rising diagonal victory") public void testFinishedGameWhereXWonViaRisingDiagonalVictory() { @@ -139,6 +153,7 @@ public void testFinishedGameWhereXWonViaRisingDiagonalVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via falling diagonal victory") public void testFinishedGameWhereOWonViaFallingDiagonalVictory() { @@ -148,6 +163,7 @@ public void testFinishedGameWhereOWonViaFallingDiagonalVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where O won via rising diagonal victory") public void testFinishedGameWhereOWonViaRisingDiagonalVictory() { @@ -157,6 +173,7 @@ public void testFinishedGameWhereOWonViaRisingDiagonalVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via a row and a column victory") public void testFinishedGameWhereXWonViaARowAndAColumnVictory() { @@ -166,6 +183,7 @@ public void testFinishedGameWhereXWonViaARowAndAColumnVictory() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Finished game where X won via two diagonal victories") public void testFinishedGameWhereXWonViaTwoDiagonalVictories() { @@ -175,6 +193,7 @@ public void testFinishedGameWhereXWonViaTwoDiagonalVictories() { ).isEqualTo(GameState.WIN); } + @Disabled("Remove to run test") @Test @DisplayName("Drawn games") public void testDraw() { @@ -184,6 +203,7 @@ public void testDraw() { ).isEqualTo(GameState.DRAW); } + @Disabled("Remove to run test") @Test @DisplayName("Another draw") public void testAnotherDraw() { @@ -193,6 +213,7 @@ public void testAnotherDraw() { ).isEqualTo(GameState.DRAW); } + @Disabled("Remove to run test") @Test @DisplayName("Ongoing game: one move in") public void testOngoingGameOneMoveIn() { @@ -202,6 +223,7 @@ public void testOngoingGameOneMoveIn() { ).isEqualTo(GameState.ONGOING); } + @Disabled("Remove to run test") @Test @DisplayName("Ongoing game: two moves in") public void testOngoingGameTwoMovesIn() { @@ -211,6 +233,7 @@ public void testOngoingGameTwoMovesIn() { ).isEqualTo(GameState.ONGOING); } + @Disabled("Remove to run test") @Test @DisplayName("Ongoing game: five moves in") public void testOngoingGameFiveMovesIn() { @@ -220,6 +243,7 @@ public void testOngoingGameFiveMovesIn() { ).isEqualTo(GameState.ONGOING); } + @Disabled("Remove to run test") @Test @DisplayName("Invalid board: X went twice") public void testInvalidBoardXWentTwice() { @@ -229,6 +253,7 @@ public void testInvalidBoardXWentTwice() { .withMessage("Wrong turn order: X went twice"); } + @Disabled("Remove to run test") @Test @DisplayName("Invalid board: O started") public void testInvalidBoardOStarted() { @@ -238,6 +263,7 @@ public void testInvalidBoardOStarted() { .withMessage("Wrong turn order: O started"); } + @Disabled("Remove to run test") @Test @DisplayName("Invalid board") public void testInvalidBoard() { @@ -247,6 +273,7 @@ public void testInvalidBoard() { .withMessage("Impossible board: game should have ended after the game was won"); } + @Disabled("Remove to run test") @Test @DisplayName("Invalid board: players kept playing after a win") public void testInvalidBoardPlayersKeptPlayingAfterAWin() { @@ -256,6 +283,7 @@ public void testInvalidBoardPlayersKeptPlayingAfterAWin() { .withMessage("Impossible board: game should have ended after the game was won"); } + @Disabled("Remove to run test") @Test @DisplayName("Invalid board: O kept playing after X wins") public void testInvalidBoardOKeptPlayingAfterXWins() { @@ -265,6 +293,7 @@ public void testInvalidBoardOKeptPlayingAfterXWins() { .withMessage("Impossible board: game should have ended after the game was won"); } + @Disabled("Remove to run test") @Test @DisplayName("Invalid board: X kept playing after O wins") public void testInvalidBoardXKeptPlayingAfterOWins() {