Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
My solutions
Author Message
JSBN

Posted: Tue Feb 25, 2003 11:01 am   Post subject: My solutions

Ok, Many of you probably did the competition today. It was easy (for me) untill i hit the poetry question, which i did not finnish. here are my answers for the first 3 questions of the competition. I will try to put up what was required ASAP:

Question 1 (Trident)

 code: var t : int var s : int var h : int put "Enter tine length:" get t put "Enter tine spacing:" get s put "Enter handle lenght:" get h for i1 : 1 .. t     for i2 : 1 .. 3         put "*" ..         for i3 : 1 .. s             put " " ..         end for     end for     put "" end for if s = 0 then else     for i4 : 1 .. (5 + s * 2) - 2         put "*" ..     end for     put "" end if for i5 : 1 .. h     for i6 : 1 .. s + 1         put " " ..     end for     put "*" end for

Question 2 (Pictures)

 code: %LARGER AMOUNTS OF PICTURES WILL REQUIRE MORE TIME FOR CALCULATION var C : int var z : int var t2 : int var d1 : int var d2 : int loop     put "Enter number of pictures"     get C     t2 := 65000     exit when C = 0     for i1 : 1 .. C         for i2 : 1 .. C             z := i1 * i2             if z = C then                 if (i1 + i2) * 2 <= t2 then                     t2 := (i1 + i2) * 2                     d1 := i1                     d2 := i2                     exit                 end if             end if         end for     end for     put "Minimum Perimeter is ", t2, " with the dimensions ", d1, " X ", d2     put "" end loop

 code: var sum : int var loca : int := 1 loop     put "Enter sum of dice:"     get sum     if sum = 0 then         put "You Quit!"         quit     end if     if loca + sum > 100 then     else         loca := loca + sum     end if     if loca = 9 then         loca := 34     elsif loca = 40 then         loca := 64     elsif loca = 67 then         loca := 86     elsif loca = 99 then         loca := 77     elsif loca = 90 then         loca := 48     elsif loca = 54 then         loca := 19     end if     put "You are now on square ", loca     exit when loca = 100 end loop put "You Win!"

Tony

Posted: Tue Feb 25, 2003 11:28 am   Post subject: (No subject)

nice, thats 3*15 = 45? Id say better then half the people.

I'll upload poetry, floorplan, subtrings when I get a comfirmation that they're correct. Unfortunatly I wasn't able to solve S5 - Trucks in the remaining 30 minutes and I'll be kicking myself... but mostly my teacher for the whole end of the year if that would cost me my stage 2

Right now my score suppost to be 60.

Can someone post a solution to trucks problem?!
Tony's programming blog. DWITE - a programming contest.
Asok

Posted: Tue Feb 25, 2003 12:06 pm   Post subject: (No subject)

for amusement purposes take a look at my rediculously longer (still works) version of J2:
 code: var picnum : int var x, y : real var counter : int := 0 x := 10 y := 1 loop     put "Enter number of pictures:"     get picnum     if picnum = 0 then         exit     end if     counter := 0     var total : array 1 .. picnum of real     var integers : array 1 .. picnum of int     var finished : array 1 .. picnum of real     var perimeter : array 0 .. picnum of real     var smallest : real := 999999     for i : 1 .. picnum         integers (i) := i     end for     for i : 1 .. picnum         total (i) := picnum / i         for k : 1 .. picnum             if total (i) = integers (k) then             counter := counter + 1                 finished (counter) := total (i)             end if         end for     end for     for l : 1 .. counter         perimeter (l) := finished (l) * 2 + finished (counter - l+1) * 2        if perimeter (l) < smallest then              smallest := perimeter (l)              x:= finished (l)              y:= finished (counter - l+1)         end if     end for     put "Minimum perimeter is ", smallest, " with dimensions ", y, " x ", x     put " " end loop

and JSBN, your J3 is incorrect, you're missing:
 code: if roll >=2 and roll <=12 then

that way the sum of 2 dice is between 2 and 12, on yours you can do like 32 which is impossible in the scenario.
Dan

Posted: Tue Feb 25, 2003 1:36 pm   Post subject: ccc

i got all of the question on j lvl done but 5, dam flooring!, i ran out of time

i will post my awsers soon, i lefted my disk at school
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Tony

Posted: Tue Feb 25, 2003 2:40 pm   Post subject: (No subject)

ya, the floor one was tricki

and as far as I can tell, this year is MUCH harder then last years.

Also, Asok... The problem didn't ask to verify the sum, so you assume the correct input. Maybe I'm playing with "special" dice?
Tony's programming blog. DWITE - a programming contest.
Asok

Posted: Tue Feb 25, 2003 9:47 pm   Post subject: (No subject)

no the problem specifically said the roll was the sum of 2 dice from 2-12 I'll double check that today but I'm pretty sure of it. It makes more sence, also in the example they never used numbers above 12.
Tony

Posted: Wed Feb 26, 2003 2:30 am   Post subject: (No subject)

exactly... the input is 2-12 or 0, you dont need to double check that, although I do see your consern for rolling 99 on first move and winning the game. But since the program is designed to help "visualize" the game on the larger screen, we're to assume the correct input.

I'm not saying you're wrong, its actually nice that you think of such details... but I'm just saying that program would work without that
Tony's programming blog. DWITE - a programming contest.
Delta

Posted: Thu Mar 20, 2003 7:14 pm   Post subject: ????????????????????????????????????

What Test is this and where can I recieve the questions so that I can answer them and test my skills. If someone could send me them I'd much appreciate it. Thnx. :D

Asok

Posted: Fri Mar 21, 2003 11:56 am   Post subject: (No subject)

this is the Canadian Computing Competition, sadly their site hasn't been updated to post the questions however you can view the other questions from previous contests here: http://www.cmc.uwaterloo.ca/ccc/index.html
bugzpodder

Posted: Sat May 24, 2003 10:42 am   Post subject: (No subject)

you dont mind truck problem in C++ right tony? i figured you still want to see it after 3 month i dont want to touch turing before stage 2 next week. anwyazy i am working on the trucking thing right now.
bugzpodder

Posted: Sat May 24, 2003 12:07 pm   Post subject: (No subject)

anywayz, here is my solution for truck. it worked for 3 test cases, so obvious there is a bug in it. this in theory works for me but i dont know why it doesnt work for test case 4 and 5. i spent about an hour debugging it. any one who can catch the error gets bits (i've never donated bits b4 but i suppose the donate bits function works?)

 code: #include using namespace std; int C,R,D; int city[1000][1000];  //city[i][j] - max weight from i to j int maxw=100000;     // max weight the truck can carry int min(int a,int b){  //minimum     if (amaxflow && !visited[i]){                 maxflow=flow[i];                 maxloc=i;              }          }          if (maxloc==dest || maxloc==-1) break;  //found, quit          visited[maxloc]=true;  //visited          for (i=0;i0){  //update all its neighbours                 xyzzy=min(maxflow,city[maxloc][i]);                 if (flow[i]>C>>R>>D;     int t1,t2,d,i,j;     //Input     for (i=0;i>t1>>t2>>d;         city[--t1][--t2]=d;         city[t2][t1]=d;     }     for (i=0;i>t1;flow(--t1);}  //check all dest cities     fout<
Asok

Posted: Sat May 24, 2003 12:13 pm   Post subject: (No subject)

what are the 5 test cases so I can try to debug this.
bugzpodder

Posted: Sat May 24, 2003 12:26 pm   Post subject: (No subject)

here is a *much much* faster version for the bigger test cases. instead of calculating flow seperately for each destination city, i do them all at once so in case of 1000 destination cities, i do not calculate things 1000 times repeatedly.

the test cases are attached. truck.in, truck.out are sample I/O. the rest are contest I/O. it fails on truck4 and truck5.

 code: #include using namespace std; int C,R,D; int city[1000][1000]; int dest[1000]; int maxw=100000; int min(int a,int b){     if (amaxflow && !visited[i]){                 maxflow=flow[i];                 maxloc=i;              }          }          if (maxloc==-1) break;          visited[maxloc]=true;          for (i=0;i0){                 xyzzy=min(maxflow,city[maxloc][i]);                 if (flow[i]>C>>R>>D;     int t1,t2,d,i,j;     //Input     for (i=0;i>t1>>t2>>d;         city[--t1][--t2]=d;         city[t2][t1]=d;     }     for (i=0;i>dest[i];dest[i]--;}     flow();     fout<

truck.zip
Description:
Filename:  truck.zip
Filesize:  125.85 KB

Tony

Posted: Sat May 24, 2003 12:57 pm   Post subject: (No subject)

hey bugz. can you please put some comments into your program... I kind of get lost in there and dont quite understand the logic
Tony's programming blog. DWITE - a programming contest.
bugzpodder

Posted: Sat May 24, 2003 1:23 pm   Post subject: (No subject)

my 2nd program is almost same as the first program. the comments are all there in the first program (i think i only changed 2-3 lines)
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 2  [ 18 Posts ]
Goto page 1, 2  Next
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: