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

  • Home
  • SEARCH
  • 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 918547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:23:43+00:00 2026-05-15T18:23:43+00:00

problem.getSuccessors(getStartState()) – it returns something like ( (4,5) , north, 1) – that means

  • 0

problem.getSuccessors(getStartState()) - it returns something like ( (4,5) , north, 1) – that means 3 things – tuple, direction,cost.

I’m using a dictionary ,closed = {}
Now I need to put the output of above function in the dictionary “closed” – how can I do that??

I need to use only dictionary because I need to return “action” i.e North, south….at the end of function. after doing some iterations, my dict is going to have multiple entries such as ((4,5),north,1) , ((3,4),south,1) and I need to extract the key from the dict i.e (4,5) .what shud I use?

  • 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-15T18:23:43+00:00Added an answer on May 15, 2026 at 6:23 pm

    I need to put the output of above
    function in the dictionary “closed” –
    how can I do that??

    It entirely depends on what you want to use as the key, and what as the value! If the key is something completely unrelated to the tuple ( (4,5) , north, 1) (I’m not sure what the north identifier is supposed to be or how it got thee — you sure it’s not the string 'north' instead?!), then @mipadi’s answer is correct. If the first item (the nested tuple) is the key, the other two the value, then, after

    s = problem.getSuccessors(getStartState())
    

    you’ll do:

    closed[s[0]] = s[1:]
    

    If the “tuple and direction”, together, are the key, and just the cost is the value, then you’ll do, instead:

    closed[s[:2]] = s[2]
    

    So, what is it that you intend to use as the key into the dictionary closed?!

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

Sidebar

Related Questions

Problem: I have a table that prints out vertical but I would like it
Problem is that when I exec sql insert query (I'm using Qt Creator and
Problem: I would like to download 100 files in parallel from AWS S3 using
Problem (simplified to make things clearer): 1. there is one statically-linked static.lib that has
Problem: I am trying to build a recursive tree using a function and data
Problem: I'm streaming my video from a php file with stream_get_contents(); using Flowplayer as
Problem Using Director 11.5 and Windows 7, with MouseWheel Xtra (wheelmouse.zip), I have the
Problem occured when i tried to display xml data that has been taken by
s = problem.getSuccessors(currNode) print s child = dict((t[0], t[1:]) for t in s) print
Problem: I'm working on a website where there is a dial that displays a

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.