Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 21st, 2012, 03:58 PM
nnekymoe nnekymoe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 7 nnekymoe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 16 m 4 sec
Reputation Power: 0
Exclamation Assassin game problem

Hi!!
Would anybody know how to solve this question?:

The game of Assassin is a simple game played on university campuses where each player is assigned a target to assassinate by simply saying “you’re dead” to them. Of course with thousands of people on campus and only a few dozen in the game you never know who is looking to assassinate you. Once you assassinate someone you take on the target they were looking for. If this happens to be you then you are the winner. To ensure that this works properly the targets must form a continuous “chain.” Write a program that allows the user to enter their target assignments and output whether it is valid or not based on if there is a continuous “chain.” Each person in the list is represented by position in the list. The value at the position is their target.

Reply With Quote
  #2  
Old November 23rd, 2012, 12:13 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is online now
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,345 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 6 h 49 m 27 sec
Reputation Power: 383
chase the indexes until you get to the start. If the length of this cycle is the length of the list the game is valid.

L = [1,2,0]
Start your count at 0.
Start at index 0. Save index 0.
Add 1 to your count.
Look up L[0]. It is 1.
Is it 0?
No.
Add 1 to your count.
Look up L[1]. It is 2.
Is it 0?
No.
Add 1 to your count.
Look up L[2]. It is 0.
Is it 0?
Yes.
Is the count equal to the list length?
Yes.
These are valid assignments for the game.
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Assassin game problem

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap