Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Puzzle code...
Index -> Programming, General Programming -> Functional Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jcollins1991




PostPosted: Tue May 25, 2010 8:15 am   Post subject: Puzzle code...

Was bored awhile ago so I wrote a program to solve one of the facebook puzzles ("smallworld")... Unfortunately they don't accept Scheme code so I can't submit it, so I've decided to post it here instead XD, since it's not a working submission it I'm hoping it won't matter...

It's a fairly simple solution, whenever you want to add someone just go through and insert them into each persons list of 3 closest friends, then at the end find the 3 closest friends of the person you're adding... Some variables are reused so it might be a bit hard to read (dist is a function then a value >.<...), but I've quickly commented so hopefully it'll be partially readable... BTW, I know it works for the test case they give, but I haven't really checked for other cases, though it should still work...

edit: looks like I can't upload *.ss files, so I changed it to .txt, just change it back to run it...



smallworld.txt
 Description:

Download
 Filename:  smallworld.txt
 Filesize:  2.89 KB
 Downloaded:  300 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, General Programming -> Functional Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: