I could not think of a better title.
This is a tips question. I'm asking for tips on golfing my code.
I recently took part in a code golf competition in C. The competition ended and I lost. The problem is:
Input a line with a number n.
Then input n lines, each line contains only a set of cards in descending order, e. g.
X2AAKKKKQT9765433
orDX22AKKQJTT884443
. Figure out if it containsDX
or four of the same cards in a row.
Obviously, this is a chameleon challenge (finding DX
is essentially the same as checking the second character if it is X
, and to check for four of the same cards you only need to check the first and the last card of the quadruplet, because the cards are in descending order.)
In that competition, the input format is strict, and error-terminating is disallowed.
After the competition, we continued to improve on this problem. We've got this so far (98 bytes):
char*p,s[99];main(){for(gets(s);gets(p=s);puts(s[1]>87?"Yes":"No"))for(;*p;)s[1]|=*p^p++[3]?0:88;}
I'm looking for tips to golf this down further.