Contest 45: 7 Card Draw

Online C++ programming contests.

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

Postby Corsix » Tue Aug 23, 2005 10:37 am

262 WITHOUT the analysis function? You gotta do it in under 51 tokens then.
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 Safari » Tue Aug 23, 2005 10:42 am

Not anymore. I discovered that an array of mine could be changed to a string.
230 tokens now. Now I have to make it under 81 tokens to beat you all :P

Edit: 213 (still without the function)
Edit: 208
Edit: 200
User avatar
Safari
 
Posts: 1362
Joined: Sun Sep 19, 2004 11:07 am

Postby Safari » Tue Aug 23, 2005 11:44 am

What type of libraries can we include?

I'm using a function that's in the string.h-library (I guess it's <cstring> for modern compilers?). But the function still works even without including <cstring>. Must I still include it?
Btw: 195
User avatar
Safari
 
Posts: 1362
Joined: Sun Sep 19, 2004 11:07 am

Postby Corsix » Tue Aug 23, 2005 11:59 am

What function is it?
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 Safari » Tue Aug 23, 2005 12:01 pm

strtok
你 好!
User avatar
Safari
 
Posts: 1362
Joined: Sun Sep 19, 2004 11:07 am

Postby Safari » Tue Aug 23, 2005 12:19 pm

Never mind. I found a solution which takes less tokens and where strtok isn't needed.

I still want to know which libraries are allowed.

181 tokens.
Edit killed 10 more tokens
User avatar
Safari
 
Posts: 1362
Joined: Sun Sep 19, 2004 11:07 am

Postby Darryl » Tue Aug 23, 2005 12:37 pm

any standard library header

DECLARATIONS 65
ANALYSIS 264
MAIN(INPUT/OUTPUT/LOGIC FLOW) 118


My analysis section is pretty big.

Also, how do you make a pointer to an unsigned char and assign it to a literal string?

unsigned char* var = "this is my string with extended ascii codes in it";
gives me an error.
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Alvaro » Tue Aug 23, 2005 12:46 pm

unsigned char *var = (unsigned char *)"this is my string with extended ascii codes in it";
User avatar
Alvaro
Moderator
 
Posts: 5185
Joined: Mon Sep 22, 2003 4:57 pm
Location: NY, USA

Postby Darryl » Tue Aug 23, 2005 12:55 pm

Alvaro wrote:unsigned char *var = (unsigned char *)"this is my string with extended ascii codes in it";


I was afraid you'd say that, I was hoping there could be a suffix(or prefix) I could put on the string to do it.
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Beer Hunter » Wed Aug 24, 2005 12:43 am

Perhaps there is something similar you could use.
Code: Select all
short my16bitvar = L"\0200\0201"[index]; // 8 tokens
User avatar
Beer Hunter
 
Posts: 912
Joined: Sat Dec 13, 2003 7:12 pm
Location: Australia

Postby Safari » Wed Aug 24, 2005 8:39 am

Care to explain that?

Do you guys do these kind of solutions? That doesn't even look like c++ to me... :wtf:
User avatar
Safari
 
Posts: 1362
Joined: Sun Sep 19, 2004 11:07 am

Postby Darryl » Wed Aug 24, 2005 11:13 am

there is a sticky thread where you can download the results for that contest, however, all of the ones on the page you posted are c++ except the one written in corsix script
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Safari » Wed Aug 24, 2005 11:33 am

Please, just give me a link where they show how

"\x0 asd as whatever"[variable]
works.

I'm talking about the string and what the string transforms to (an array?).

Btw: are we allowed to write include "iostream"?
User avatar
Safari
 
Posts: 1362
Joined: Sun Sep 19, 2004 11:07 am

Postby Alvaro » Wed Aug 24, 2005 12:06 pm

The expression `A[B]' just means `*(A+B)'. A string constant has type `const char *', and its value is the address of the first character of the string, so

"foo"[var] == *("foo"+var),

which is the character `var' places after the beginning of the string constant.

An even more obscure way of doing the same thing is reversing the operands, like this:

variable["some string here"]
User avatar
Alvaro
Moderator
 
Posts: 5185
Joined: Mon Sep 22, 2003 4:57 pm
Location: NY, USA

Postby Darryl » Wed Aug 24, 2005 12:47 pm

Safari wrote:Btw: are we allowed to write include "iostream"?


I was going to dis-allow it, but then there were some complaints and I said if no one objected I would allow it and no one has objected so I guess it's allowed

[edit]
corsix, Beerhunter .. I'm coming for you guys...

393... just got rid of my last function, everything is in main and no duplication.

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

PreviousNext

Return to Contests

Who is online

Users browsing this forum: No registered users and 0 guests