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

Username:   Password: 
 RegisterRegister   
 2003 S4 Substring (coded in java)
Index -> Contests
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nate




PostPosted: Tue Feb 17, 2004 5:57 pm   Post subject: 2003 S4 Substring (coded in java)

Here is my answer to the 2003 CCC S4 question.

Its a sketchy answer (probably could be done with less code)

***remeber***
Make a file called substr.in with this format
2 <- number of words
abc <- 1 word
aaa <- second word

On another note:
Does anyone have an answer to 2003 CCC Floor Plan question, or some hints to doing it.



Substring.java
 Description:

Download
 Filename:  Substring.java
 Filesize:  1.55 KB
 Downloaded:  215 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Feb 17, 2004 7:54 pm   Post subject: (No subject)

for the floor plan, you first load the plan into a 2D array marking it as ether floor or wall... then x/y nested forloops to go thought each square, starting a recursion function that will spread, marking all of the floor with that room's marker as long as it is not a wall or not already marked as another room. When the function ends that room is all marked and you increase the counter.

at the end, your marker counter is your number of rooms. Then you just count unique markers to find area of each individual room Very Happy
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
bugzpodder




PostPosted: Wed Feb 18, 2004 8:44 am   Post subject: (No subject)

Quote:
Its a sketchy answer (probably could be done with less code)

***remeber***
Make a file called substr.in with this format
2 <- number of words
abc <- 1 word
aaa <- second word


WHAT??
Tony




PostPosted: Wed Feb 18, 2004 5:35 pm   Post subject: (No subject)

i think that means that file is formated in a way that the first line contains number of lines after that, each containing a single word... an example would be
Quote:

3
first
second
third
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Brightguy




PostPosted: Thu Feb 19, 2004 12:04 am   Post subject: Re: Floor Plan Question

Here's a Visual Basic solution that I developed for the Floor Plan Question when I was going over last year's contest. The input files must be in the same folder as the application.

I must warn you though, I was trying to write it as fast as possible so the code is messy... Rolling Eyes



Floor Plan.txt
 Description:

Download
 Filename:  Floor Plan.txt
 Filesize:  3.88 KB
 Downloaded:  227 Time(s)

nate




PostPosted: Thu Feb 19, 2004 5:00 pm   Post subject: (No subject)

Thats awsome, unfourtunatly i haven't uesed VB...........yet! lol

Do you know how to do this in Java or Turing
Tony




PostPosted: Thu Feb 19, 2004 5:42 pm   Post subject: (No subject)

its exactly the same... it looks like the Brightguy approached the problem in a similar way I described earlier... donno, I just looked over the code quickly and saw some recursion Laughing

anyways, you could just "translate" the code into turing line by line, its preaty much the same, lol
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Andy




PostPosted: Thu Feb 19, 2004 8:24 pm   Post subject: (No subject)

psssh... why use arrays when u can use whatdotcolor tony?
Tony




PostPosted: Fri Feb 20, 2004 3:37 pm   Post subject: (No subject)

oh yeah dodge - use whatdotcolor and the screen as your memory pallet Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Contests
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: