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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:29:36+00:00 2026-05-21T15:29:36+00:00

The following piece of code attempts to create a map that shows the minimum

  • 0

The following piece of code attempts to create a map that shows the minimum number of moves it would take to get from each square on that map to the specified location. The function as a whole is largely irrelevant to the problem, but I thought I should provide my problem in context. I’ve also imported deque from collections. The strange part comes in at line 7. I get TypeError: ‘int’ object not iterable. But the statement “distance_from_loc, f_loc = squares_to_check.popleft()” shouldn’t be attempting to iterating anything to the best of knowledge. Any help would be greatly appreciated.

    def complex_distance(self, loc):
        row, col = loc
        squares_to_check = deque((0, loc))
        self.complex_distance_map = zeros((self.height, self.width), int) + 999
        self.complex_distance_map[row][col] = 0
        while squares_to_check:
            distance_from_loc, f_loc = squares_to_check.popleft()
            distance_from_loc += 1
            for d in AIM:
                n_loc = self.destination(f_loc, d)
                n_row, n_col = n_loc
                if distance_from_loc < self.complex_distance_map[n_row][n_col] and not self.map[n_row][n_col] == -4:
                    squares_to_check.append((distance_from_loc, n_loc))
                    self.complex_distance_map[n_row][n_col] = distance_from_loc
  • 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-21T15:29:37+00:00Added an answer on May 21, 2026 at 3:29 pm

    The line does try to iterate:

    >>> a, b = 0
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: 'int' object is not iterable
    

    The line

    squares_to_check = deque((0, loc))
    

    initialises the deque with the two elements 0 and loc, not with the single element (0, loc). Use

    squares_to_check = deque([(0, loc)])
    

    to get the desired result.

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

Sidebar

Related Questions

The following piece of code shows an Insert table dialog: Dialog d = WordApp.Dialogs[WdWordDialog.wdDialogTableInsertTable];
Consider following piece of code: declare @var bit = 0 select * from tableA
The following piece of code is from u-boot: /* Initialize GOT pointer. ** Global
I have the following piece of code pattern: void M1(string s, string v) {
I have the following piece of code which replaces template markers such as %POST_TITLE%
I used the following piece of code in the service to debug the service
I have the following piece of code in Visual C++ 2005 : : class
I've got the following piece of code in an aspx webpage: Response.Redirect(/Someurl/); I also
I have trouble with the following piece of code. When I go through with
I was reading a book on templates and found the following piece of code:

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.