PDA

View Full Version : Project Challenge


thuh Freak
2004-05-24, 14:40
this is kind of an idea was mentioend in a thread in the suggestions forum by your's truly. pardon the lameness of this particular challenge, but if we get a fair number of people participating, i or someone else, can come up with better ones. the idea is like this: a programming idea is presented, in general terms, and the membership has to try and implement it. winner gets to wear the "i won the contest" hat*. if possible, the challenge should be vague enough that people can approach it from any programming language they are familiar with. you lose points and credit if you cheat (like googling src code), but you are encouraged to discuss possible ideas and solutions with the membership.

so, ai, heres your first 'project challenge'. implement the game "31". if you are unfamiliar, it works like this: a matrix (two dimensional array, in this case 6x6) of the numbers 1->6 is created (each duplicated 6 times across), and presented to the users. two users (or user and computer, implementor's choice) alternate selecting a number from the list. after the number is picked, its removed from the options (note: so each number [1->6] can be picked 6 times). the running sum of the selected numbers is maintained as well (preferably visible to the user). the person who makes the total exactly equal "31" wins. if a user pushes the total over 31, they lose. under 31, and the game continues. (yes the game is incredibly lame, but so is my creativity.) extra poitns to whomever can make a computer who can't win (cuz who wants to lose?). and even more brownie points to whoever can make the computer unbeatable. also, you can try making 6x5, 5x5, or nxm versions, possibly with different end totals.

here's an example:
i go first and pick 6. cpu goes and picks 1 (total=7). i do 5, cpu does 6. (total 18). i do 6, cpu does 6 (30). i do 1 (total=31). i win. oh boy, that was fun!

edit: submitters can optionally make binaries/run-only versions of the code available to the public (i can host em if you like), but source should be submitted to the judge panel (for now, i am the judge panel. if anyone would like to join our illustrious group, pm me). try not to give away the answer until the contest is declared closed. and don't be dissuaded if someone beats you to finishing, cuz you could do it in another language, or do one of the bonus challenges.

edit #2: submitters should put their tarballed (.tar.bz2 or .tar.gz**), or .zip'd, submissions into my ftp site. its not up 24/7, but damn near most of the time. ftp://thuhfreak.isa-geek.com. you can put anything for a username, if asked. it shouldn't ask for a password. when you upload, your file(s) will be magically scooped away to some far off land (the judging area), then an empty file will be put in their place. if an empty file doesn't appear after your upload is done, pm me. or if there are any problems, pm me. oh, and please dont hack my poor little ftp server.

edit #3: deadline. i think friday at noon (EDT, which is -4 GMT) is a good cutoff, to make sure this doens't last forever.

* hat not included, nor will it be furnished by thuh Freak. also, hat should be released to the next winner of the next challenge. maybe instead of a hat, we could use the member status dealie.

** if you are unfamiliar with 'tarballing', it goes like this: put everything you want to give away into a folder. for example, the "tarball" folder, and put it in your home directory. open up Terminal.app, and open a new window. type in:cd; tar c tarball > tarball.tar replacing 'tarball' in the above with your foldername. now you have a "Taped ARchive". next step is compression. cd; bzip2 tarball.tar #OR
cd; gzip tarball.tar
bzip2 will take longer, but will make a more highly compressed file (not noticeable, generally, for small files). after running tar and bzip2, you have a file named "tarball.tar.bz2" (or "tarball.tar.gz" if you did tar and gzip). send that file to me for submission.
note: the previous stpes may require the BSD subsystem, or some other configurably removeable part of the os. I know that the tar, bzip2 and gzip programs are all available through fink, if you don't have them.

AirSluf
2004-05-24, 17:16
XXXXX

hyperb0le
2004-05-24, 18:25
When is the deadline? I would enter, but I'm up to my nose in code for a word processor I'm writing. If the deadline isn't too soon, though, I may give it a shot.

thuh Freak
2004-05-24, 18:34
When is the deadline? I would enter, but I'm up to my nose in code for a word processor I'm writing. If the deadline isn't too soon, though, I may give it a shot.
i was thinking about making a deadline, but i decided not to. i want this to be as much of a no-pressure "contest" as possible. something to play with, and discuss, but not somehting to get in a tizzy about, nor to skip work/school/life over. but, on the other hand, the sooner we get some interest, the sooner i can come up with some non-lame challenges. i've cooked up a few already.

Gargoyle
2004-05-24, 19:43
Coolies. This is the exact type of idea I need to build up my coding. I will try and do this as a cocoa app, but if interest is a bit slow to start I will make it as a php web page.

spotcatbug
2004-05-24, 20:03
Anybody have a link to a free C/C++ code obfuscator?

thuh Freak
2004-05-24, 20:55
Anybody have a link to a free C/C++ code obfuscator?
;) perhaps i need to clarify (note: an edit will be pending shortly in the top message).

spotcatbug
2004-05-25, 09:45
Alright, I'm trying it out. I like puzzles and contests.

One question: who wins if there's no possible move? Like, for example, if the total is 30 and there aren't any more 1's to choose.

edit: Oh wait. Never mind. I see. The next player would be forced to make the total greater than 31 and they would lose.

thuh Freak
2004-05-25, 10:09
Alright, I'm trying it out. I like puzzles and contests.

One question: who wins if there's no possible move? Like, for example, if the total is 30 and there aren't any more 1's to choose.

edit: Oh wait. Never mind. I see. The next player would be forced to make the total greater than 31 and they would lose.
correct.

hint: a good strategy, like maybe for the unbeatable computer version, would be to look ahead one move and make sure that your opponent will put you within range of 31; another might be that you can put him so close to 31, yet can't hit it exactly. personally, i like the satisfaction of when i hit 31, rather than when my opponent goes over, but either win is acceptable in the rules.

spotcatbug
2004-05-25, 10:51
I was about to post my initial stab, but I think we need a system for naming our entries first (binaries, source folders, whatever). Otherwise we'll have a bunch of "aichallenge1"'s (and the like) posted.

I was thinking along the lines of using our AI names followed by some indication of which challenge it is. Like, for me, on this challenge "spotcatbug_1" or "spotcatbug_AI1".

Also, is anybody else trying this? I don't want to be the only one. :o

thuh Freak
2004-05-25, 11:25
I was about to post my initial stab, but I think we need a system for naming our entries first (binaries, source folders, whatever). Otherwise we'll have a bunch of "aichallenge1"'s (and the like) posted.

I was thinking along the lines of using our AI names followed by some indication of which challenge it is. Like, for me, on this challenge "spotcatbug_1" or "spotcatbug_AI1".

Also, is anybody else trying this? I don't want to be the only one. :o
well, first, i don't think you're the only one. the thread has gotten a lot of views (hopefully interested hackers, and not just me poking in every so often). the lack of deadline might be having a procrastination effect on potential contestants.

naming convention sounds like a good idea. how about ai name, then challenge name (31), then submission number (incase someone submits future versions, potentially for the bonus challenges). so "thuhFreak_31_1", and underscores are interchangeable with spaces. i prefer for submissions to be tarballed (.tar.bz2 or .tar.gz), and hopefully have a folder at the top level with sources/binaries inside. your ai name should be near the top of the source files as well. i'm going to setup an anonymous ftp server, where people can make submissions. i'll update the top message when its in place.

spotcatbug
2004-05-25, 13:11
i prefer for submissions to be tarballed (.tar.bz2 or .tar.gz)Is .zip ok? Is there a reason not to use .zip? I kinda like being able to just right-click on the file/folder in the Finder and then choose "Create Archive of..." from the contextual menu.

thuh Freak
2004-05-25, 13:18
Is .zip ok? Is there a reason not to use .zip? I kinda like being able to just right-click on the file/folder in the Finder and then choose "Create Archive of..." from the contextual menu.
.zip is ok, i'm just trying to avoid .sit, b/c i dont have stuffit, and dont want it on my computer.

spotcatbug
2004-05-25, 13:22
Ok, here's (http://www247.pair.com/kinetic/ai/spotcatbug_31_3.zip) the binary for my first attempt. It's a command line app (should be able to just double-click and it'll launch in the terminal).

I don't know if the computer is unbeatable, but I think it's pretty good. I haven't been able to beat it yet.

edit: I added the ability to change the computer's intentions from "try to win" to "try to lose."

edit2: I didn't switch to the "Deployment" build style in Xcode. This binary works.

thuh Freak
2004-05-25, 13:51
Ok, here's (http://www247.pair.com/kinetic/ai/spotcatbug_31_1.zip) the binary for my first attempt. It's a command line app (should be able to just double-click and it'll launch in the terminal).

I don't know if the computer is unbeatable, but I think it's pretty good. I haven't been able to beat it yet.
i'll hold off on trying it out, until we declare the challenge over, lest i unnecessarily prejudge. i think friday noon is a good cutoff date. if you can think of any updates, or changes, feel free to submit them.

thuh Freak
2004-05-25, 13:52
When is the deadline? I would enter, but I'm up to my nose in code for a word processor I'm writing. If the deadline isn't too soon, though, I may give it a shot.
ok, i decided to put in a deadline, just so this thing doesn't last forever. friday noon, then shortly after (probably mid saturday) i'll announce the winner, and the next challenge (it should hopefully be tougher).

AirSluf
2004-05-26, 01:32
XXXXX

thuh Freak
2004-05-26, 11:38
I'm in for a 2 player version, working a computer opponent next.
i patiently await your second submission.

i was wondering, aside from the lameness of the challenge, do you guys feel it was too easy, too hard, just right? disrespective of the difficulty, do you feel like you have enough time, too much time? i got a pretty crafty next challenge lined up, and i was thinking it'll be like a one day event, instead of most of a week. but i don't know if its beneath or above you guys. (thinking aloud...) maybe for the next one i'll try to do a few concurrent challenges, with various difficulties and deadlines. and i'll see which one gets more action.

AirSluf
2004-05-26, 14:12
XXXXX

AirSluf
2004-05-26, 23:11
XXXXX

Gargoyle
2004-05-27, 18:14
I am on page 58 of my "Beginners Guide to C". Will I get extra points if I actually make a working submission by tomorrow afternoon? (I don't even know how to define an array yet!)

spotcatbug
2004-05-28, 09:52
i was wondering, aside from the lameness of the challenge, do you guys feel it was too easy, too hard, just right? disrespective of the difficulty, do you feel like you have enough time, too much time? i got a pretty crafty next challenge lined up, and i was thinking it'll be like a one day event, instead of most of a week. but i don't know if its beneath or above you guys. (thinking aloud...) maybe for the next one i'll try to do a few concurrent challenges, with various difficulties and deadlines. and i'll see which one gets more action.I liked this challenge (31). There was more time than I needed, but that's not always going to be the case for me. I just happened to have some free time at the start of this one. I think roughly a week (or however long this challenge lasted) is probably going to be a pretty good amount of time, regardless of the difficulty. That way it doesn't come down to timing (the winner is the person that happened to have the right scheduling). Having more than one challenge going at a time sounds best to me; people could pick which they like/is at their skill level/they have time for.

Ryan
2004-05-28, 16:47
Its a little late, where I live at least, but here's my submission:

http://homepage.mac.com/ryantann/cubedude_31.py

Its in Python, because I heard that it was an easy language to start with. It can be run from the Terminal with(if its in your home folder) "python cubedude_31.py"

It isn't much, as this is my first real project. All I've done before this is simple stuff like the quadratic formula and other various equations. For example, my submission doesn't allow the computer to be an opponent, or even make a distiction between Player 1 and 2.

spotcatbug
2004-05-29, 16:38
I've got next week off. More challenges, please! :D

thuh Freak
2004-05-29, 20:42
The results are in: spotcatbug is the winner for the first ever semi-regular AI.org Project Challenge. i'm going to post to the 'member status' thread as soon as i'm done here. horray for scb! spotcatbug was the first submitter to send in a working rendition of the "31" game, with nearly-perfect ai. the challenge was actually a trick, there is no way to guarantee a win, if the first person knows what they are doing. and fyi, to win at 31, a person should pass the turn back to their opponent with the following totals: 3, 10, 17, 24, 31. if the first player starts at 3, and doesn't stray from those, he'll win. if either player ever strays from those numbers, their opponent can pick it up from there and win. thanks to all the contestants (all three of you ;)). sorry i didn't post earlier. i had checked in every couple of hours and the site was down.

And, as promised, I have more than one challenge prepared for ya'll. The first one, we'll call it "Age", has a language requirement. i broke one of my own damned rools. but i like this one, and it wouldn't be as challenging if it was language-agnostic. if you don't know sql (or any of its variants), i recommend reading one of the numerous tutorials out there on the web. ok, now the "Age" challenge: you have a table "People", with columns "Name" (varchar 50), and "Age" (smallint). There are 4 records in there, as follows: Laura:15, Jane:20, Bob:10, Nickie:17. try to find, in the simplest, shortest, most efficient, quickest or just any old way that works, a sql query that will return the oldest person's name. and you can't just hard code the name, like "select name from people where name='jane';". your query has to be able to find the oldest person even if i remove jane from the table, or add an older person (or people) to the table. also, you are only allowed to return the oldest person's name (no more, no less; just one record). for this challenge, don't put the answer anywhere public. you can post it to my ftp server (its not up right now, but should be in less than an hour).

the simul-challenge this week is called "Monty Hall", or "MH" for short (when you make your submissions). i've mentioned it once or twice before back at the old ai, so you may have heard of it from me already; or perhaps you've heard of this problem on your own adventures. the idea is this: 3 doors are presented to the user. behind two doors are "zonks", basically they are loser doors. one door has the grand prize (in our game, the grand prize is just +1 on their score; and a zonk is no change). the user selects a door. but to twist the game a bit, at this point Monty Hall opens one of the doors (NOT the one the user selected, AND NOT the grand prize; thus it is ALWAYS a zonk) and says to the user "look, this one is a zonk. would you like to change your answer?" as math would have it, the user has a 66 2/3% of being right if they change at that middle junction. your challenge, should you choose to accept it, is to create a comptuer simulation of the Monty Hall problem. the submission should have two play modes: live and statistic (or your implementation can do either). in live mode, the user selects a door, a zonk is revelaed and the user gets to rechoose or stick to their answer; score should be maintained and be visible when the user wants it, as well as the total number of live games. in statistic mode, the user says how many times to run the game, and the computer acts in the player's place: randomly selects a door, a zonk is revealed by Monty, and then always changes their selection. a count should be maintained of how many successes, and failures, and percentages should be made available. note: in both live and statistic modes, the prize door should be randomly chosen before the game starts, and prize behind the doors doesn't move once its been selected (until the next round begins). also, in statistic mode, the computer shouldn't cheat ;). a good measure of how good your statistic mode will be the proximity to 66.666% as more iterations are done. for this challenge, you can post binaries in public, but try to keep source code hidden (ie, just on my ftp server, or in PMs). there are no restrictions on language for the MH problem.

both of these challenges are due Friday at noon (Eastern Daylight Time) again.

spotcatbug
2004-06-02, 17:02
This thread is still alive. :)

My Monty Hall submission is here (http://www247.pair.com/kinetic/ai/spotcatbug_MH.html). I did it as an applet, so you can try it just by clicking that link. The interface is sorta not laid-out too nice, but should be easy to figure out.

P.S. Does anybody know why the background of the applet is brushed metal?

SilentEchoes
2004-06-02, 19:47
Aw cmon thuh Freak, Your first challenge could be done entirely with a select statement. You gotta post something a bit more challenging than that.

ast3r3x
2004-06-02, 20:44
Aw cmon thuh Freak, Your first challenge could be done entirely with a select statement. You gotta post something a bit more challenging than that.

Shut up, I can do this one in less then a minute ;)

thuh Freak
2004-06-02, 20:44
Aw cmon thuh Freak, Your first challenge could be done entirely with a select statement. You gotta post something a bit more challenging than that.
yea. i kno. some people, even sql "experts" have trouble on it though. the dba at work uses it as a question for anyone we hire in IT. its fun to watch people squirm when they can't get it immediately.

SilentEchoes
2004-06-02, 23:16
Yeah its funny because when I first read it I expected it to be all complicated so in my head I immediately started picturing the structure of the code with arrays and whatnot but then as I was typing it out I was like oh duh.

MCQ
2004-06-03, 00:27
Put in my submission. The first one was nice and easy... spent a little time on the second one, didn't go so far as to put it in an applet though :p I think the code works, but didn't test it much.

thuh Freak
2004-06-06, 13:55
The results are in. And, buh bua da dah, spotcatbug won again. He was the first to submit both challeges, and have the answers be correct. I'll run over to the member status thread in a second.

More people seemed to like the sql challenge than the other, so I think I'll continue down that road for a week. This one is called "Age v2" (or av2 for short). Much like the previous sql challenge, you have a table, "People", with two columns, name (varchar 50), and age (smallint). In the shortest, most effecient, blah blah or anyway that works, query the table and return ONLY the second youngest person. For example, if the table has the records: Laura:15, Jane:20, Bob:10, Nickie:17, you would return Laura. And you can't manually write in anybody's name. I should be able to insert, remove, or replace anyone's name or age, and the query/queries should stil pull the second-youngest person's name from the list. Accuracy will be the first test, then speed, and finally length. If yours executes faster, is written shorter (not including white space, nor appreviations like 'desc'), and of course, is accurate, you'll be crowned the winnar. I'd also prefer we not use temp tables, though if everyone does it, i'll consider them. Cut off date is friday at noon, yet again. You can PM me responses, IM them if you catch me on aim (i'm thuhfreak), or put them in a text file and upload them to my ftp server: ftp://thuhfreak.isa-geek.com/. The ftp server will replace anything it receives with a blank file, and puts the real one in a secret hiding place, so the next person to come to the server won't see the response. Also, your response should work with mysql, though we prefer non mysql-specific code.

thuh Freak
2004-06-08, 14:04
I just thought up a new challenge. Something, maybe, for you non-sql people out there to play with. We'll call this one "Mathy". Your program should have an input available from the user for a string (how you present it, of course, depends on your implementation). The user inputs a series of math operations (basic ones, like +, -, * and /) with numbers too. For the sake of this challenge, you can assume the user inputs them correctly (so you can drop any error messages rising from user input; though you should still check for errors in your own code ;)). The program should interpret the string, and evaluate the operations, in proper order (mul, then div, then add, then sub), and display the result. Note: For implementations that allow it, live updating of the result may not be preferable, and you may want to evaluate the result when they hit a button or some other interface element.

So, for example, the user may put in "5 + 6 * 3", your program should return 23 (5 + (6 * 3)=5+18=23). Extra points if you put in parenthetic evaluations (ie, user inputs "( (5 + 6) * 3 )", and you return "33"). Preferable solutions will not have a length or number of operation requirement. Your on your honor to not steal code from the internet, as I'm quite sure it is more than abundantly available. You are, however, encouraged to discuss incomplete theories and algorithms. We'll make the deadline for this one Saturday, at noon (eastern time), since I thought of it a later. You can submit links to source to me in PMs, IMs or upload source to my ftp server (ftp://thuhfreak.isa-geek.com).

thuh Freak
2004-06-08, 16:50
i'm also kind of curious, for each of the challenges, how long you expected it to take, and how long it actually took to finish them. again, you are on your honor with that, and it wont affect if you win or not. i'm just curious.

spotcatbug
2004-06-09, 09:31
Here's (http://www247.pair.com/kinetic/ai/spotcatbug_Mathy_1.html) my entry for Mathy. I'm pretty sure it works correctly. Once again, it's an applet (just click the link to try it).

I expected it to take about an hour. That was a little optimistic and I headed down the wrong path and ended up with a solution where I couldn't get operator precedence and parentheses working, so I basically had to begin again after about an hour and a half.

Took me three or four hours, mostly thinking. I think that's a good length. Too short is almost not worth the trouble. Too long, and I should probably be doing something else.

I couldn't see a really simple, clever implementation, even though I have this strong feeling that there is one. I ended up just thinking to myself, "Ok, how do I evaluate an expression like this?" And then I coded that up.

thuh Freak
2004-06-09, 11:29
I expected it to take about an hour. That was a little optimistic and I headed down the wrong path and ended up with a solution where I couldn't get operator precedence and parentheses working, so I basically had to begin again after about an hour and a half.

Took me three or four hours, mostly thinking. I think that's a good length. Too short is almost not worth the trouble. Too long, and I should probably be doing something else.

I couldn't see a really simple, clever implementation, even though I have this strong feeling that there is one. I ended up just thinking to myself, "Ok, how do I evaluate an expression like this?" And then I coded that up.
it's kind of funny. i came up with this problem cuz i needed it for work, and i had been thinking about it before and had estimated for myself it would take me a few days (hence, i tried pushing it off to you guys, :o i was cheating). i had worked out a left to right (thus no order of ops), non-parenthetic solution a few days ago, that was basically no thinking- just typing. the client had seen it, tried some numbers and wasn't too happy ("its not logical"). so basically i had to come up with this a solution and i was stumped. after i posted the challenge, i figured i'd try to actually write some code. after about a half hour i had a craptacular, almost-working, non-parenthetic, but proper order-of-operation solution. and from my thinking, it wouldn't be possible to work in parentheses. but i made the non-parentheses part work, then i separated out the parenthetic approach completely, and broke them down into a bunch of little non-parenthesis versions. overall i was done in 2.5 hrs (not including my l->r version) and i was so surprised by my speed, that i figured i'd ask you guys your speeds. i generally overestimate, but in this case i was way off.

i dont think mine was particularly clever (well maybe, but it doesn't seem so). its just really cool that it works. i tested like a whole shitload of answers with 'bc' (a cli calculator), and i was spot on every time. i haven't looked over your code yet, cuz i want to hold off judging on these until the contest is over.

spotcatbug
2004-06-09, 12:10
hence, i tried pushing it off to you guys
:lol: In that case, you should have included a language requirement, too, so we'd be writing for your environment. Save you some time. :D

i had worked out a left to right (thus no order of ops), non-parenthetic solution a few days ago, that was basically no thinking- just typing
That's exactly where I had to stop and start over. It was at that point that I realized I would need to think a little before typing.

thuh Freak
2004-06-09, 12:32
:lol: In that case, you should have included a language requirement, too, so we'd be writing for your environment. Save you some time. :D
i considered it, but i thought, how many, of the handful of programmers we have here, would know vb.net (or cs.net), and how could i suggest it without it being obvious that i was cheating.

spotcatbug
2004-06-09, 12:49
i considered it, but i thought, how many, of the handful of programmers we have here, would know vb.net (or cs.net), and how could i suggest it without it being obvious that i was cheating.
Well, actually, now that you mention it, I might have enjoyed trying to do it in cs.net (assuming that means C#.NET, or however that's supposed to be typed). Something different.

thuh Freak
2004-06-09, 17:27
Well, actually, now that you mention it, I might have enjoyed trying to do it in cs.net (assuming that means C#.NET, or however that's supposed to be typed). Something different.
yea, i meant c#. that stupid little hash button is annoying to type. in my day, computer language names were written with the roman letters, and we liked it. none of that music symbol crap. feel free to challenge yourself to a cs implementation.

thuh Freak
2004-06-13, 11:14
Well, this time around, sadly, interest seemed to drop to '1'. :\ Spotcatbug was the only one to submit. I think I'm gonna hold off for a while on challenges. If anyone else would like to come up with challenges, and do some judging: feel free.