Contest 45: 7 Card Draw

Online C++ programming contests.

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

Postby Corsix » Mon Sep 12, 2005 1:24 pm

Togra wrote:Nice code guys, especially Corsix's hyperstring ;).
A new rule is now implemented about not opening files :lol:

Togra wrote: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.
Nice idea.
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 Sep 12, 2005 1:46 pm

Togra wrote: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 :(.


Why use brainfuck and an interpreter, why not just create a big machine code string and execute it directly as I believe corsix had suggested. It's the same idea and you save having to use the interpreter.

I was playing with the idea of working with the whole 7 cards but couldn't come up with anything efficient. So basically used next_permutation to shuffle between all variations. It was a bit overkill since I only needed combinations (21 to be exact) but it was token effiecient.(I wonder why next_combination doesn't exist?) and then I assigned a value to it in order to break ties.

Me and Corsix "discussed" back and fourth his hyperstring method since it used it's own source file as the run-time input/storage for his hyperstring . I was against it, but allowed it barring no complaints from other contestants. (I had suggested this idea early on but threw it out because of the resulting 25 meg file it produced and the inability to work with the file/string of that size) so I give corsix some credit on pulling it off.
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Corsix » Mon Sep 12, 2005 2:04 pm

Darryl wrote:I was playing with the idea of working with the whole 7 cards but couldn't come up with anything efficient. So basically used next_permutation to shuffle between all variations. It was a bit overkill since I only needed combinations (21 to be exact) but it was token effiecient.(I wonder why next_combination doesn't exist?) and then I assigned a value to it in order to break ties.
If I had known how to use next_permutation i might have been able to squeeze another token or two...
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

Previous

Return to Contests

Who is online

Users browsing this forum: No registered users and 0 guests