Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

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 June 17th, 2003, 05:41 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 26
Lightbulb challenging math/programming question

here is a challenge, i'd like to see what methods people can come up with to solve this other than the way i did it

The problem is to write a program that computes the distance, defined as the number of cells in a shortest path, between any pair of cells. For example, two maggots in cells 19 and 30 are 5 cells apart. One of the shortest paths connecting the two cells via the cells 19 ? 7 ? 6 ? 5 ? 15 ? 30, so you must move five times to adjacent cells to get from 19 to 30.



You will receive points (query a and query b). Then you have to calculate the distance between the two points. After, send the distance back to the server. Repeat this procedure 3 times. When you successfully complete this task and all 3 answers are correct, then you will get the password for the next level. (The input consists of several lines, each containing two integers a and b (a,b ¡Ì 10000), denoting numbers of cells )

Last edited by infamous41md : July 25th, 2003 at 02:33 AM.

Reply With Quote
  #2  
Old June 18th, 2003, 09:55 AM
epl epl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Dublin
Posts: 413 epl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 8
I reckon mapping the 2 numbers to a coordinate system - either angle and distance from the origin or a cartesian x, y pairing - will get you a long way there. I'm going to have a go at

It's a nice puzzle, by the way. mapping to an angle, distance pair and see what comes out.

What language will you use? It's easy enoughto draw a grid like yours iteratively, btw - starting with the cell 1, then the six around it, then the twelve around it and so on...

Reply With Quote
  #3  
Old June 18th, 2003, 12:19 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 26
i did it in C. similar to what you were thinking, altho you run into some difficulties when it comes to calculating the distance. let me know when u finish it and i'll show u my solution and vice versa. and yea, i thought it was a very cool puzzle - even tho it drove me nuts for a few hours trying to work out the initial gameplan

Reply With Quote
  #4  
Old June 18th, 2003, 03:56 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level)infamous41md User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 26
here's my solution.
Attached Files
File Type: tar solution.tar (10.0 KB, 371 views)

Last edited by infamous41md : July 25th, 2003 at 02:33 AM.

Reply With Quote
  #5  
Old July 19th, 2003, 05:10 PM
aries21 aries21 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 1 aries21 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This one is interesting, but heres how you can do it. Set up a coordinate system like you said, except make it a tricoord system (i.e. x,y,z) where they are like this.

_ /
\

You can then determine the distance by adding the coords and dividing by 2...I think. I have some code that is similar to this on my other machine that I can show you if you'd like

Reply With Quote
  #6  
Old July 21st, 2003, 08:19 PM
MarkSigEp MarkSigEp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 MarkSigEp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'd use Dijkstra's algorithm to compute the shortest path - here's an example: URL

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > challenging math/programming question


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT