Contest 44 Results

Online C++ programming contests.

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

Contest 44 Results

Postby Darobat » Thu Feb 17, 2005 8:42 am

togra - 99 tokens
gamma - 103 tokens
Darryl - 107 tokens
corsix - 112 tokens
Beer Hunter - 117 tokens
Alvaro - 124 tokens

and the file I used to test each persons code on
Code: Select all
0h2s       h9h9g
   2       9   5
   g   d6h9t   k
   6   1       3
   d9h9t   g9f9f
           5
       e   g
       1   9
       i2a1j

The correct output should be 1337.

All entries can be downloaded here.
Congrats to togra on breaking the 100 mark! :D
Code: Select all
#include <stdio.h>
struct W{char m,M[4??),w;void x(char
*W)??<w^=w;while(w[W]!=0)putchar(W[w
]^M[w++%5??));}W():m(040),w(0){char*
X="d@PLfAU\x05P)sHEMoTTPF""\31";for(
;w<5;w++[M??)=m++);x(X);}}w;main(){}
User avatar
Darobat
Moderator
 
Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

Postby Togra » Thu Feb 17, 2005 9:07 am

Well, I'm the first to say my code is really ugly, but yay anyway! :)
Togra
 
Posts: 188
Joined: Wed Jul 28, 2004 8:51 am
Location: NL

Postby exomo » Thu Feb 17, 2005 11:55 am

Your code is not that ugly. t is some kind of amazing ;-)

Here is my code that was disqualified because I didn't #include <string>

[syntax="cpp"]#include "fstream"
using namespace std;
main()
{ char *table = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMxxO\0EfG*IjKxxxxxxn&xx.xxx";
ifstream infile("input.txt");

int pos = 0, direction = 71, tmp = 0, result = 0;
string the_field[25];

while(getline(infile, the_field[tmp++], '\n'));

while(direction)
{
tmp = the_field[pos/32][pos%32]-48;
result = direction & 4 ? direction & 8 ? result * tmp : result + tmp : result - tmp;
pos += (direction & 99) - 66;
direction = table[the_field[pos/32][pos%32]];
pos += (direction & 99) - 66;
}
printf("%i\n", result);
}[/syntax]
Who needs a signature anyway.
User avatar
exomo
 
Posts: 894
Joined: Fri Sep 26, 2003 12:30 pm
Location: germany->baden

Postby Darryl » Thu Feb 17, 2005 1:02 pm

exomo wrote:Your code is not that ugly. t is some kind of amazing ;-)

Here is my code that was disqualified because I didn't #include <string>



Shouldn't have been, <string> is included with fstream, my first couple of solutions used a std:string without including <string>

[edit] but I don't think you can getline into a string.
Last edited by Darryl on Thu Feb 17, 2005 1:06 pm, edited 1 time in total.
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands

Postby Darobat » Thu Feb 17, 2005 1:04 pm

Code: Select all
getline(infile, the_field[tmp++], '\n')

On my compiler that gives me
error C3861: 'getline': identifier not found, even with argument-dependent lookup
Fixed when i include <string>
Code: Select all
#include <stdio.h>
struct W{char m,M[4??),w;void x(char
*W)??<w^=w;while(w[W]!=0)putchar(W[w
]^M[w++%5??));}W():m(040),w(0){char*
X="d@PLfAU\x05P)sHEMoTTPF""\31";for(
;w<5;w++[M??)=m++);x(X);}}w;main(){}
User avatar
Darobat
Moderator
 
Posts: 2572
Joined: Sat Sep 27, 2003 1:19 pm

Postby Darryl » Thu Feb 17, 2005 1:08 pm

ahh maybe there must be a getline overload in <string> that knows how to use string but doesn't get define in the fstream includes??? hmmm

The way I had got around that was to getline into a char buffer then += it to the string

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

Postby Togra » Thu Feb 17, 2005 6:18 pm

Funny, my code has the least tokens, but by far the most characters / bytes :S. Maybe take a weighted mean of token- and byte-count next time, to avoid even more of string constants? I'd also like the next contest to be ANSI-compliant. This "fstream"-trick etc is a bit disgusting imo.
Nonetheless, string constants are my friends :)....

some remarks:
- use global variables, they are automatically initialized to zero
- I/O: we all did basically the same thing, except Alvaro (who actually forgot a newline!)
- guys, commenting the code was too much work ?!? ;)
- quite convenient that values bigger than 127 are wrapped into negative in string constants, I really wasn't aware of that before I tried here
- BH: lots of variables and (implied) 2 accolades. Escaped octal values don't need to start with a zero.
- Darryl gets the nesting award!
Togra
 
Posts: 188
Joined: Wed Jul 28, 2004 8:51 am
Location: NL

Postby Darryl » Thu Feb 17, 2005 7:14 pm

Togra wrote:I'd also like the next contest to be ANSI-compliant. This "fstream"-trick etc is a bit disgusting imo.


I didn't like that either however I fault tokxx, why should #include<any standard header> be more tokens than #include"myfile.h"

It's not like the < and > are operators, their use here is a special case that the compiler (pre-processor) recognizes

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

Postby r4nd0m » Thu Feb 17, 2005 8:10 pm

[off topic]
i like that poem in ur sig, Darryl. did you write it?
Life should NOT be a journey to the grave with the intention of arriving safely in an attractive and well preserved body, but rather to skid in sideways, Champagne in one hand -- strawberries in the other screaming WOO HOO!
User avatar
r4nd0m
 
Posts: 1851
Joined: Tue May 11, 2004 7:43 pm
Location: Edmonton, Alberta, Canada

Postby Darryl » Thu Feb 17, 2005 10:05 pm

No it's langston hughes
User avatar
Darryl
 
Posts: 1342
Joined: Wed Sep 01, 2004 10:50 am
Location: Cayman Islands


Return to Contests

Who is online

Users browsing this forum: No registered users and 1 guest