Retourner au contenu associé (journal : Amis matheux, quel générateur d'exercice?)
Posté par tzeentch00 le 31 mai 2012 à 21:45. En réponse au journal Amis matheux, quel générateur d'exercice?. Évalué à 4.
Avec ConTeXt (et LuaTeX), c’est relativement simple. Voilà un exemple vite fait (l’algorithme n’est peut-être pas parfait) :
\startluacode userdata = userdata or {} math.randomseed(os.time()) function userdata.randomx (xmax) return (math.random(3, xmax)) end function userdata.getx() return (x) end function userdata.gety() if x%2 == 1 then return ((x^2 - 1) / 2) else return ((x / 2)^2 - 1) end end function userdata.getz() if x%2 == 1 then return ((x^2 + 1) / 2) else return ((x / 2)^2 + 1) end end \stopluacode \def\randomx#1% {\ctxlua{x = userdata.randomx(#1)}} \def\getx% {\ctxlua{context("\%.0f", userdata.getx())}} \def\gety% {\ctxlua{context("\%.0f", userdata.gety())}} \def\getz% {\ctxlua{context("\%.0f", userdata.getz())}} \starttext \dorecurse{10}{ \randomx{100} \math{x = \getx}\\ \math{y = \gety}\\ \math{z = \getz}\blank[big]} \stoptext
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
# Context MKIV
Posté par tzeentch00 . En réponse au journal Amis matheux, quel générateur d'exercice?. Évalué à 4.
Avec ConTeXt (et LuaTeX), c’est relativement simple. Voilà un exemple vite fait (l’algorithme n’est peut-être pas parfait) :