昨日、私はそれを見て、いくつかの文字が他の文字の中に収まることに気付きました。例:文字 R
が入る場所に P
という文字が収まります。だから、簡単な挑戦です:二つの文字を与え、文字のうちのいずれかが他のものの中に入るならば真理値を返します(直接的または回転的ですが反転しない)、そうでなければ偽の値を返します。つまり、入力が
[P、R]
または [R、P]
である場合、どちらの文字ももう一方の内部に収まるので真実を返す必要があります。あなたが [L、U]
を取得した場合、どちらも他のものの中に収まらないので、あなたは偽を返す必要があります。
ルール
- The input must be two alphanumeric characters in the range
[0-9A-Z], as there are also numbers in the mat, in any form you
need (two separate chars as two inputs, a list with two chars, a
string with the 2 chars, whatever). - The output must be consistent (the truthy and falsey values
must be always the same). -
Following is the table of fittings (note that a letter always
fits in its proper place, just in case you get something like
[Y,Y]
as input):char fits inside chars -------------------------------------------------------- C G,O F B,E,P,R G O I 0,1,7,B,D,E,F,H,K,L,M,N,O,P,R,T,V,W,X,Z L E M W P R S O V A W M 0 O 1 B,E,L 3 O 6 9,O 8 O 9 6,O
I solemnly swear that I have tested every fitting in my kid’s
mat. (Dries his sweat from his forehead.)
This is code-golf,
so may the shortest code for each language win!
いくつかのテストケース
input output
-------------
[C,G] truthy (C fits inside G)
[G,C] truthy (C fits inside G)
[F,R] truthy (F fits inside R)
[M,W] truthy (both fit inside the other)
[O,S] truthy (S fits inside O)
[T,T] truthy (T fits in its place)
[E,V] falsey (no fit found)
[P,L] falsey
Sandbox
post. Please, forgive me if you spot more fittings that I
missed. Many thanks to Οurous
for helping me with the fittings list.
Python 2, 135 130 129
bytes
-1 byte thanks to Lynn
lambda s:cmp(*s)%2*s[::cmp(*s)|1]in'OIH TIE XI7 RF O8 OGC LI0 O3 O96 VA O6 KI PI WI L1 WMI O0 RIB NI1 FE SOC VID ZIFB1 PF LE1 RP'
オンラインで試してみてください!
Python 3, 143 bytes
lambda*i:any({*i}&{a,c}=={*i}for a,b in zip('CFGILMPSVW013689','GO BEPR O 017BDEFHKLMNOPRTVWXZ E W R O A M O BEL O 9O O 6O'.split())for c in b)