(* 13_02 *)

(* Require XMLgen_MC.nb ver >=0.04 *)
SetDirectory[NotebookDirectory[]];
<<XMLgenMC.mx;
TTS[mt_]:=ToString[TeXForm[StandardForm[mt]]];
TOT[mt_]:=ToString[OneLineTeXForm[mt]];
TOTT[mt_]:=ToString[OneLineTeXForm[Transpose[mt]]];
TOC[mt_,c_]:=TOTT[{Transpose[mt][[c]]}];
TTD[r_]:=StringReplace[TT[r],"\\frac"->"\\dfrac"];
Rnz[m_]:=(RandomInteger[m]+1)*(2*RandomInteger[1]-1); (* \\pm 1,\pm2,...,\pm(m+1) *)
Rpos[m_]:=RandomInteger[m]+1; (* 1,2,...,m+1 *)
Rbtw[m_]:=RandomInteger[2m]-m;
TTC[A_,n_]:=TOTT[{(Transpose[A])[[n]]}];
Col[A_,n_]:=Transpose[{A[[Range[Length[A]],n]]}];
ColCat[CL_]:=Join@@@(Transpose@CL);
RowCat[CL_]:=Join@@(CL);
PtString[M_]:=StringReplace[ToString[M],{"{"->"(","}"->")"}];
ai2tex[s_]:=StringReplace[TOT[s],Table["\\text{a"<>TOT[i]<>"}"->"{\\mathbf a}_"<>TOT[i],{i,1,5}]];
TpStr[L_]:="\\("<>TOT[L[[1]]]<>"\\times"<>TOT[L[[2]]]<>"\\)";
TpTpse[L_]:=If[L=={},{},{L[[2]],L[[1]]}];
PType[A_,B_]:=If[A=={}||B=={},Return[{}],
If[A[[2]]===B[[1]],Return[{A[[1]],B[[2]]}],Return[{}]]];
PTypeL[L_]:=Module[{ct,len,tmp},len=Length[L];
Which[len==0,Return[{}],len==1,Return[L[[1]]],
len==2,Return[PType[L[[1]],L[[2]]]],
True,tmp=L[[1]];For[ct=2,ct≤len,ct++,tmp=PType[tmp,L[[ct]]]];Return[tmp]]];
Title="R^2の1次変換による平面の像";
SELNUM=6;NUM=200;

(* select pairs of matrices *)
We1={{1},{0}};We2={{0},{1}};
QtList={}; For[ct=1,ct≤300,ct++,
Cn=RandomChoice[{2,2,3,3,3,3,4}];
QtList=Append[QtList,{Cn}]];
(* QtList=DeleteDuplicates[QtList]; *)
QtList=RandomSample[QtList,NUM];Length[QtList]

Clear[QtextF];QtextF[mm_]:=Module[{Cn},
{Cn}=QtList[[mm]];
Return["次の行列で定まる平面の1次変換のうち, 平面全体の像(写り先全体)が平面全体になるものを選びなさい."]];

For[ct=1,ct≤200,ct++,QtextF[ct]]

CListF[mm_]:=Module[{Cn,MA,ct,fs,tmpL={},ret={}},
{Cn}=QtList[[mm]];fs="正解です.";
While[Length[tmpL]≤Cn,
MA=Table[Table[Rnz[3],2],2];
While[Det[MA]==0,MA=Table[Table[Rnz[3],2],2]];tmpL=Append[tmpL,MA];tmpL=DeleteDuplicates[tmpL]];
For[ct=1,ct≤Length[tmpL],ct++,ret=Append[ret,{"\\("<>TOT[tmpL[[ct]]]<>"\\)",fs}]];
Return[RandomSample[ret,Cn]]];

CListF[17]

ICListF[mm_]:=Module[{Cn,MA,tmpL={},ct,fs1,fs2,a,b,ret={}},
{Cn}=QtList[[mm]];
fs1[a_,b_]:="平面を直線\\("<>TOT[a*x+b*y]<>"=0\\)に写します.";
fs2="全平面を(0,0)一点に写します.";
For[ct=1,ct≤5,ct++,
MA=Transpose[{Table[Rnz[2],2]}].{Table[Rnz[2],2]};
{a,b}={-MA[[2,1]],MA[[1,1]]};
{a,b}={a,b}/GCD[a,b];
ret=Append[ret,{"\\("<>TOT[MA]<>"\\)",fs1[a,b]}];
ret=DeleteDuplicates[ret]];
ret=RandomSample[ret,SELNUM-Cn-1];
ret=Append[ret,{"\\("<>TOT[Table[Table[0,2],2]]<>"\\)",fs2}];
Return[ret]];

GenerateMCxml[DFname[],"LA/13-02."<>Title<>"(MC1)",Title,NUM,"false",QtextF,CListF,ICListF]

ICListF[3]

Permutations[{1,2,3,4},{2}] /. Permutations[{1,2,3},{2}]Nothing

#->Nothing &/@ Permutations[{1,2,3},{2}]

sz=3;ToExpression[Table["a"<>TOT[j],{j,1,sz}]]

ColCat[{{{1,2},{2,3}},{{5},{7}}}]

RowCat[{{{1,2,3},{3,3,5}},{{4,4,4}}}]

Permutations[{1,2,3},{2}]

{1,2}@@{1,2,3,4,5}

? Apply

{a,b,c,d,e}[[{3,5}]]

?

StringJoin[{"a","c"}]

? Nothing

Transpose[{Table[Rnz[2],2]}].{Table[Rnz[2],2]}