Contest 45: 7 Card Draw

Online C++ programming contests.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard, raimo

Postby Corsix » Sat Aug 27, 2005 1:06 pm

Darryl wrote:i can't believe there's a solution under 300 tokens.
To be honest, neither can I :shock:
Code: Select all
#include <stdio.h>
char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";
int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main
(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}
User avatar
Corsix
 
Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

Postby Corsix » Sun Aug 28, 2005 9:13 am

Darryl wrote:Here's another sample input with some of the more difficult to eval hands.
ah kh qh jh 10h 2h 8s as 2s 3s 6d 4s 2c 5s
2h 3h 4d jd 4h 5h 6h as 2s 3s 6d 4s 2c 5s
ad kh qs jd 10h 2h 8s as 2d 3s 6d 4s 2c 5h
2h 3c 4d jd 4s 5h 6h as 2s 3c 6d 4s 2c 5h
qh 7h qd 4d 4h 2h 8s as 3s 3d 6d 4c 2c ah
5s 2s ks 3s 8d 10s 5c 4c 2c 7h 3c 10c kc 6s
ks 6s ac 9c 6c 3c kh 9s 4c 9d 7d jc 2h 10c
kc 8s kh ks 6h 5h 4s 5s 2h 10h 10s 9h ah ad
5d 5c 5h 8d 8h js 10s 3c 7c 4h 6s 2s ah 4s


and the expected output

qh kh jh ah 10h
6h 5h 4h 3h 2h
qs kh jd ad 10h
6h 5h 4d 3c 2h
as ah 6d 3s 3d
ks 5s 3s 2s 10s
ks kh ac 6s 6c
ks kh kc 8s 6h
8h 8d 5h 5d 5c
I would like to point something out about #4:
2h 3c 4d jd 4s 5h 6h as 2s 3c 6d 4s 2c 5h

Set 1 is: 2h 3c 4d jd 4s 5h 6h
Set 2 is: as 2s 3c 6d 4s 2c 5h

The best from set 1 is: 2h 3c 4[d or s] 5h 6h
The best from set 2 is: 2s 3c 4s 5h 6d

You put the answer as:
6h 5h 4d 3c 2h
, however it can be any of these:
2h 3c 4d 5h 6h
2h 3c 4s 5h 6h
2s 3c 4s 5h 6d


In other (related) news, I'm checking my entry redy for testing.
Code: Select all
#include <stdio.h>
char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";
int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main
(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}
User avatar
Corsix
 
Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

Postby Darryl » Mon Aug 29, 2005 7:18 am

I had pointed out earlier, that in the case of a tie, that either (any) correct answer would be acceptable as well as variations on a hands such as with four-of-a-kind, the 5th card can be anything because it plays no role in ranking the hand, while in two pair, the fifth card can make a difference and therefore only the highest would be acceptable (even if it plays no role in that particular hand)

One other note, is that I will be traveling from the 31st to the 7th, but I will try to still review the entries on whatever computer I have available, but I will only have access to msvc beta and dev-c since I can download those, so if your entry depends on MSVC 2003.net then I may have to wait to I return to review it.

On second thought, I guess I can download msvc toolkit as well...and use command line (grumble grumble)
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Corsix » Mon Aug 29, 2005 7:31 am

I've only tested my entry on MSVC 2003.net; it may work on a newer version of MSVC but I do not know.
Code: Select all
#include <stdio.h>
char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";
int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main
(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}
User avatar
Corsix
 
Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

Postby gamma » Tue Aug 30, 2005 1:26 pm

Again: frustration mode:
Aaargh. I want to enter *whining*. I have lots, no loads of ideas for this one, but I'm only at half a program. Deadline will beat be. I'd rather be beaten by you guys. Can't enter all contests :( Grr.
while (true){sleep(28800);work(57600);}
"Free" as in speech is so much better than "free" as in beer.
User avatar
gamma
 
Posts: 178
Joined: Mon Dec 01, 2003 9:16 am
Location: The Netherlands

Postby Togra » Tue Aug 30, 2005 2:18 pm

Same here :(! I have almost no free time, but that's not so bad as it sounds.
After the deadline, we must share our ideas (if not exploited by the contestants)! Looking forward to see if BeerHunter will beat Corsix, or is there another silent candidate to win.... ??
Togra
 
Posts: 188
Joined: Wed Jul 28, 2004 8:51 am
Location: NL

Postby Darryl » Tue Aug 30, 2005 3:12 pm

I could always extend the deadline a week, since I will be out of town/on vacation anyway and more than likely won't have time to check entries. I was hoping to get more early entries as opposed to last minute so that I could had checked them prior to leaving.

So far I've only received an entry from Corsix... it compiled and tested ok with 1 of my test files, havn't tried it with the other2 but I am expecting it to work with them as well.

Beer Hunter will most likely send in one tomorrow, and I know safari has made an attempt and hopefully will submit what he has come up with.
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Beer Hunter » Wed Aug 31, 2005 12:02 am

Oh, right, deadline. Submitting…
User avatar
Beer Hunter
 
Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

Postby Corsix » Wed Aug 31, 2005 2:36 am

Beer Hunter wrote:Oh, right, deadline. Submitting…
:lol:
Code: Select all
#include <stdio.h>
char*_="XxTIHRCXCxTIHRXRCxTIHXHRCxTIXIHRCxTXTIHRCxXxTIHRCX";
int main(int l){for(l+=7;l!=putchar(010);++l);if(*(++_))main
(*_!=88?(putchar(*_^073)|putchar(33))&1:0xffff2a8b);}
User avatar
Corsix
 
Posts: 1181
Joined: Fri Jul 23, 2004 9:33 am
Location: Berkeley, UK

Postby Darryl » Thu Sep 08, 2005 8:55 am

Ok, here is the results of the 7 card draw contest:

There were 3 entries including myself, Corsix and BeerHunter ( I think it's beer hunter though the file he submitted was main.cpp - Ryan would had disqualified for not following rules :-) )
The entires can be downloaded here

First, here's the token count:
Beer Hunter 313
Corsix 298
Darryl 346

As for the testing, Only mine and Corsix gave the correct answer in all cases, BeerHunter's missed the highlighted one below, outputting 2 pair over 3-of-a-kind.

So Congratulations to Corsix.

The output of each entry is above and the input below

Good Job all and thanks for participating.

Image
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby exomo » Thu Sep 08, 2005 11:51 am

Congratulation to Corsix and well done to everybody.
Hopefully I can enter the next contest.
Who needs a signature anyway.
User avatar
exomo
 
Posts: 879
Joined: Fri Sep 26, 2003 12:30 pm
Location: germany->baden

Postby Emery » Thu Sep 08, 2005 11:59 am

I demand a recount!
--~~~~
User avatar
Emery
 
Posts: 4313
Joined: Sat Mar 19, 2005 9:16 am

Postby Beer Hunter » Fri Sep 09, 2005 4:43 am

Sorry, I overlooked the rule about needing to call it "beer hunter.cpp". I was looking at the "submissions" heading at the time. :-)

Anyway, congratulations to everyone.
User avatar
Beer Hunter
 
Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

Postby Togra » Mon Sep 12, 2005 12:53 pm

Nice code guys, especially Corsix's hyperstring ;).

My original idea was to write code in a simple language like BrainFuck, put it in string literals and use a little interpreter (about 200 tokens). But this would require a massive amount of time to code, since BrainFuck is very low-level.

Shortly before the deadline Gamma and I discussed the idea to generate some function that would assign a numeric value to a 7-card hand, which would preserve the ordering using those cool string lookups. We both never got the time to work further on it... well, it might very well be infeasible. Anyway - nice contest, I'm really sorry for not participating :(.
Togra
 
Posts: 188
Joined: Wed Jul 28, 2004 8:51 am
Location: NL

Postby Safari » Mon Sep 12, 2005 1:10 pm

Nice codes. Mine was awfull, I created my own regexp method

$c %c /c (c )c

If $ = 10 then % would be 9, /=8, ...

* = any character

# = one character. Then checks if all the other '#' has the same signs

etc etc

It was ugly and big so I didn't want to post it.
User avatar
Safari
 
Posts: 1362
Joined: Sun Sep 19, 2004 11:07 am

PreviousNext

Return to Contests

Who is online

Users browsing this forum: No registered users and 0 guests