Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
ECOO 2013 Round 1 Solutions

(No ending time set)
1 - Very Easy  42%  [ 3 ]
2 - Somewhat Easy  42%  [ 3 ]
3 - Neither Easy nor Difficult  0%  [ 0 ]
4 - Somewhat Difficult  14%  [ 1 ]
5 - Very Difficult  0%  [ 0 ]

Author Message
SamScott

Posted: Thu Apr 04, 2013 6:52 am   Post subject: ECOO 2013 Round 1 Solutions

Hi Everyone,

The ECOO Computing Competition Round 1 is over. Attached are the questions, data files, solutions, and notes. Please use this thread to discuss any aspect of the competition. If you have alternate solutions or solution ideas please post or discuss here.

Sam Scott
Sheridan College

ECOO 2013 Round 1 - Solutions.zip
Description:
Filename:  ECOO 2013 Round 1 - Solutions.zip
Filesize:  314.4 KB

ishidon

Posted: Thu Apr 04, 2013 3:21 pm   Post subject: Re: ECOO 2013 Round 1 Solutions

I solved #4 rather simply by just trying every permutation of the coupons.
Here is my code in Python 2.6.
Solved DATA41.txt in around 16 seconds on my computer and DATA42.txt in around 0.6 seconds.
Unfortunately it was after the contest -_-
 code: from itertools import permutations from copy import deepcopy def eva(xx, y):     x = deepcopy(xx)     for i, v in enumerate(y):         if v != "BOGO":             if v == "\$5":                 x[i] = max(x[i]-5, 0)             elif v == "\$10":                 x[i] = max(x[i]-10, 0)             elif v == "\$50":                 x[i] = max(x[i]-50, 0)                elif v == "10%":                 x[i] *= 0.9             elif v == "20%":                 x[i] *= 0.8                         elif v == "BOGO":             temp = y.index("!")             maxv = max(x[i], x[temp])             if maxv == x[i]:                 x[temp] = 0             else:                 x[i] = 0         if v != "TAX":             x[i] *= 1.13                 for i, v in enumerate(x):         x[i] = round(v, 2)     return sum(x) infile = open("DATA41.TXT") nums = [] keys = [] coupons = []  testcases = [] for i in infile:     i = i.strip()     if "." in i:         nums.append(float(i))     elif "B" in i or "%" in i or "\$" in i or "T" in i:         coupons.append(i)     else:         keys.append(int(i))         if len(keys) == 3:             testcases.append([nums, coupons, keys[:-1]])             nums = []             coupons = []             keys = [keys[-1]] testcases.append([nums, coupons, keys[:-1]]) for i in range(5):     nums = testcases[i][0]     coupons = testcases[i][1]     keys = testcases[i][2]     while coupons.count("BOGO") > 2:         coupons.remove("BOGO")             if coupons.count("BOGO") == 1:         coupons.append("BOGO")     while len(coupons) < len(nums):         coupons.append("NOTHING")     lnum = 100000     for i in set(permutations(coupons, keys[0])):         if (i.count("BOGO") == 0 or i.count("BOGO") == 2):             if "BOGO" in i:                 temp = i.index("BOGO")                 ii = []                 c = 0                 for blah in i:                     if blah == "BOGO" and c == 0:                         c += 1                         ii.append("BOGO")                                             elif blah == "BOGO" and c != 0:                         ii.append("!")                     else:                         ii.append(blah)                 num = eva(nums, ii)             else:                 num = eva(nums, i)             if num < lnum:                 lnum = num            print "The best price is \$%.2f" %lnum
crossley7

Posted: Thu Apr 04, 2013 7:21 pm   Post subject: RE:ECOO 2013 Round 1 Solutions

Can't write this anymore since I'm in Uni now but there questions look decent. Q4 might be a little trickier than in past years but I think for some regions that is much needed.

Overall though looks like a good balanced contest. Though maybe a few more types of questions would help. Seems a bunch of these were simulation/ad-hoc. A geometry or graph search problem would be helpful to balance it out
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 3 Posts ]
 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: