diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ecda2de10..de4283ca1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -207,6 +207,10 @@ Each problem/submodule has three source sets: - `.meta/src/reference/java/` — a reference solution that passes all the tests - `src/main/java/` — starter source file(s). +### Update/sync Gradle versions + +Please read [How to Update Gradle](../reference/how-to-update-gradle.md) + ## Contributing to Concept Exercises Please read [Implementing a Concept Exercise](reference/implementing-a-concept-exercise.md). diff --git a/config.json b/config.json index 0b281151c..1d3f88194 100644 --- a/config.json +++ b/config.json @@ -1791,6 +1791,17 @@ "lists" ], "difficulty": 10 + }, + { + "slug": "game-of-life", + "name": "Conway's Game of Life", + "uuid": "749de7fc-3dcb-4231-9b4f-115d153af74f", + "practices": [], + "prerequisites": [ + "arrays", + "if-statements" + ], + "difficulty": 5 } ], "foregone": [ diff --git a/exercises/gradle/wrapper/gradle-wrapper.jar b/exercises/gradle/wrapper/gradle-wrapper.jar index d64cd4917..e6441136f 100644 Binary files a/exercises/gradle/wrapper/gradle-wrapper.jar and b/exercises/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/game-of-life/.docs/instructions.md b/exercises/practice/game-of-life/.docs/instructions.md new file mode 100644 index 000000000..495314064 --- /dev/null +++ b/exercises/practice/game-of-life/.docs/instructions.md @@ -0,0 +1,11 @@ +# Instructions + +After each generation, the cells interact with their eight neighbors, which are cells adjacent horizontally, vertically, or diagonally. + +The following rules are applied to each cell: + +- Any live cell with two or three live neighbors lives on. +- Any dead cell with exactly three live neighbors becomes a live cell. +- All other cells die or stay dead. + +Given a matrix of 1s and 0s (corresponding to live and dead cells), apply the rules to each cell, and return the next generation. diff --git a/exercises/practice/game-of-life/.docs/introduction.md b/exercises/practice/game-of-life/.docs/introduction.md new file mode 100644 index 000000000..2347b936e --- /dev/null +++ b/exercises/practice/game-of-life/.docs/introduction.md @@ -0,0 +1,9 @@ +# Introduction + +[Conway's Game of Life][game-of-life] is a fascinating cellular automaton created by the British mathematician John Horton Conway in 1970. + +The game consists of a two-dimensional grid of cells that can either be "alive" or "dead." + +After each generation, the cells interact with their eight neighbors via a set of rules, which define the new generation. + +[game-of-life]: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life diff --git a/exercises/practice/game-of-life/.meta/config.json b/exercises/practice/game-of-life/.meta/config.json new file mode 100644 index 000000000..b8dbee6ad --- /dev/null +++ b/exercises/practice/game-of-life/.meta/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "akbatra567" + ], + "files": { + "solution": [ + "src/main/java/GameOfLife.java" + ], + "test": [ + "src/test/java/GameOfLifeTest.java" + ], + "example": [ + ".meta/src/reference/java/GameOfLife.java" + ], + "invalidator": [ + "build.gradle" + ] + }, + "blurb": "Implement Conway's Game of Life.", + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" +} diff --git a/exercises/practice/game-of-life/.meta/src/reference/java/GameOfLife.java b/exercises/practice/game-of-life/.meta/src/reference/java/GameOfLife.java new file mode 100644 index 000000000..a2f47e734 --- /dev/null +++ b/exercises/practice/game-of-life/.meta/src/reference/java/GameOfLife.java @@ -0,0 +1,37 @@ +class GameOfLife { + public int[][] tick(int[][] matrix) { + if (matrix.length == 0) { + return matrix; + } + int rowCount = matrix.length; + int columnCount = matrix[0].length; + int[][] resultMatrix = new int[rowCount][columnCount]; + + for (int row = 0; row < rowCount; row++) { + for (int column = 0; column < columnCount; column++) { + int liveNeighbors = countLiveNeighbors(matrix, row, column); + + if ((matrix[row][column] == 1 && (liveNeighbors == 2 || liveNeighbors == 3)) || + (matrix[row][column] == 0 && liveNeighbors == 3)) { + resultMatrix[row][column] = 1; + } + } + } + return resultMatrix; + } + + private int countLiveNeighbors(int[][] matrix, int row, int col) { + int rowCount = matrix.length; + int columnCount = matrix[0].length; + int count = 0; + + for (int i = Math.max(0, row - 1); i <= Math.min(row + 1, rowCount - 1); i++) { + for (int j = Math.max(0, col - 1); j <= Math.min(col + 1, columnCount - 1); j++) { + if (i != row || j != col) { + count += matrix[i][j]; + } + } + } + return count; + } +} diff --git a/exercises/practice/game-of-life/.meta/tests.toml b/exercises/practice/game-of-life/.meta/tests.toml new file mode 100644 index 000000000..398cd4546 --- /dev/null +++ b/exercises/practice/game-of-life/.meta/tests.toml @@ -0,0 +1,34 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[ae86ea7d-bd07-4357-90b3-ac7d256bd5c5] +description = "empty matrix" + +[4ea5ccb7-7b73-4281-954a-bed1b0f139a5] +description = "live cells with zero live neighbors die" + +[df245adc-14ff-4f9c-b2ae-f465ef5321b2] +description = "live cells with only one live neighbor die" + +[2a713b56-283c-48c8-adae-1d21306c80ae] +description = "live cells with two live neighbors stay alive" + +[86d5c5a5-ab7b-41a1-8907-c9b3fc5e9dae] +description = "live cells with three live neighbors stay alive" + +[015f60ac-39d8-4c6c-8328-57f334fc9f89] +description = "dead cells with three live neighbors become alive" + +[2ee69c00-9d41-4b8b-89da-5832e735ccf1] +description = "live cells with four or more neighbors die" + +[a79b42be-ed6c-4e27-9206-43da08697ef6] +description = "bigger matrix" diff --git a/exercises/practice/game-of-life/build.gradle b/exercises/practice/game-of-life/build.gradle new file mode 100644 index 000000000..1344305f7 --- /dev/null +++ b/exercises/practice/game-of-life/build.gradle @@ -0,0 +1,23 @@ +plugins { + id "java" +} + +repositories { + mavenCentral() +} + +dependencies { + testImplementation platform("org.junit:junit-bom:5.10.0") + testImplementation "org.junit.jupiter:junit-jupiter" + testImplementation "org.assertj:assertj-core:3.25.1" +} + +test { + useJUnitPlatform() + + testLogging { + exceptionFormat = "full" + showStandardStreams = true + events = ["passed", "failed", "skipped"] + } +} diff --git a/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.jar b/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..e6441136f Binary files /dev/null and b/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.jar differ diff --git a/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.properties b/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..2deab89d5 --- /dev/null +++ b/exercises/practice/game-of-life/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/exercises/practice/game-of-life/gradlew b/exercises/practice/game-of-life/gradlew new file mode 100755 index 000000000..1aa94a426 --- /dev/null +++ b/exercises/practice/game-of-life/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/exercises/practice/game-of-life/gradlew.bat b/exercises/practice/game-of-life/gradlew.bat new file mode 100644 index 000000000..93e3f59f1 --- /dev/null +++ b/exercises/practice/game-of-life/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/exercises/practice/game-of-life/src/main/java/GameOfLife.java b/exercises/practice/game-of-life/src/main/java/GameOfLife.java new file mode 100644 index 000000000..ee9c38d66 --- /dev/null +++ b/exercises/practice/game-of-life/src/main/java/GameOfLife.java @@ -0,0 +1,5 @@ +class GameOfLife { + public int[][] tick(int[][] matrix){ + throw new UnsupportedOperationException("Delete this statement and write your own implementation."); + } +} diff --git a/exercises/practice/game-of-life/src/test/java/GameOfLifeTest.java b/exercises/practice/game-of-life/src/test/java/GameOfLifeTest.java new file mode 100644 index 000000000..9fe627bfd --- /dev/null +++ b/exercises/practice/game-of-life/src/test/java/GameOfLifeTest.java @@ -0,0 +1,158 @@ +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.*; + +public class GameOfLifeTest { + @Test + @DisplayName("Empty Matrix") + public void testEmptyMatrix() { + int[][] matrix = new int[][]{}; + assertThat(new GameOfLife().tick(matrix)).isEmpty(); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Live cells with zero live neighbors die") + public void testLiveCellsWithZeroLiveNeighborsDie() { + int[][] matrix = { + {0, 0, 0}, + {0, 1, 0}, + {0, 0, 0} + }; + + int[][] expected = { + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0} + }; + + assertThat(new GameOfLife().tick(matrix)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Live cells with only one live neighbor die") + public void testLiveCellsWithOnlyOneLiveNeighborsDie() { + int[][] matrix = { + {0, 0, 0}, + {0, 1, 0}, + {0, 1, 0}}; + + int[][] expected = { + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0} + }; + + assertThat(new GameOfLife().tick(matrix)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Live cells with two live neighbors stay alive") + public void testLiveCellsWithTwoLiveNeighborsStayAlive() { + int[][] matrix = { + {1, 0, 1}, + {1, 0, 1}, + {1, 0, 1} + }; + + int[][] expected = { + {0, 0, 0}, + {1, 0, 1}, + {0, 0, 0} + }; + + assertThat(new GameOfLife().tick(matrix)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Live cells with three live neighbors stay alive") + public void testLiveCellsWithThreeLiveNeighborsStayAlive() { + int[][] matrix = { + {0, 1, 0}, + {1, 0, 0}, + {1, 1, 0} + }; + + int[][] expected = { + {0, 0, 0}, + {1, 0, 0}, + {1, 1, 0} + + }; + + assertThat(new GameOfLife().tick(matrix)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Dead cells with three live neighbors become alive") + public void testDeadCellsWithThreeLiveNeighborsBecomeAlive() { + int[][] matrix = { + {1, 1, 0}, + {0, 0, 0}, + {1, 0, 0} + }; + + int[][] expected = { + {0, 0, 0}, + {1, 1, 0}, + {0, 0, 0} + }; + + assertThat(new GameOfLife().tick(matrix)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Live cells with four or more neighbors die") + public void testLiveCellsWithFourOrMoreNeighborsDie() { + int[][] matrix = { + {1, 1, 1}, + {1, 1, 1}, + {1, 1, 1} + }; + + int[][] expected = { + {1, 0, 1}, + {0, 0, 0}, + {1, 0, 1} + }; + + assertThat(new GameOfLife().tick(matrix)).isEqualTo(expected); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("Bigger Matrix") + public void testBiggerMatrix () { + int[][] matrix = { + {1, 1, 0, 1, 1, 0, 0, 0}, + {1, 0, 1, 1, 0, 0, 0, 0}, + {1, 1, 1, 0, 0, 1, 1, 1}, + {0, 0, 0, 0, 0, 1, 1, 0}, + {1, 0, 0, 0, 1, 1, 0, 0}, + {1, 1, 0, 0, 0, 1, 1, 1}, + {0, 0, 1, 0, 1, 0, 0, 1}, + {1, 0, 0, 0, 0, 0, 1, 1} + }; + + int[][] expected = { + {1, 1, 0, 1, 1, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 1, 0}, + {1, 0, 1, 1, 1, 1, 0, 1}, + {1, 0, 0, 0, 0, 0, 0, 1}, + {1, 1, 0, 0, 1, 0, 0, 1}, + {1, 1, 0, 1, 0, 0, 0, 1}, + {1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1} + }; + + assertThat(new GameOfLife().tick(matrix)).isEqualTo(expected); + } + +} diff --git a/exercises/settings.gradle b/exercises/settings.gradle index 916d7dd7f..c991919dc 100644 --- a/exercises/settings.gradle +++ b/exercises/settings.gradle @@ -62,6 +62,7 @@ include 'practice:etl' include 'practice:flatten-array' include 'practice:food-chain' include 'practice:forth' +include 'practice:game-of-life' include 'practice:gigasecond' include 'practice:go-counting' include 'practice:grade-school' diff --git a/resources/exercise-template/gradle/wrapper/gradle-wrapper.jar b/resources/exercise-template/gradle/wrapper/gradle-wrapper.jar index 933486d82..e6441136f 100644 Binary files a/resources/exercise-template/gradle/wrapper/gradle-wrapper.jar and b/resources/exercise-template/gradle/wrapper/gradle-wrapper.jar differ diff --git a/resources/exercise-template/gradle/wrapper/gradle-wrapper.properties b/resources/exercise-template/gradle/wrapper/gradle-wrapper.properties index d3ca171f7..b82aa23a4 100644 --- a/resources/exercise-template/gradle/wrapper/gradle-wrapper.properties +++ b/resources/exercise-template/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists