Now I golfed it so much that I don't know how it works anymore... ##Explanation: var a,b:char; //for reading cards c:set of byte; //this set is for remembering which cards are present in the input //14 numbers used for each suit i:byte; begin repeat readln(a,b); //read rank into a, suit into b and a newline i:=pos(b,'HDC')*14+pos(a,'23456789TJQK'); //temporary use i to calculate corresponding number for the card //pos() gives 0 if b is not found //1st pos() is for the group of numbers for that suit, 2nd pos() is for offset c:=c+[i]; //include i into set if a='A'then c:=c+[i+13] //if rank is A, include the number at the end of group as well until eof; i:=0; while not( ([i..i+4]<=c) //if NOT 5 cards in a row are present... and //while the check is started from 10 (T)... (i mod 14<10) //(otherwise, it is checking across 2 different suits) )do i:=i+1; //increment i, otherwise stop write(i<52) //if i<=51, there is a straight flush starting at the card corresponding to i //(if there isn't a straight flush, i stops at 252 due to i..i+4, I don't know why) end.
Explanation:
var a,b:char; //for reading cards
c:set of byte; //this set is for remembering which cards are present in the input
//14 numbers used for each suit
i:byte;
begin
repeat
readln(a,b); //read rank into a, suit into b and a newline
i:=pos(b,'HDC')*14+pos(a,'23456789TJQK');
//temporary use i to calculate corresponding number for the card
//pos() gives 0 if b is not found
//1st pos() is for the group of numbers for that suit, 2nd pos() is for offset
c:=c+[i]; //include i into set
if a='A'then c:=c+[i+13] //if rank is A, include the number at the end of group as well
until eof;
i:=0;
while not(
([i..i+4]<=c) //if NOT 5 cards in a row are present...
and //while the check is started from 10 (T)...
(i mod 14<10) //(otherwise, it is checking across 2 different suits)
)do i:=i+1; //increment i, otherwise stop
write(i<52) //if i<=51, there is a straight flush starting at the card corresponding to i
//(if there isn't a straight flush, i stops at 252 due to i..i+4, I don't know why)
end.