Computer Science Canada Free Range Code wrangling |
Author: | md [ Sat May 20, 2006 11:33 pm ] |
Post subject: | Free Range Code wrangling |
Rules: 1. Entries may be written in any language; however I can only verify solutions to programs written in languages for which a free compiler is available. This means no turing (unless someone else wants to verify those solutions...). 2. You may submit as many solutions as you wish for each problem, however only the last one submitted will be accepted. 3. Solutions should be emailed to contest@nxor.org with the subject "Compsci.ca Contest"; and have a compsci.ca username and the question # clearly identified. Questions can be asked by email (same address) or forum post; PMs will most likely be ignored. 4. Points will be awarded as follows: 5 points for each working solution, 2 points for a partially working solution, and no points for a non-working solution, or absent solution. At the end of the contest the user with the most points shall be declared the winner. Prizes will be $10 for first place and $5 for runner up; as well as bragging rights. To be elegible to win you must have at least 20 points. 5. This contest is open to teams, with the prize being split equally among the winners. Teams shall be no larger then two people, and they shall receive one less point per additional team member, or 1 point whichever is greater. (Example: if you have two people in your team you will only get 4 points for a complete solution and 1 for a partial solution). Teams must be clearly identified in solutions. 6. This contest will run two weeks from today (the 21st of may), though it may be extended for an additional week if enough people request it. 7. Questions may be changed if they are found to be too trivial. The reason is that the prize is real money and I want people to work for it. Questions: #1 Write a program that finds the series of consecutive positive integers whose sum is exactly 10000. If there is more then one such series find all of them. #2 Write a program that finds a four digit number all of whose integral powers end with the same four digits as the original number. If there are more then one such number find them all. #3 Write a program that finds four dollar amounts such that the sum of the four amounts and the product of the four amounts is equal to $9.81. If there is more then one solution find them all. #4 Write a program that finds a six digit number such that it can be split into two parts or three digits each, and when those parts are added and the sum squared you get the original number. #5 Write a program that finds a four-digit number that is the sum of the fourth power of it's digits. #6 Write a program that finds the smallest number that is the sum of two pairs of cubes. That is a, b, c, and d are four unique postitive integers such that a^3 + b^3 = c^3 + d^3. There is a solution where a^3 + b^3 < 32768. You should print out hte four integers; and the answer to a3 + b^3. #7 Write a program that finds at least the first five sets starting with 3^2 + 4^2 = 5^2, such that 1.Each set is a set of n consecutive integers, where n is odd 2.The sum of the squares of the first n/2 + 0.5 numbers equals the sum of the squares of the last n/2 - 0.5 numbers 3.The left side of the equation has one more term then the right Output the entire set in order of lowest to highest as well as the sum of each side of the equation. #8 Write a program that finds two five-digit numbers that between them use the numbers 0-9 only once each, such that the first number divided by the second number is equal to 9. If there is more then one solution find them all. #9 Write a program to find all the 9 digit numbers that are perfect squares and that use each of the digits 1 through 9 once each. #10 Write a program that finds all whole numbers (with fewer then six digits) that are equal to the sum of the factorials of their digits. The first two solutions are trivial: 1! and 2!. For a three digit number the equation would be A! + B! + C! = ABC. #11 Write a program that finds an integer that, when a specific digit is removed, is reduced to one-ninth of it's value and that, when a second digit is removed is further reduced to one-ninth of the second value. Your program should print out the lowest complete set of numbers. #12 Write a program that finds the smallest perfect square that begins with exactly sixteen 7s and also finds it's square root. Your program should be able to find a square starting with any specified set of digits. Bonus: Write a program to for all totals less then $10, finds all sets of four dollar values whose sum is the same as their product. Good Luck! |
Author: | Cervantes [ Sun May 21, 2006 8:19 am ] |
Post subject: | |
Nice, Cornflake! I have a question: How does speed affect the score for each solution? If a solution works but takes 30 minutes to complete, what score does it get? I'd say 0, but who knows--you're one of those crazies that leaves their computer on all night. |
Author: | cool dude [ Sun May 21, 2006 10:18 am ] |
Post subject: | |
so i'm guessing no turing or visual basic is that for sure? i can try writing it in java but i just started learning it so i don't think i will have enough time doing it in java. |
Author: | Tony [ Sun May 21, 2006 11:36 am ] |
Post subject: | |
cool dude wrote: but i just started learning it so i don't think i will have enough time doing it in java.
well actually this could be your motivation to learn Java. It's best to learn with practice, and those questions take your practice outside of the "Hello World" comfort zone. |
Author: | cool dude [ Sun May 21, 2006 11:42 am ] |
Post subject: | |
Tony wrote: cool dude wrote: but i just started learning it so i don't think i will have enough time doing it in java.
well actually this could be your motivation to learn Java. It's best to learn with practice, and those questions take your practice outside of the "Hello World" comfort zone. true but unfortunately i still have school and exams are just around the corner so i really don't have the time. if this contest was done in the summer then i would have more time. |
Author: | md [ Sun May 21, 2006 11:52 am ] |
Post subject: | |
Points have no relation to execution time; except in that if it takes more then 15 minutes your doing something wrong and you get 0 points. There are solutions in BASIC that take < 10 minutes on a 386. And yes; turing and visual basic are out. C# might work if I can get it to complile with mono. In fact I'll even accept progams I cannot compile if you can also give me a executable (for linux). The thing about most of these questions is that they aren't terribly hard, so part of teh challenge is writing solutions in a new language. |
Author: | cool dude [ Sun May 21, 2006 11:57 am ] |
Post subject: | |
k i will try writing some of them in java if i have time. is it okay if i just do some of the problems and not all of them. i'm not looking to win just to try. |
Author: | md [ Sun May 21, 2006 12:00 pm ] |
Post subject: | |
cool dude wrote: k i will try writing some of them in java if i have time. is it okay if i just do some of the problems and not all of them. i'm not looking to win just to try.
You can do whichever questions you want; and you can only solve them partially if you wish. You could even team up with someone and try and get more points that way. Question #6 had been changed slightly. Now you need to output one additional number: the sum of a^3 + b^3. |
Author: | bugzpodder [ Sun May 21, 2006 1:27 pm ] |
Post subject: | |
all these problems have deterministic solutions. so all you have to do use find the answers, and use cout. I guarentee you that your solution will run less than 15 minutes. You can even just write a script that uses only echo command in linux. |
Author: | bugzpodder [ Sun May 21, 2006 1:31 pm ] |
Post subject: | |
and double check #3 while you are at it. |
Author: | bugzpodder [ Sun May 21, 2006 1:34 pm ] |
Post subject: | |
anyone interested, similar problems can be found in project euler http://mathschallenge.net/index.php?section=project |
Author: | bugzpodder [ Sun May 21, 2006 1:39 pm ] |
Post subject: | |
and more similar problems (and a few are the same, sorry no solutions there) can be found at: http://homepages.transy.edu/~jmiller/web706/second.htm |
Author: | Cervantes [ Sun May 21, 2006 2:04 pm ] |
Post subject: | |
bugzpodder wrote: and double check #3 while you are at it.
Cornflake wrote: #3 Write a program that finds the two numbers whose cubes add up to exactly 6 3^(1/3) and 3^(1/3) do it. Were they supposed to be distinct? 2^(1/3) and 4^(1/3). How many solutions to this are you supposed to find? |
Author: | md [ Sun May 21, 2006 4:29 pm ] |
Post subject: | |
Yes the questions are deterministic. However you will get negative points if you submit a program that just writes out answers. That is not the point of this contest. The point is to write a program that calculates the correct solution (or solutions); and hopefully to do it in a new language. [edit]#3 has been changed because the original question was trivial. Most of these comments no longer apply [/edit] If people would stop discussing the questions here that would be most appreciated. Giving away hints (or answers) doesn't help at all... If you do have a question about the wording or meaning of a question that's fine. (If a mod could remove the posts that don't match the above statement... that would be most appreciated). |
Author: | rizzix [ Sun May 21, 2006 4:39 pm ] |
Post subject: | |
sorry |
Author: | Cervantes [ Sun May 21, 2006 4:41 pm ] |
Post subject: | |
Cornflake wrote: #3 has been changed slightly; 3^(1/3) cannot be one of the number. Both numbers must be unique.
There's still an infinite number of solutions, though. Sorry, no mod powers here. |
Author: | rizzix [ Sun May 21, 2006 4:42 pm ] |
Post subject: | |
indeed. PS: fixed it btw. |
Author: | md [ Sun May 21, 2006 4:47 pm ] |
Post subject: | |
Bah, where is a powerful mod when needed? The Bonus question is now #3; as the original #3 was apparently more trivial then I thought. A new bonus question will be psoted later tonight. Sorry to anyone who was writing #3. |
Author: | bugzpodder [ Sun May 21, 2006 6:05 pm ] |
Post subject: | |
Cervantes wrote: Cornflake wrote: #3 has been changed slightly; 3^(1/3) cannot be one of the number. Both numbers must be unique.
There's still an infinite number of solutions, though. Sorry, no mod powers here. there was no calculations involved, and plus you cannot output infinitely many decimal digits, plus every questions uses the word "numbers" yet the meaning is different, whether it be integer, positive integer, or reals like in this case. I think project euler (see link i've posted) is a better set of problems than these. |
Author: | md [ Sun May 21, 2006 10:14 pm ] |
Post subject: | |
bugzpodder wrote: there was no calculations involved, and plus you cannot output infinitely many decimal digits, plus every questions uses the word "numbers" yet the meaning is different, whether it be integer, positive integer, or reals like in this case. I think project euler (see link i've posted) is a better set of problems than these. Lookit! Quit ragging on my questions! If they are so easy then write them! There may be other better challenges out there... but this one has $10 attached to it On an unrelated note... the bonus question shall be posted eventually; but tonight and tomorrow day my time is owned by my employer, so I won't have time to find a question until after that. |
Author: | codemage [ Tue May 23, 2006 8:50 am ] |
Post subject: | |
If you ask me, this seems like another elaborate scheme for Cornflake to get us to do his homework for him. Perhaps you should explain the nature of this "contest" and if it's for an "experimental class" and who your "teacher's" name is. For the last time, Cornflake. Do your own work. There are some excellent tutorial sections here for you to learn how to solve these problems the honest way. |
Author: | zylum [ Tue May 23, 2006 9:34 am ] |
Post subject: | |
for #3, basically you want four integers a,b,c,d > 0 such that a*b*c*d = 981 = a+b+c+d ? if so, i dont think there is a solution.. can anyone confirm this? |
Author: | md [ Tue May 23, 2006 12:09 pm ] |
Post subject: | |
codemage wrote: If you ask me, this seems like another elaborate scheme for Cornflake to get us to do his homework for him. Perhaps you should explain the nature of this "contest" and if it's for an "experimental class" and who your "teacher's" name is.
For the last time, Cornflake. Do your own work. There are some excellent tutorial sections here for you to learn how to solve these problems the honest way. Ha! I'm currently working for the summer so no classes for me I just wanted to encourage other people to actually do something duringthe summer (I forgot you silly people still had school) so I figured "Contest!" Blame timmytheturtle for the prizes... they were only going to be $1 at first. Zylum; there is indeed a solution to #3. There is only one solution though. I have solutions to all the questions; if they weren't possible I wouldn't have posted them [edit] bonus finally posted; as a hint there are ~180 sets. |
Author: | zylum [ Tue May 23, 2006 1:32 pm ] |
Post subject: | |
nvm, i was using integers rather than decimals 176 sets? |
Author: | zylum [ Tue May 23, 2006 3:55 pm ] |
Post subject: | |
any clues for 12? |
Author: | md [ Tue May 23, 2006 8:36 pm ] |
Post subject: | |
zylum wrote: nvm, i was using integers rather than decimals
176 sets? It's doable using integers... infact that's how my code does it. You just need to remember that if you multiply 9.81 by 100 to get into integers you also need to do the other side right too (hint hint). #12. Horner's Technique. Character arrays. |
Author: | md [ Thu May 25, 2006 12:01 pm ] |
Post subject: | |
So far no solutions... is anyone actually working on them? |
Author: | zylum [ Thu May 25, 2006 12:40 pm ] |
Post subject: | |
i still dont get #12... horner's method is for solving polynomials, what does that have to do with perfect squares? i have done all the others, which were really easy... ill submit once i finish #12. |
Author: | md [ Thu May 25, 2006 2:53 pm ] |
Post subject: | |
really easy == poor, but that someone actually tried them is good. Hopefully someone else tries them too I'm not exactly sure how the solution to #12 works... all I can go by is the explanation and what code I do understand. |
Author: | MysticVegeta [ Thu May 25, 2006 8:21 pm ] | ||
Post subject: | |||
I have done 17.. easy so far but 12 sorta f**ked me up. I found a pascal solution, too bad I dont read pascal... would someone test it or tell everyone whats going on in this?
|
Author: | md [ Thu May 25, 2006 9:37 pm ] |
Post subject: | |
First that's dephi; not pascal. Second your supposed to write your own solution not steal other peoples code. If your cheating on this one how can I be sure you didn't cheat on other ones too? [edit] That doesn't even look like a solution to #12... wrong topic? |
Author: | zylum [ Thu May 25, 2006 11:26 pm ] |
Post subject: | |
this should be in Martins thread about project Euler... 12 in Euler was pretty tough too. theres a special way you have to find the devisors. *wished he had powers in contest forums * |
Author: | MysticVegeta [ Fri May 26, 2006 1:35 pm ] |
Post subject: | |
Cornflake wrote: First that's dephi; not pascal. Second your supposed to write your own solution not steal other peoples code. If your cheating on this one how can I be sure you didn't cheat on other ones too?
[edit] That doesn't even look like a solution to #12... wrong topic? Weird... It was under .pas extension... I cant differenciate both langs sorry. Isnt #12 the 500 divisors one?? Its the solution for that one... |
Author: | md [ Sat May 27, 2006 11:37 am ] |
Post subject: | |
#12 wrote: #12 Write a program that finds the smallest perfect square that begins with exactly sixteen 7s and also finds it's square root. Your program should be able to find a square starting with any specified set of digits.
Not too hard to check... really either your intentionally spamming the wrong topic or you can't read. In lighter news zylum has submitted answers to everything, though I have yet to check and see if they work. |
Author: | MysticVegeta [ Sat May 27, 2006 9:10 pm ] |
Post subject: | |
oh I am sorry guys, didnt intend to spam, its jsut that zylum and I were talking about #12 on Euler... and you guys were talking about #12 of some other contest here too so I assumed it was the same, what I was really looking for was: http://compsci.ca/v2/viewtopic.php?t=12373 martin's post, sorry for replies, please ignore them |
Author: | zylum [ Mon Jun 12, 2006 12:09 am ] |
Post subject: | |
so uh.. who won? |
Author: | Cervantes [ Mon Jun 12, 2006 11:29 am ] |
Post subject: | |
You did! |
Author: | md [ Mon Jun 12, 2006 12:20 pm ] |
Post subject: | |
You, zylum you won since no one else submitted anything. You can claim your prize somehow... not entirely sure how it'll work. Congrats though. |
Author: | zylum [ Mon Jun 12, 2006 4:04 pm ] |
Post subject: | |
no competitors? what kind of contest was this? i guess they were all afraid of my submissions . btw, forget the prize. i did this more for fun.. were all my solutions correct though? |
Author: | md [ Mon Jun 12, 2006 8:38 pm ] |
Post subject: | |
I actually haven't tried them... if you can send me the output of htem I can just verify that way. Installing a java compiler is a pain |