# Is this a winning *Frustration* configuration?

Frustration is a solitaire card game which is played by calling out the sequence:

“Ace”, “Two”, “Three”, ... , "Nine", "Ten", “Jack”, “Queen”, “King”, “Ace”, “Two”, etc.

With each call, you simultaneously flip over a card from a shuffled deck of 52 cards. You win the game if you get through the entire deck without ever calling out the rank of the card being flipped over.

### Challenge

Given a string or list of characters representing an ordered deck of cards, return "Truthy" if the deck is a winning Frustration configuration, and return "Falsy" otherwise

### Input

Input will be a single string (or a list of characters, or a list of codepoints) consisting solely of the following 13 characters (you may choose to take the letters as uppercase or lowercase):

A 2 3 4 5 6 7 8 9 T J Q K


Each character will be repeated 4 times in the input. An example of a valid input is:

A23456789TJQKA23456789TJQKA23456789TJQKA23456789TJQK


You may assume that the input is always valid (ie. it will contain exactly 52 characters and the 13 characters mentioned above will be repeated exactly 4 times each)

### Output

Output one of two distinct "Truthy" and "Falsy" values. The values you choose must be consistent (ie. different "Truthy" inputs must produce the same "Truthy" output and different "Falsy" inputs must produce the same "Falsy" output)

### Examples

The input KA23456789TJQKA23456789TJQKA23456789TJQKA23456789TJQ would be a winning Frustration configuration (hence a "Truthy" input) because none of the cards in the sequence match the name called out when flipping that card over.

The input 2K3A456789TJQKA23456789TJQKA23456789TJQKA23456789TJQ would not be a winning Frustration configuration (hence a "Falsy" input) because the 3rd card flipped over matches the name called out when flipping it (3).

### Test Cases (one per line)

Truthy

KA23456789TJQKA23456789TJQKA23456789TJQKA23456789TJQ
2A2A2AKQKQK3Q456789345678934567893456789A2JJJJTQKTTT
KQJT98675432AKQJT98675432AKQJT98675432AKQJT98675432A
55667987TAQK8TAQK8TAQK8TAQK325476979965432JJJJ234234
JAK3TTJAK3TT33KAA2456789456789456789222456789JJQQQKQ


Falsy

A23456789TJQKA23456789TJQKA23456789TJQKA23456789TJQK
2A2A2AKQKQKQ3456789345678934567893456789A2JJJJTQKTTT
KQJT98765432AKQJT98765432AKQJT98765432AKQJT98765432A
8TAQK8TAQK8TAQK8TAQK234567999765432JJJJ2342345566797
JAK3TTJAK3TT33KAA2456789456789456789222456789JJQQQQK


### Scoring

This is . Shortest answer in bytes wins

• @KevinCruijssen Yes, that's fine – math junkie Apr 28 at 14:28

# Python 2, 45 42 bytes

-5 bytes thanks to @ovs

lambda s:all(map(cmp,s,'A23456789TJQK'*4))


Try it online!

• Can you use all instead of 0not in ? – ovs Apr 24 at 22:21
• Thanks for the tip! I've never thought of using all for integers. – dingledooper Apr 24 at 22:27

# Perl 5 -p, 29 bytes

$_^="A23456789TJQK"x4;$_=/\0/


Try it online!

Perl allows XOR on strings, how awesome is that?!

• -p means that the language is perl 5 -p. The add bytes to your score is an old rule that has been superseded. – S.S. Anne Apr 25 at 20:20
• thanks for that, for anyone else wanting a reference to the rule, i found it here: codegolf.meta.stackexchange.com/questions/14337/… – Jarmex Apr 25 at 20:56

# Bash + Core utilities, 48 bytes

egrep "echo $$[^A ][^{{2..9},T,J,Q,K} ]$${4}"



Try the test cases online!

Input is on stdin.

Output is the exit code: 0 for truthy, 1 for falsy.

# Jelly, 14 bytes

QṢ“ṡ=2E’œ?ṁn⁸Ạ


A monadic Link accepting a list of characters which yields 0 or 1.

Try it online!

### How?

QṢ“ṡ=2E’œ?ṁn⁸Ạ - Link: list of characters, D
Q              - de-duplicate D
Ṣ             - sort
“ṡ=2E’       - base 250 integer = 3,832,012,820
œ?     - nth permutation
ṁ    - mould like (D)
n   - not equal? (vectorises):
⁸  -   chain's left argument, D
Ạ - all?

• Does nth permutation require sorting? – my pronoun is monicareinstate Apr 25 at 5:57
• We need to sort before applying it as the right argument defines the 1st permutation. "Permutation at index x of the items in y (where y defines the sort order of those items)." – Jonathan Allan Apr 25 at 15:22

and.zipWith(/=)(cycle"A23456789TJQK")


Try it online!

# 05AB1E, 19 bytes

-2 bytes thanks to EdgyNerd,

-1 byte thanks to Grimmy.

'A8L>"TJQK"JJ4×ø€Ëà


Try it online!

• And I've asked OP if lowercase input is allowed, in which case 'A8L>"TJQK"JJ could be 8L>J.•§®т•«Á (if not, an additional u is required and it's the same byte-count for this first part). Also @petStorm, you might want to mention you inverted the truthy/falsey in your output.. – Kevin Cruijssen Apr 28 at 6:53
• OP confirmed that taking the input as lowercase is allowed, so here is 17: 8L>J.•§®т•«ÁÞø€Ëà (still outputs 0 for truthy; 1 for falsey). – Kevin Cruijssen Apr 28 at 14:39

# Retina 0.8.2, 57 bytes

([^A][^2][^3][^4][^5][^6][^7][^8][^9][^T][^J][^Q][^K]){4}


Try it online! Link includes test cases. Explanation: Simply matches a string of 52 bytes that doesn't match the specified character at each given position.

# Wolfram Language (Mathematica), 58 bytes

Inner[Equal,#,Characters[#<>#<>#<>#&@"A23456789TJQK"],Or]&


Try it online! Pure function. Takes a list of characters as input and returns True or False as output. Note that this function checks for losing configurations (since Equal and Or are shorter than Unequal and And), so False is the truthy value and True is the falsey value.

## JavaScript (ES6), 48 bytes

With the input being a string:
t=>![...t].some((v,i)=>"A23456789TJQK"[i%13]==v)

With the input as an array of char it's down to 43 bytes:
t=>!t.some((v,i)=>"A23456789TJQK"[i%13]==v)

var f=
t=>![...t].some((v,i)=>"A23456789TJQK"[i%13]==v);

[
"KA23456789TJQKA23456789TJQKA23456789TJQKA23456789TJQ",
"2A2A2AKQKQK3Q456789345678934567893456789A2JJJJTQKTTT",
"KQJT98675432AKQJT98675432AKQJT98675432AKQJT98675432A",
"55667987TAQK8TAQK8TAQK8TAQK325476979965432JJJJ234234",
"JAK3TTJAK3TT33KAA2456789456789456789222456789JJQQQKQ"
].map(v=>console.log(v,f(v)));

[
"A23456789TJQKA23456789TJQKA23456789TJQKA23456789TJQK",
"2A2A2AKQKQKQ3456789345678934567893456789A2JJJJTQKTTT",
"KQJT98765432AKQJT98765432AKQJT98765432AKQJT98765432A",
"8TAQK8TAQK8TAQK8TAQK234567999765432JJJJ2342345566797",
"JAK3TTJAK3TT33KAA2456789456789456789222456789JJQQQQK"
].map(v=>console.log(v,f(v)));

s->s.matches("A23456789TJQK".repeat(4).replaceAll(".","[^$0]"))  Try it online! # APL (Dyalog Unicode), 44 bytesSBCS {A T J Q K←10+¯9 0 1 2 3⋄~∨/(13|⍳52)=13|⍎¨⍵}  Try it online! # Charcoal, 19 bytes ⬤θ¬⁼ι§⁺⪫…²χωTJQKA⊖κ  Try it online! Link is to verbose version of code. Outputs a Charcoal boolean; - for truthy, nothing for falsy. Explanation:  θ Input string ⬤ All characters satisfy ι Current character ¬⁼ Not equal to …²χ Digits from 2 to 9 ⪫ ω Joined together ⁺ TJQKA Suffixed with picture cards § Indexed by ⊖κ Current index incremented  # Perl 5, 36 bytes sub f{('A23456789TJQK'x4^pop)!~/\0/}  Try it online! 'A23456789TJQK' x 4 results in the 52 byte string of A23456789TJQK repeated four times. This string is bitwise XOR-ed (operator ^) by the equal length input string from pop. Any equal byte (char) at the same positions in the two strings results in a null-byte from xor. And !~ (not regex-match) returns true if no null-byte \0 exists. Otherwise false. # C (gcc), 64 bytes i;f(char*s){for(i=0;i<52&&s[i]-"A23456789TJQK"[i++%13];);i-=52;}  Outputs zero for truthy and non-zero for falsy. Try it online! # J, 26 bytes 1 e.(52$'A23456789TJQK')&=


Try it online!

0 is truthy, 1 is falsy.

Straightforward as possible, posted mostly as a straw man because I thought it was interesting that there didn't seem to be a trick to compress 'A23456789TJQK' that was shorter than the literal.

# Pyth, 24 20 bytes

!sqV*X1"ATJQK"jkr2T4


Try it online!

• X1"ATJQK"jkr2T Construct the string "A23456789TJQK". Inserting the range 2-9 at position 1 of "ATJQK" is one byte shorter than using the full string literal

• * ... 4 Duplicate that string 4 times

• V Vectorize the above string and the input string as inputs to the following function:

• q (arg1) == (arg2)
• !s Return true if the result sums to 0 (ie. none of the cards from the input match the above string)