{"text": "expon := function(a, n, one, mul)\n\tlocal p;\n\tp := one;\n\twhile n > 0 do\n\t\tif IsOddInt(n) then\n\t\t\tp := mul(a, p);\n\t\tfi;\n\t\ta := mul(a, a);\n\t\tn := QuoInt(n, 2);\n\tod;\n\treturn p;\nend;\n\nexpon(2, 10, 1, \\*);\n# 1024\n\n# a more creative use of exponentiation\nList([0 .. 31], n -> (1 - expon(0, n, 1, \\-))/2);\n# [ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,\n# 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1 ]\n", "meta": {"hexsha": "65a17aa7257dd199e88938d61f8694f7f827ca2f", "size": 403, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Exponentiation-operator/GAP/exponentiation-operator.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Exponentiation-operator/GAP/exponentiation-operator.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Exponentiation-operator/GAP/exponentiation-operator.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 19.1904761905, "max_line_length": 52, "alphanum_fraction": 0.459057072, "num_tokens": 227, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9362850004144265, "lm_q2_score": 0.8499711699569787, "lm_q1q2_score": 0.7958152572154205}} {"text": "FixedPartitions := function(arg)\n\tlocal aux;\n\taux := function(i, u)\n\t\tlocal r, v, w;\n\t\tif i = Size(arg) then\n\t\t\treturn [[u]];\n\t\telse\n\t\t\tr := [ ];\n\t\t\tfor v in Combinations(u, arg[i]) do\n\t\t\t\tfor w in aux(i + 1, Difference(u, v)) do\n\t\t\t\t\tAdd(r, Concatenation([v], w));\n\t\t\t\tod;\n\t\t\tod;\n\t\t\treturn r;\n\t\tfi;\n\tend;\n\treturn aux(1, [1 .. Sum(arg)]);\nend;\n\n\nFixedPartitions(2, 0, 2);\n# [ [ [ 1, 2 ], [ ], [ 3, 4 ] ], [ [ 1, 3 ], [ ], [ 2, 4 ] ],\n# [ [ 1, 4 ], [ ], [ 2, 3 ] ], [ [ 2, 3 ], [ ], [ 1, 4 ] ],\n# [ [ 2, 4 ], [ ], [ 1, 3 ] ], [ [ 3, 4 ], [ ], [ 1, 2 ] ] ]\n\nFixedPartitions(1, 1, 1);\n# [ [ [ 1 ], [ 2 ], [ 3 ] ], [ [ 1 ], [ 3 ], [ 2 ] ], [ [ 2 ], [ 1 ], [ 3 ] ],\n# [ [ 2 ], [ 3 ], [ 1 ] ], [ [ 3 ], [ 1 ], [ 2 ] ], [ [ 3 ], [ 2 ], [ 1 ] ] ]\n", "meta": {"hexsha": "e8741d352c4e9f309e2ae56327456f0db9160544", "size": 751, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Ordered-Partitions/GAP/ordered-partitions.gap", "max_stars_repo_name": "mullikine/RosettaCodeData", "max_stars_repo_head_hexsha": "4f0027c6ce83daa36118ee8b67915a13cd23ab67", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Ordered-Partitions/GAP/ordered-partitions.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Ordered-Partitions/GAP/ordered-partitions.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 25.8965517241, "max_line_length": 79, "alphanum_fraction": 0.3515312916, "num_tokens": 353, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9353465134460243, "lm_q2_score": 0.8459424314825853, "lm_q1q2_score": 0.7912493038632884}} {"text": "# We will compute the sum exactly\n\n# Computing an approximation of a rationnal (giving a string)\n# Value is truncated toward zero\nApprox := function(x, d)\n\tlocal neg, a, b, n, m, s;\n\tif x < 0 then\n\t\tx := -x;\n\t\tneg := true;\n\telse\n\t\tneg := false;\n\tfi;\n\ta := NumeratorRat(x);\n\tb := DenominatorRat(x);\n\tn := QuoInt(a, b);\n\ta := RemInt(a, b);\n\tm := 10^d;\n\ts := \"\";\n\tif neg then\n\t\tAppend(s, \"-\");\n\tfi;\n\tAppend(s, String(n));\n\tn := Size(s) + 1;\n\tAppend(s, String(m + QuoInt(a*m, b)));\n\ts[n] := '.';\n\treturn s;\nend;\n\na := Sum([1 .. 1000], n -> 1/n^2);;\nApprox(a, 10);\n\"1.6439345666\"\n# and pi^2/6 is 1.6449340668, truncated to ten digits\n", "meta": {"hexsha": "00a70a71b6a36a1d1174ada6c7dd5f8ca75a450f", "size": 629, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Sum-of-a-series/GAP/sum-of-a-series.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Sum-of-a-series/GAP/sum-of-a-series.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Sum-of-a-series/GAP/sum-of-a-series.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 19.0606060606, "max_line_length": 61, "alphanum_fraction": 0.573926868, "num_tokens": 228, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284088045171237, "lm_q2_score": 0.849971175657575, "lm_q1q2_score": 0.7891207230662634}} {"text": "DotProduct := function(u, v)\n\treturn u*v;\nend;\n\nCrossProduct := function(u, v)\n\treturn [\n\t\tu[2]*v[3] - u[3]*v[2],\n\t\tu[3]*v[1] - u[1]*v[3],\n\t\tu[1]*v[2] - u[2]*v[1] ];\nend;\n\nScalarTripleProduct := function(u, v, w)\n\treturn DotProduct(u, CrossProduct(v, w));\nend;\n\nVectorTripleProduct := function(u, v, w)\n\treturn CrossProduct(u, CrossProduct(v, w));\nend;\n\na := [3, 4, 5];\nb := [4, 3, 5];\nc := [-5, -12, -13];\n\nDotProduct(a, b);\n# 49\n\nCrossProduct(a, b);\n# [ 5, 5, -7 ]\n\nScalarTripleProduct(a, b, c);\n# 6\n\n# Another way to get it\nDeterminant([a, b, c]);\n# 6\n\nVectorTripleProduct(a, b, c);\n# [ -267, 204, -3 ]\n", "meta": {"hexsha": "e04b4bc7f86ec59e0af2eff4551a7352c7abcf8c", "size": 606, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Vector-products/GAP/vector-products.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Vector-products/GAP/vector-products.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Vector-products/GAP/vector-products.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 15.5384615385, "max_line_length": 44, "alphanum_fraction": 0.5693069307, "num_tokens": 242, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9674102580527664, "lm_q2_score": 0.8104789132480439, "lm_q1q2_score": 0.7840656146116158}} {"text": "IsPrimeTrial := function(n)\n local k, m;\n if n < 5 then\n return (n = 2) or (n = 3);\n fi;\n if RemInt(n, 2) = 0 then\n return false;\n fi;\n m := RootInt(n);\n k := 3;\n while k <= m do\n if RemInt(n, k) = 0 then\n return false;\n fi;\n k := k + 2;\n od;\n return true;\nend;\n\nFiltered([1 .. 100], IsPrimeTrial);\n# [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 ]\n", "meta": {"hexsha": "947680283c83614081facce56193101667f63c57", "size": 453, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Primality-by-trial-division/GAP/primality-by-trial-division.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Primality-by-trial-division/GAP/primality-by-trial-division.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Primality-by-trial-division/GAP/primality-by-trial-division.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 20.5909090909, "max_line_length": 100, "alphanum_fraction": 0.472406181, "num_tokens": 205, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9572778073288128, "lm_q2_score": 0.815232489352, "lm_q1q2_score": 0.7804039698700923}} {"text": "# Using parity of binomial coefficients\nSierpinskiTriangle := function(n)\n\tlocal i, j, s, b;\n\tn := 2^n - 1;\n\tb := \" \";\n\twhile Size(b) < n do\n\t\tb := Concatenation(b, b);\n\tod;\n\tfor i in [0 .. n] do\n\t\ts := \"\";\n\t\tfor j in [0 .. i] do\n\t\t\tif IsEvenInt(Binomial(i, j)) then\n\t\t\t\tAppend(s, \" \");\n\t\t\telse\n\t\t\t\tAppend(s, \"* \");\n\t\t\tfi;\n\t\tod;\n\t\tPrint(b{[1 .. n - i]}, s, \"\\n\");\n\tod;\nend;\n\nSierpinskiTriangle(4);\n *\n * *\n * *\n * * * *\n * *\n * * * *\n * * * *\n * * * * * * * *\n * *\n * * * *\n * * * *\n * * * * * * * *\n * * * *\n * * * * * * * *\n * * * * * * * *\n* * * * * * * * * * * * * * * *\n", "meta": {"hexsha": "6be677e3ff2f4ecb228f1f5a0f8d57bef3dcfd8e", "size": 791, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Sierpinski-triangle/GAP/sierpinski-triangle.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Sierpinski-triangle/GAP/sierpinski-triangle.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Sierpinski-triangle/GAP/sierpinski-triangle.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 20.2820512821, "max_line_length": 39, "alphanum_fraction": 0.2629582807, "num_tokens": 273, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9334308165850442, "lm_q2_score": 0.8267117855317474, "lm_q1q2_score": 0.771678257049379}} {"text": "\n#\n# Read(\"~/Workspace/groupsSB/epi/ext.gi\");\n#\n# highest_weight:=[1,1];# A2: corresponding highest weight module is the Lie algebra\n#\n\nL:= SimpleLieAlgebra(type,rank,Rationals);\ncb0:=CanonicalBasis(L);\nV:= HighestWeightModule( L, highest_weight );\nextA:=List([1..Dimension(V)],i->ExteriorPowerOfAlgebraModule( V, i ));\nextA_basis:=List(extA,i->Basis(i));\n\next_e:=function(k,e)\n\tlocal W,extb,result,v;\n W:=extA[k];\n extb:=extA_basis[k];\n\n\tresult:=[];\n\tfor v in extb do\n\t\tAppend(result,[Coefficients(extb,e^v)]);\n\tod;\n\tresult:=TransposedMat(result);\n\treturn result;\nend;\n\nade0:=function(e)\n\tlocal result,v;\n\tresult:=[];\n\tfor v in cb0 do\n\t\tAppend(result,[Coefficients(cb0,e*v)]);\n\tod;\n\tresult:=TransposedMat(result);\n\treturn result;\nend;\n\n\next_root_group:=function(k,index,t)\n\tlocal ee,tmp,result,i;\n\tee:=ext_e(k,cb0[index]);\n\ttmp:=ee;\n\tresult:=tmp^0;\n\ti:=1;\n\twhile Length(Set(Concatenation(tmp)))<>1 do\n\t\tresult:=result+t^i*tmp/Factorial(i);\n\t\ti:=i+1;\n\t\ttmp:=tmp*ee;\n\tod;\n\treturn result;\nend;\n\next_root_nil_degree:=function(k,index)\n\tlocal ee,tmp,i;\n\tee:=ext_e(k,cb0[index]);\n\ttmp:=ee;\n\ti:=1;\n\twhile Length(Set(Concatenation(tmp)))<>1 do\n\t\ti:=i+1;\n\t\ttmp:=tmp*ee;\n\tod;\n\treturn i;\nend;\n\next_lin_comb:=function(k,coeffs)\n\tlocal extAb,result;\n\textAb:=extA_basis[k];\n\tresult:=List([1..Length(extAb)],i->coeffs[i]*extAb[i]);\n\treturn Sum(result);\nend;", "meta": {"hexsha": "64757fc3af886c1ca7db3a3b8a3ceaa953af9f16", "size": 1349, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "epi/ext.gi", "max_stars_repo_name": "iuliansimion/groupsSB", "max_stars_repo_head_hexsha": "db7494e81bb03f76c20fa181e358ba1cc2d28975", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "epi/ext.gi", "max_issues_repo_name": "iuliansimion/groupsSB", "max_issues_repo_head_hexsha": "db7494e81bb03f76c20fa181e358ba1cc2d28975", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "epi/ext.gi", "max_forks_repo_name": "iuliansimion/groupsSB", "max_forks_repo_head_hexsha": "db7494e81bb03f76c20fa181e358ba1cc2d28975", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 19.5507246377, "max_line_length": 84, "alphanum_fraction": 0.6782802076, "num_tokens": 430, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9284087965937712, "lm_q2_score": 0.8311430478583168, "lm_q1q2_score": 0.7716405168594191}} {"text": "PolynomialRegression := function(x, y, n)\n\tlocal a;\n\ta := List([0 .. n], i -> List(x, s -> s^i));\n\treturn TransposedMat((a * TransposedMat(a))^-1 * a * TransposedMat([y]))[1];\nend;\n\nx := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\ny := [1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321];\n\n# Return coefficients in ascending degree order\nPolynomialRegression(x, y, 2);\n# [ 1, 2, 3 ]\n", "meta": {"hexsha": "76a6f155acacd035371d45039c07e5353cf60ca0", "size": 387, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Polynomial-regression/GAP/polynomial-regression.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Polynomial-regression/GAP/polynomial-regression.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Polynomial-regression/GAP/polynomial-regression.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 29.7692307692, "max_line_length": 77, "alphanum_fraction": 0.5478036176, "num_tokens": 172, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES\n\n", "lm_q1_score": 0.959762057376384, "lm_q2_score": 0.803173791645582, "lm_q1q2_score": 0.7708557307005549}} {"text": "# Using built-in functions\nIncr := s -> String(Int(s) + 1);\n\n# Implementing addition\n# (but here 9...9 + 1 = 0...0 since the string length is fixed)\nIncrement := function(s)\n local c, n, carry, digits;\n digits := \"0123456789\";\n n := Length(s);\n carry := true;\n while n > 0 and carry do\n c := Position(digits, s[n]) - 1;\n if carry then\n c := c + 1;\n fi;\n if c > 9 then\n carry := true;\n c := c - 10;\n else\n carry := false;\n fi;\n s[n] := digits[c + 1];\n n := n - 1;\n od;\nend;\n\ns := \"2399\";\nIncrement(s);\ns;\n# \"2400\"\n", "meta": {"hexsha": "f218b178c9dcca110f540aaffd75148144f81e87", "size": 563, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Increment-a-numerical-string/GAP/increment-a-numerical-string.gap", "max_stars_repo_name": "mullikine/RosettaCodeData", "max_stars_repo_head_hexsha": "4f0027c6ce83daa36118ee8b67915a13cd23ab67", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Increment-a-numerical-string/GAP/increment-a-numerical-string.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Increment-a-numerical-string/GAP/increment-a-numerical-string.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 18.1612903226, "max_line_length": 63, "alphanum_fraction": 0.5168738899, "num_tokens": 193, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9273632976542185, "lm_q2_score": 0.8289388019824946, "lm_q1q2_score": 0.7687274209600234}} {"text": "cube := Group([(1, 2, 3, 4)(5, 6, 7, 8), (1, 4, 8, 5)(2, 3, 7, 6)]);\n\nPrint(\"Order(cube) = \", Order(cube), \"\\n\");\n\ndegree := 8;\ncolorings := Filtered(\n Combinations(Cartesian([1..degree], [\"b\", \"w\"]), degree)\n, \\c -> Size(Set(List(c, \\a -> a[1]))) = degree\n);\n\nPrint(\"Size(colorings) = \", Size(colorings), \"\\n\");\n\nOnFunctions := function(omega, g)\n local result;\n result := List(omega, t -> [t[1]^g, t[2]]);\n SortBy(result, t -> t[1]);\n return result;\nend;\n\norbits := Orbits(cube, colorings, OnFunctions);\nPrint(\"Size(orbits) = \", Size(orbits), \"\\n\");\n\nIsFixed := function(omega, g)\n return OnFunctions(omega, g) = omega;\nend;\n\norbitCount := 1/Order(cube) * Sum(List(Elements(cube), \\g -> Size(Filtered(colorings, \\c -> IsFixed(c, g)))));\n\nPrint(\"orbitCount: \", orbitCount, \", #orbits: \", Size(orbits));", "meta": {"hexsha": "0fb14f6c62c7f3954625b5d8e90d307005741350", "size": 809, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "code/Burnside.gap", "max_stars_repo_name": "fifth-postulate/group-theory-with-gap", "max_stars_repo_head_hexsha": "284d4648a982cee696ffe7cb1e31c6942f1d3929", "max_stars_repo_licenses": ["MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "code/Burnside.gap", "max_issues_repo_name": "fifth-postulate/group-theory-with-gap", "max_issues_repo_head_hexsha": "284d4648a982cee696ffe7cb1e31c6942f1d3929", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "code/Burnside.gap", "max_forks_repo_name": "fifth-postulate/group-theory-with-gap", "max_forks_repo_head_hexsha": "284d4648a982cee696ffe7cb1e31c6942f1d3929", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 27.8965517241, "max_line_length": 110, "alphanum_fraction": 0.5883807169, "num_tokens": 283, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9149009642742805, "lm_q2_score": 0.839733963661418, "lm_q1q2_score": 0.7682734130876949}} {"text": "# Built-in function\nDivisorsInt(Factorial(5));\n# [ 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120 ]\n\n# A possible implementation, not suitable to large n\ndiv := n -> Filtered([1 .. n], k -> n mod k = 0);\n\ndiv(Factorial(5));\n# [ 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120 ]\n\n# Another implementation, usable for large n (if n can be factored quickly)\ndiv2 := function(n)\n local f, p;\n f := Collected(FactorsInt(n));\n p := List(f, v -> List([0 .. v[2]], k -> v[1]^k));\n return SortedList(List(Cartesian(p), Product));\nend;\n\ndiv2(Factorial(5));\n# [ 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120 ]\n", "meta": {"hexsha": "cf7fc476271af8af0e5b027f35bb9d7c65cf41c5", "size": 633, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Factors-of-an-integer/GAP/factors-of-an-integer.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Factors-of-an-integer/GAP/factors-of-an-integer.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Factors-of-an-integer/GAP/factors-of-an-integer.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 30.1428571429, "max_line_length": 75, "alphanum_fraction": 0.5718799368, "num_tokens": 287, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9449947132556618, "lm_q2_score": 0.8128673246376009, "lm_q1q2_score": 0.7681553243608066}} {"text": "# Built-in\na := 2988348162058574136915891421498819466320163312926952423791023078876139;\nb := 2351399303373464486466122544523690094744975233415544072992656881240319;\nPowerModInt(a, b, 10^40);\n1527229998585248450016808958343740453059\n\n# Implementation\nPowerModAlt := function(a, n, m)\n local r;\n r := 1;\n while n > 0 do\n if IsOddInt(n) then\n r := RemInt(r*a, m);\n fi;\n n := QuoInt(n, 2);\n a := RemInt(a*a, m);\n od;\n return r;\nend;\n\nPowerModAlt(a, b, 10^40);\n", "meta": {"hexsha": "92d44dd0f694927e7d65a33e2136934b83a8ee0f", "size": 510, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Modular-exponentiation/GAP/modular-exponentiation.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Modular-exponentiation/GAP/modular-exponentiation.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Modular-exponentiation/GAP/modular-exponentiation.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 23.1818181818, "max_line_length": 76, "alphanum_fraction": 0.6549019608, "num_tokens": 183, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9381240194661944, "lm_q2_score": 0.817574471748733, "lm_q1q2_score": 0.7669862496498719}} {"text": "Ackermann := function( m, n )\n \n if m = 0 then\n return n + 1;\n elif m > 0 and n = 0 then\n return Ackermann( m - 1, 1 );\n fi;\n\n return Ackermann( m - 1, Ackermann( m, n - 1 ) );\n\nend;\n\n\n", "meta": {"hexsha": "5271b81da2647aac8a5495f107013546977489e1", "size": 200, "ext": "gi", "lang": "GAP", "max_stars_repo_path": "Ackermann/GAP/sebasguts/Ackermann.gi", "max_stars_repo_name": "Mynogs/Algorithm-Implementations", "max_stars_repo_head_hexsha": "13a74821fc1f0f7becaa9fb63b98e94134936bdb", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1184, "max_stars_repo_stars_event_min_datetime": "2015-01-01T14:11:29.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T19:40:47.000Z", "max_issues_repo_path": "Ackermann/GAP/sebasguts/Ackermann.gi", "max_issues_repo_name": "Mynogs/Algorithm-Implementations", "max_issues_repo_head_hexsha": "13a74821fc1f0f7becaa9fb63b98e94134936bdb", "max_issues_repo_licenses": ["MIT"], "max_issues_count": 89, "max_issues_repo_issues_event_min_datetime": "2015-01-01T15:49:17.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-05T19:11:38.000Z", "max_forks_repo_path": "Ackermann/GAP/sebasguts/Ackermann.gi", "max_forks_repo_name": "Mynogs/Algorithm-Implementations", "max_forks_repo_head_hexsha": "13a74821fc1f0f7becaa9fb63b98e94134936bdb", "max_forks_repo_licenses": ["MIT"], "max_forks_count": 388, "max_forks_repo_forks_event_min_datetime": "2015-01-02T03:26:17.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-24T14:36:10.000Z", "avg_line_length": 14.2857142857, "max_line_length": 51, "alphanum_fraction": 0.51, "num_tokens": 77, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9381240142763573, "lm_q2_score": 0.8152324826183822, "lm_q1q2_score": 0.7647891691624373}} {"text": "# All of this is built-in\nDerangements([1 .. 4]);\n# [ [ 2, 1, 4, 3 ], [ 2, 3, 4, 1 ], [ 2, 4, 1, 3 ], [ 3, 1, 4, 2 ], [ 3, 4, 1, 2 ], [ 3, 4, 2, 1 ],\n# [ 4, 1, 2, 3 ], [ 4, 3, 1, 2 ], [ 4, 3, 2, 1 ] ]\nSize(last);\n# 9\n\nNrDerangements([1 .. 4]);\n# 9\n\n# An implementation using formula D(n + 1) = n*(D(n) + D(n - 1))\nNrDerangementsAlt_memo := [1, 0];\nNrDerangementsAlt := function(n)\n\tif not IsBound(NrDerangementsAlt_memo[n + 1]) then\n\t\tNrDerangementsAlt_memo[n + 1] := (n - 1)*(NrDerangementsAlt(n - 1) + NrDerangementsAlt(n - 2));\n\tfi;\n\treturn NrDerangementsAlt_memo[n + 1];\nend;\n\nL := List([0 .. 9]);\n\nPrintArray(TransposedMat([L,\n\tList(L, n -> Size(Derangements([1 .. n]))),\n\tList(L, n -> NrDerangements([1 .. n])),\n\tList(L, NrDerangementsAlt)]));\n# [ [ 0, 1, 1, 1 ],\n# [ 1, 0, 0, 0 ],\n# [ 2, 1, 1, 1 ],\n# [ 3, 2, 2, 2 ],\n# [ 4, 9, 9, 9 ],\n# [ 5, 44, 44, 44 ],\n# [ 6, 265, 265, 265 ],\n# [ 7, 1854, 1854, 1854 ],\n# [ 8, 14833, 14833, 14833 ],\n# [ 9, 133496, 133496, 133496 ] ]\n", "meta": {"hexsha": "2d8631fd30b0bc23f3b0d09e436be67de6cd7db7", "size": 1193, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Permutations-Derangements/GAP/permutations-derangements.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Permutations-Derangements/GAP/permutations-derangements.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Permutations-Derangements/GAP/permutations-derangements.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 33.1388888889, "max_line_length": 99, "alphanum_fraction": 0.4224643755, "num_tokens": 543, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9124361652391386, "lm_q2_score": 0.8376199714402812, "lm_q1q2_score": 0.764274754668687}} {"text": "ZigZag := function(n)\n local a, i, j, k;\n a := NullMat(n, n);\n i := 1;\n j := 1;\n for k in [0 .. n*n - 1] do\n a[i][j] := k;\n if (i + j) mod 2 = 0 then\n if j < n then\n j := j + 1;\n else\n i := i + 2;\n fi;\n if i > 1 then\n i := i - 1;\n fi;\n else\n if i < n then\n i := i + 1;\n else\n j := j + 2;\n fi;\n if j > 1 then\n j := j - 1;\n fi;\n fi;\n od;\n return a;\nend;\n\nPrintArray(ZigZag(5));\n# [ [ 0, 1, 5, 6, 14 ],\n# [ 2, 4, 7, 13, 15 ],\n# [ 3, 8, 12, 16, 21 ],\n# [ 9, 11, 17, 20, 22 ],\n# [ 10, 18, 19, 23, 24 ] ]\n", "meta": {"hexsha": "17d58dd2e65285928d47c6bb5f657bad89d4a0ec", "size": 653, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Zig-zag-matrix/GAP/zig-zag-matrix.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Zig-zag-matrix/GAP/zig-zag-matrix.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Zig-zag-matrix/GAP/zig-zag-matrix.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 17.6486486486, "max_line_length": 33, "alphanum_fraction": 0.3185298622, "num_tokens": 314, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9390248242542283, "lm_q2_score": 0.8128673155708976, "lm_q1q2_score": 0.7633025881459685}} {"text": "# Spiral matrix with numbers 1 .. n2, more natural in GAP\nSpiralMatrix := function(n)\n local i, j, k, di, dj, p, vi, vj, imin, imax, jmin, jmax;\n a := NullMat(n, n);\n vi := [ 1, 0, -1, 0 ];\n vj := [ 0, 1, 0, -1 ];\n imin := 0;\n imax := n;\n jmin := 1;\n jmax := n + 1;\n p := 1;\n di := vi[p];\n dj := vj[p];\n i := 1;\n j := 1;\n for k in [1 .. n*n] do\n a[j][i] := k;\n i := i + di;\n j := j + dj;\n if i < imin or i > imax or j < jmin or j > jmax then\n i := i - di;\n j := j - dj;\n p := RemInt(p, 4) + 1;\n di := vi[p];\n dj := vj[p];\n i := i + di;\n j := j + dj;\n if p = 1 then\n imax := imax - 1;\n elif p = 2 then\n jmax := jmax - 1;\n elif p = 3 then\n imin := imin + 1;\n else\n jmin := jmin + 1;\n fi;\n fi;\n od;\n return a;\nend;\n\nPrintArray(SpiralMatrix(5));\n# [ [ 1, 2, 3, 4, 5 ],\n# [ 16, 17, 18, 19, 6 ],\n# [ 15, 24, 25, 20, 7 ],\n# [ 14, 23, 22, 21, 8 ],\n# [ 13, 12, 11, 10, 9 ] ]\n", "meta": {"hexsha": "279eb660a9d1a22f6faec3437cae5798f25d24db", "size": 1038, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Spiral-matrix/GAP/spiral-matrix.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Spiral-matrix/GAP/spiral-matrix.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Spiral-matrix/GAP/spiral-matrix.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 21.625, "max_line_length": 68, "alphanum_fraction": 0.3853564547, "num_tokens": 482, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9304582516374121, "lm_q2_score": 0.8175744850834648, "lm_q1q2_score": 0.760718925974118}} {"text": "# According to section 21.18 of the reference manual, Sort is not stable (it's a Shell sort).\n# However, SortingPerm is stable. We will see it on an example, showing indexes of elements after the sort.\n\nn := 20;\nL := List([1 .. n], i -> Random(\"AB\"));\n# \"AABABBBABBABAABABBAB\"\n\n\np := SortingPerm(L);\n# (3,10,15,17,18,19,9,14,7,13,6,12,16,8,4)(5,11)\n\na := Permuted(L, p);;\nb := Permuted([1 .. n], p);;\n\nPrintArray(TransposedMat(List([1 .. n], i -> [a[i], b[i]])));\n# [ [ 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B' ],\n# [ 1, 2, 4, 8, 11, 13, 14, 16, 19, 3, 5, 6, 7, 9, 10, 12, 15, 17, 18, 20 ] ]\n", "meta": {"hexsha": "3dbf445c4c7a4719896a68910231b734ccffce41", "size": 721, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Sort-stability/GAP/sort-stability.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Sort-stability/GAP/sort-stability.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Sort-stability/GAP/sort-stability.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 40.0555555556, "max_line_length": 128, "alphanum_fraction": 0.4729542302, "num_tokens": 331, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9263037282594921, "lm_q2_score": 0.8198933271118222, "lm_q1q2_score": 0.7594702456787602}} {"text": "QuadraticRoots := function(a, b, c)\n local d;\n d := Sqrt(b*b - 4*a*c);\n return [ (-b+d)/(2*a), (-b-d)/(2*a) ];\nend;\n\n# Hint : E(12) is a 12th primitive root of 1\nQuadraticRoots(2, 2, -1);\n# [ 1/2*E(12)^4-1/2*E(12)^7+1/2*E(12)^8+1/2*E(12)^11,\n# 1/2*E(12)^4+1/2*E(12)^7+1/2*E(12)^8-1/2*E(12)^11 ]\n\n# This works also with floating-point numbers\nQuadraticRoots(2.0, 2.0, -1.0);\n# [ 0.366025, -1.36603 ]\n", "meta": {"hexsha": "d0a390b289c293677555d2dcee7cadb2c06ce960", "size": 404, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Roots-of-a-quadratic-function/GAP/roots-of-a-quadratic-function.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Roots-of-a-quadratic-function/GAP/roots-of-a-quadratic-function.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Roots-of-a-quadratic-function/GAP/roots-of-a-quadratic-function.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 26.9333333333, "max_line_length": 54, "alphanum_fraction": 0.5569306931, "num_tokens": 208, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9653811601648193, "lm_q2_score": 0.7853085884247212, "lm_q1q2_score": 0.7581221161808539}} {"text": "MultiFactorial := function(n, k)\n local r;\n r := 1;\n while n > 1 do\n r := r*n;\n n := n - k;\n od;\n return r;\nend;\n\nPrintArray(List([1 .. 10], n -> List([1 .. 5], k -> MultiFactorial(n, k))));\n[ [ 1, 1, 1, 1, 1 ],\n [ 2, 2, 2, 2, 2 ],\n [ 6, 3, 3, 3, 3 ],\n [ 24, 8, 4, 4, 4 ],\n [ 120, 15, 10, 5, 5 ],\n [ 720, 48, 18, 12, 6 ],\n [ 5040, 105, 28, 21, 14 ],\n [ 40320, 384, 80, 32, 24 ],\n [ 362880, 945, 162, 45, 36 ],\n [ 3628800, 3840, 280, 120, 50 ] ]\n", "meta": {"hexsha": "722892e965ac54aa9a4a4cfa3379ad0bc0442f9e", "size": 781, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Multifactorial/GAP/multifactorial.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Multifactorial/GAP/multifactorial.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Multifactorial/GAP/multifactorial.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 35.5, "max_line_length": 76, "alphanum_fraction": 0.2586427657, "num_tokens": 303, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9489172587090975, "lm_q2_score": 0.7981867849406659, "lm_q1q2_score": 0.7574132159037246}} {"text": "MersenneSmallFactor := function(n)\n local k, m, d;\n if IsPrime(n) then\n d := 2*n;\n m := 1;\n for k in [1 .. 1000000] do\n m := m + d;\n if PowerModInt(2, n, m) = 1 then\n return m;\n fi;\n od;\n fi;\n return fail;\nend;\n\n\n# If n is not prime, fail immediately\nMersenneSmallFactor(15);\n# fail\n\nMersenneSmallFactor(929);\n# 13007\n\nMersenneSmallFactor(1009);\n# 3454817\n\n# We stop at k = 1000000 in 2*k*n + 1, so it may fail if 2^n - 1 has only larger factors\nMersenneSmallFactor(101);\n# fail\n\nFactorsInt(2^101-1);\n# [ 7432339208719, 341117531003194129 ]\n", "meta": {"hexsha": "cafdde74d6cbc17289e5023e7298e1b3f4ecf022", "size": 629, "ext": "gap", "lang": "GAP", "max_stars_repo_path": "Task/Factors-of-a-Mersenne-number/GAP/factors-of-a-mersenne-number.gap", "max_stars_repo_name": "LaudateCorpus1/RosettaCodeData", "max_stars_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_stars_repo_licenses": ["Info-ZIP"], "max_stars_count": 1, "max_stars_repo_stars_event_min_datetime": "2018-11-09T22:08:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-11-09T22:08:38.000Z", "max_issues_repo_path": "Task/Factors-of-a-Mersenne-number/GAP/factors-of-a-mersenne-number.gap", "max_issues_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_issues_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_issues_repo_licenses": ["Info-ZIP"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Task/Factors-of-a-Mersenne-number/GAP/factors-of-a-mersenne-number.gap", "max_forks_repo_name": "seanwallawalla-forks/RosettaCodeData", "max_forks_repo_head_hexsha": "9ad63ea473a958506c041077f1d810c0c7c8c18d", "max_forks_repo_licenses": ["Info-ZIP"], "max_forks_count": 1, "max_forks_repo_forks_event_min_datetime": "2018-11-09T22:08:40.000Z", "max_forks_repo_forks_event_max_datetime": "2018-11-09T22:08:40.000Z", "avg_line_length": 19.0606060606, "max_line_length": 88, "alphanum_fraction": 0.573926868, "num_tokens": 216, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9465966686936262, "lm_q2_score": 0.7931059487389968, "lm_q1q2_score": 0.7507514489974322}}