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 3755036
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:38:12+00:00 2026-05-19T09:38:12+00:00

I Have a list with a and b and the b’s are somewhat of

  • 0

I Have a list with “a” and “b” and the “b”‘s are somewhat of a path and “a”‘s are walls. Im writing a program to make a graph of all the possible moves. I got the code running to check the first “b” for possible moves, but i have NO Idea how im going to find all “b”‘s , even less check them all without repeating.

Major issue im having is getting the tuple coordinates of the “b”‘s out of the list.

Any pointers/tips?

  • 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-05-19T09:38:13+00:00Added an answer on May 19, 2026 at 9:38 am

    This finds a list of valid moves from every square.

    I am assume that off the edge of the map is a “wall”, and that you can’t move diagonally:

    # reference like this: maze[y][x] or maze[row][col]
    # with [0][0] starting at the top left
    maze = [['b','a','a', 'a'],
            ['b','a','b', 'a'],
            ['b','a','b', 'b'],
            ['b','b','b', 'a'],
            ['b','a','b', 'a'],
            ['a','a','a', 'a']]
    
    moves = {}
    
    # Loop through all cells of the maze, starting in the top-left
    for y, row in enumerate(maze):
        for x, value in enumerate(row):
    #        print "y, x, val: ", y, x, value
            # for every cell, create an empty list of moves
            moves[y, x] = []
            # then if we can move from this cell
            # check each of its neighbours and if they are a 'b' add it 
            # to the list of moves - assumes we can't move diagonally
            if value == 'b':
                if y - 1 > 0 and maze[y - 1][x] == 'b':
                    moves[y, x].append((y - 1, x))
                if y + 1 < len(maze) and maze[y + 1][x] == 'b':
                    moves[y, x].append((y + 1, x))
                if x - 1 > 0 and maze[y][x - 1] == 'b':
                    moves[y, x].append((y, x - 1))
                if x + 1 < len(row) and maze[y][x+1] == 'b':
                    moves[y, x].append((y, x+1))
    
    print moves
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have list of items with check boxes using this code: ProcessList = (ListView)
I have list of restaurant details along with menus which i got from singleplatform.
I have list of ints consisting of {1,2,3,1,2,1,5,1,2,1,1} I like retrieve all 1 located
I have list of attached files and want to make my LinearLayout with it
i have List<List<Person>> i want it to copy all people in the previous collection
I have list of input area in the form with id like contact1_title, contact2_title,
I have list of articles on the page in table and i want to
I have list of structure. I want to modify a particular data from the
I have list of textareas. For textareas I use tinyMCE Editor. When I start
I have List I want to sort Desc by Priority, which is int and

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.