mirror of
https://github.com/TheAlgorithms/C.git
synced 2026-02-04 05:44:35 +00:00
[PR #878] [CLOSED] change: checkwin() function for games/tic_tac_toe.c #1394
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/TheAlgorithms/C/pull/878
Author: @s7effeno
Created: 10/10/2021
Status: ❌ Closed
Base:
master← Head:change-tictactoe-checkwin-function📝 Commits (1)
a64412fchange: checkwin() function for games/tic_tac_toe.c📊 Changes
1 file changed (+160 additions, -132 deletions)
View changed files
📝
games/tic_tac_toe.c(+160 -132)📄 Description
Description of Change
Changed the checkwin() function to be less "hardcoded"
With this change, this function is divided in three sub-functions for rows, columns and diagonals.
The checks are no longer a long series of if-statements, they're implemented using loops
References
Checklist
Notes:
This new implementation uses for loops, two counters (one fore each player) and run-time offset calculation to access the grid array; for this reason it may possibly be slower than before but in my opinion a little more concise and elegant.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.