Skip to main content
Commonmark migration
Source Link

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.

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.

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.
added 10 characters in body
Source Link
AlexRacer
  • 1k
  • 1
  • 6
  • 11

Pascal (FPC), 223 216 210210 209 bytes

var a,b:char;c:set of byte;i:byte;begin repeat readln(a,b);i:=pos(b,'HDC')*14+pos(a,'23456789TJQK');c:=c+[i];if a='A'then c:=c+[i+13]until eof;i:=0;while(i mod 14>9)or(not([i..i+4]<=c)or(i mod 14>9)do i:=i+1;write(i<52)end.

Try it online!Try it online!

Uses T for 10. Input contains 1 card per line.

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.

Pascal (FPC), 223 216 210 bytes

var a,b:char;c:set of byte;i:byte;begin repeat readln(a,b);i:=pos(b,'HDC')*14+pos(a,'23456789TJQK');c:=c+[i];if a='A'then c:=c+[i+13]until eof;i:=0;while(i mod 14>9)or(not([i..i+4]<=c))do i:=i+1;write(i<52)end.

Try it online!

Uses T for 10. Input contains 1 card per line.

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.

Pascal (FPC), 223 216 210 209 bytes

var a,b:char;c:set of byte;i:byte;begin repeat readln(a,b);i:=pos(b,'HDC')*14+pos(a,'23456789TJQK');c:=c+[i];if a='A'then c:=c+[i+13]until eof;i:=0;while not([i..i+4]<=c)or(i mod 14>9)do i:=i+1;write(i<52)end.

Try it online!

Uses T for 10. Input contains 1 card per line.

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.

added 65 characters in body
Source Link
AlexRacer
  • 1k
  • 1
  • 6
  • 11

Pascal (FPC), 223 216216 210 bytes

var a,b:char;c:set of byte;i:byte;begin repeat readln(a,b);i:=pos(b,'HDC')*14+pos(a,'23456789TJQK');c:=c+[i];if a='A'then c:=c+[i+13]until eof;for ieof;i:=0to 52do if=0;while(i mod 14<1014>9)andor(not([i..i+4]<=c)then)do break;writei:=i+1;write(i<52)end.

Try it online!Try it online!

Uses T for 10. Input contains 1 card per line.

##ExplanationNow 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; for ii:=0to 52do //iterate through the set=0; ifwhile not( ([i..i+4]<=c)  //test ifif NOT 5 cards in a row are present... and(i mod 14<10)then break;   //andwhile 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 isn'tis a straight flush, i is left with the last value of starting at the loopcard corresponding to i //(if there isisn't a straight flush, i is lower (the lowest card isstops at the number252 due to i..i+4, I don't know why) end.

Pascal (FPC), 223 216 bytes

var a,b:char;c:set of byte;i:byte;begin repeat readln(a,b);i:=pos(b,'HDC')*14+pos(a,'23456789TJQK');c:=c+[i];if a='A'then c:=c+[i+13]until eof;for i:=0to 52do if(i mod 14<10)and([i..i+4]<=c)then break;write(i<52)end.

Try it online!

Uses T for 10. Input contains 1 card per line.

##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; for i:=0to 52do //iterate through the set if([i..i+4]<=c)  //test if 5 cards in a row are present... and(i mod 14<10)then break; //and the check is started from 10 (T) //(otherwise, it is checking across 2 different suits) write(i<52) //if there isn't straight flush, i is left with the last value of the loop //if there is, i is lower (the lowest card is at the number i) end.

Pascal (FPC), 223 216 210 bytes

var a,b:char;c:set of byte;i:byte;begin repeat readln(a,b);i:=pos(b,'HDC')*14+pos(a,'23456789TJQK');c:=c+[i];if a='A'then c:=c+[i+13]until eof;i:=0;while(i mod 14>9)or(not([i..i+4]<=c))do i:=i+1;write(i<52)end.

Try it online!

Uses T for 10. Input contains 1 card per line.

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.

added 1268 characters in body
Source Link
AlexRacer
  • 1k
  • 1
  • 6
  • 11
Loading
Source Link
AlexRacer
  • 1k
  • 1
  • 6
  • 11
Loading