[PR #878] [CLOSED] change: checkwin() function for games/tic_tac_toe.c #1394

Open
opened 2026-01-29 15:20:06 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/TheAlgorithms/C/pull/878
Author: @s7effeno
Created: 10/10/2021
Status: Closed

Base: masterHead: change-tictactoe-checkwin-function


📝 Commits (1)

  • a64412f change: 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

  • Added description of change
  • Added file name matches
  • Added tests and example, test must pass
  • PR title follows semantic
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

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.

## 📋 Pull Request Information **Original PR:** https://github.com/TheAlgorithms/C/pull/878 **Author:** [@s7effeno](https://github.com/s7effeno) **Created:** 10/10/2021 **Status:** ❌ Closed **Base:** `master` ← **Head:** `change-tictactoe-checkwin-function` --- ### 📝 Commits (1) - [`a64412f`](https://github.com/TheAlgorithms/C/commit/a64412f3e857bbdbcb729e27719e22849b2608c8) change: checkwin() function for games/tic_tac_toe.c ### 📊 Changes **1 file changed** (+160 additions, -132 deletions) <details> <summary>View changed files</summary> 📝 `games/tic_tac_toe.c` (+160 -132) </details> ### 📄 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 - [X] Added description of change - [X] Added file name matches - [X] Added tests and example, test must pass - [X] PR title follows semantic - [X] Search previous suggestions before making a new one, as yours may be a duplicate. - [X] I acknowledge that all my contributions will be made under the project's license. 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. <a href="https://gitpod.io/#https://github.com/TheAlgorithms/C/pull/878"><img src="https://gitpod.io/button/open-in-gitpod.svg"/></a> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 15:20:06 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/C#1394