Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8972221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:09:56+00:00 2026-06-15T18:09:56+00:00

Say I have a list like so: board = [[0, 0, 0, 0, 0,],

  • 0

Say I have a list like so:

board = 
[[0, 0, 0, 0, 0,], 
[0, 0, 0, 0, 0,], 
[0, 0, 0, 0, 0,], 
[0, 0, 0, 0, 0,], 
[0, 0, 0, 0, 0,]

that represents spaces on a 2D board.
If player one goes, it will change to 1.
If player two goes, it will change to 2.

Win conditions are: if a row or column is completely filled, or diagonally.

Here are my functions for horizontal or vertical winners:

def horizontal_winner(board, boxes):
    '''
    function will find if the horizontal win conditions apply
    given 2 inputs. the board, a list and the number of boxes
    - board - the 2D board of the game
    - boxes - number of boxes per side
    ''' 
    for i in range(boxes):
        player_1 = 0
        player_2 = 0
        for j in range(boxes):
            if board[i][j] == 1:# first iteration - [1, 0, 0, 0, 0]
                player_1 += 1
                print("p1: " + str(player_1))
            elif board[i][j] == 2:# first iteration - [2, 0, 0, 0, 0]
                player_2 += 1
                print("p2: " + str(player_2))
        if player_1 == boxes:
            return True
        elif player_2 == boxes:
            return False


def vertical_winner(board, boxes):
    '''
    function will find if the vertical win conditions apply
    given 2 inputs. the board, a list and the number of boxes per side
    - board - the 2D board of the game
    - boxes - number of boxes per side
    '''
    for i in range(boxes):
        player_1 = 0
        player_2 = 0 
        for j in range(boxes):
            if board[j][i] == 1:# first iteration - [1, 0, 0, 0, 0]
                player_1 += 1
            elif board[j][i] == 2:# first iteration - [2, 0, 0, 0, 0]
                player_2 += 1
        if player_1 == boxes:
            return True
        elif player_2 == boxes:
            return False

How would I check diagonally?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:09:57+00:00Added an answer on June 15, 2026 at 6:09 pm

    First of all, recognize that there are only 2 diagonals. And the coordinates of each box on them is either (i, i) or (boxes-i-1, i) for some i in range(boxes). That should help you figure it out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

lets say I have a list like so: ['one','two','three','four','five','six','seven','eight','nine'] and I want to experiment
Say I have a list containing strings that look like this: 00x000s00g00wfds0d dkdf00sdf00sdfg00jk kf00dfjkd0sdl0sd0f0
Let's say I have a list of domain names that I would like to
Say I have a list that looks like this: ['item1', 'item2', 'item3', 'item4', 'item5',
Let's say I have list elements (more than one) like these: <li id=menu-item-51604><span class=dish-name>葡萄柚清心優多</span><span
Let's say I have a list that looks something like this: List(0,5,34,0,9,0,0,0) What I'd
Let's say I have a list that looks like this: <ul> <li id=q></li> <li
Let's say I have a list of IPs that looks like this: 10.2.3.4 10.5.3.2
Say I have a function that returns a quoted list like so: (defun create-structure
Say I have a List like: List<String> list = new ArrayList<>(); list.add(a); list.add(h); list.add(f);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.