Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/ABC-problem/Mathematica/abc-problem.math
Normal file
12
Task/ABC-problem/Mathematica/abc-problem.math
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
blocks=Partition[Characters[ToLowerCase["BOXKDQCPNAGTRETGQDFSJWHUVIANOBERFSLYPCZM"]],2];
|
||||
ClearAll[DoStep,ABCBlockQ]
|
||||
DoStep[chars_List,blcks_List,chosen_List]:=Module[{opts},
|
||||
If[chars=!={},
|
||||
opts=Select[blcks,MemberQ[#,First[chars]]&];
|
||||
{Rest[chars],DeleteCases[blcks,#,1,1],Append[chosen,#]}&/@opts
|
||||
,
|
||||
{{chars,blcks,chosen}}
|
||||
]
|
||||
]
|
||||
DoStep[opts_List]:=Flatten[DoStep@@@opts,1]
|
||||
ABCBlockQ[str_String]:=(FixedPoint[DoStep,{{Characters[ToLowerCase[str]],blocks,{}}}]=!={})
|
||||
Loading…
Add table
Add a link
Reference in a new issue