1
$\begingroup$

I solved the puzzle of IBM Ponder This September 2019 by my code written with mathematica. I would like to share this code after the solution that will come as soon, and discuss it.

In the meantime, if someone would want to think about the question.

September 2019 - Challenge http://www.research.ibm.com/haifa/ponderthis/challenges/September2019.html

The problem: The US dollar has five common banknote denominations: 1, 5, 10, 20, and 50. Each integer dollar value between 0 and 99 dollars can be paid in a single way with a minimal number of notes.

If Alice and Bob have different amounts of money, they still can have the same set of notes. For example, if Alice has 92 dollars and Bob has 74 dollars (in a minimal number of notes), they both have the same set of banknotes {1,20,50}.

Let's assume that Alice and Bob have two different amounts of money uniformly distributed in the [0.99] range with a minimal number of banknotes. The probability that they are the same set of banknotes is approximately 3.79798%.

Your task, this month, is to find another set of five banknotes such that:

1-Each integer dollar value between 0 and 99 dollars can be paid in a single way with a minimal number of notes; and

2-The probability above (even set of banknotes for two different amounts of money uniformly distributed in the [0.99] range) would be exactly 4%.

My code is divided into 3 parts:

1 Functions.

2 Data.

3 Optimization. Solutions.

$\endgroup$
  • $\begingroup$ a first step: we can get numbers that share the same minimal set of notes using grouped=Select[Length@#>1&]@GroupBy[Range[99],Union@@MinimalBy[Length][ IntegerPartitions[#, All, {1, 5, 10, 20, 50}]]&] $\endgroup$ – kglr Oct 5 at 14:16
  • $\begingroup$ Re "1 - .. the amount of Alice and Bob can be zero": 0 can not be one of two different amounts of money sharing the same set of banknotes. Re 2--3: thank you for your understanding:) $\endgroup$ – kglr Oct 5 at 14:56
  • $\begingroup$ "0 can not be one of two different amounts of money sharing the same set of banknotes". Could you please give me an example. $\endgroup$ – Reda.Kebbaj Oct 6 at 5:49
0
$\begingroup$

Module III : optimization the Challange September October 2019, Probabilty Value of BankNotes selected.

AliceBob = 
 Permutations[Range[0, 99], {2}]; HyBankNotes = 65; BankNote = {}; BankNotes =
  Subsets[Range[2, HyBankNotes], {4}]; BankSave = 
 Select[BankNotes, #1[[1]] == 2 && 4 <= #1[[2]] <= 12 && 
    8 <= #1[[3]] <= 16 &]; c = 1; While[c != Length[BankSave], 
 AppendTo[BankNote, Insert[BankSave[[c]], 1, 1]]; c++]; q1 = 
 q2 = p = {}; S = 0; For[k = 1, k <= Length[BankNote], k++, NSolution1 = 0; 
 Dv = Reverse[BankNote[[k]]]; Dv1 = Reverse[Dv]; 
 For[x = 0, x <= 99, x++, 
  Res = s11 = 
    s12 = s13 = s14 = s15 = s1 = s2 = s3 = s4 = s5 = s16 = s6 = s17 = {}; 
  s7 = s18 = s8 = s19 = s9 = s011 = s01 = s012 = s02 = s014 = s04 = s016 = {};
   s06 = s017 = 
    s07 = s019 = 
      s09 = s0120 = 
        s020 = s0121 = 
          s021 = s0123 = 
            s023 = s0125 = 
              s025 = s0127 = 
                s027 = s0128 = 
                  s028 = s0129 = 
                    s029 = s0130 = 
                    s030 = s0131 = 
                    s031 = s0132 = 
                    s032 = s0133 = s033 = s0134 = s034 = s0135 = s035 = {}; 
  Notes1[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes2[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes3[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes4[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes5[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes7[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes9[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes11[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes12[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes14[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes16[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes17[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes19[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes20[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes21[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes23[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes25[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes27[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes28[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes29[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes30[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes31[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes32[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes33[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes34[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes35[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Sor = SortBy[{s11, s12, s13, s14, s15, s17, s19, s011, s012, s014, s016, 
     s017, s019, s0120, s0121, s0123, s0125, s0127, s0128, s0129, s0130, 
     s0131, s0132, s0133, s0134, s0135}, First]; 
  If[First[First[Sor[[1]]]] == First[First[Sor[[2]]]] && 
    Last[First[Sor[[1]]]] != Last[First[Sor[[2]]]], Goto[begin1]]; 
  Res = Last[First[Sor[[1]]]];
  For[i = 1, i <= 5, i++, If[Res[[i]] > 0, Res[[i]] = 1]]; A[x] = Res]; 
 NSolution1 = Length[Select[AliceBob, A[#1[[1]]] == A[#1[[2]]] &]]; 
 NSolution = NSolution1; AppendTo[p, NSolution]; 
 If[NSolution1 == 396, Goto[begin]]; 
 Label[begin1]]; Label[begin]; t = 3257; q1 = 
 q2 = p = {}; S = 0; g = 0; g1 = {}; g3 = 0; For[k = t, 
 k <= Length[BankNote], k++, NSolution1 = 0; Dv = Reverse[BankNote[[k]]]; 
 For[x = 0, x <= 99, x++, 
  Res = s11 = 
    s12 = s13 = s14 = s15 = s1 = s2 = s3 = s4 = s5 = s16 = s6 = s17 = {}; 
  s7 = s18 = s8 = s19 = s9 = s011 = s01 = s012 = s02 = s014 = s04 = s016 = {};
   s06 = s017 = 
    s07 = s019 = 
      s09 = s0120 = 
        s020 = s0121 = 
          s021 = s0123 = 
            s023 = s0125 = 
              s025 = s0127 = 
                s027 = s0128 = 
                  s028 = s0129 = 
                    s029 = s0130 = 
                    s030 = s0131 = 
                    s031 = s0132 = 
                    s032 = s0133 = s033 = s0134 = s034 = s0135 = s035 = {}; 
  Notes1[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes2[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes3[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes4[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes5[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes7[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes9[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes11[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes12[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes14[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes16[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes17[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes19[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes20[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes21[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes23[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes25[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes27[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes28[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes29[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes30[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes31[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes32[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes33[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes34[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes35[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Sor = SortBy[{s11, s12, s13, s14, s15, s17, s19, s011, s012, s014, s016, 
     s017, s019, s0120, s0121, s0123, s0125, s0127, s0128, s0129, s0130, 
     s0131, s0132, s0133, s0134, s0135}, First]; 
  If[First[First[Sor[[1]]]] == First[First[Sor[[2]]]] && 
    Last[First[Sor[[1]]]] != Last[First[Sor[[2]]]], Goto[begin2]]; 
  Res = Last[First[Sor[[1]]]];
  For[i = 1, i <= 5, i++, If[Res[[i]] > 0, Res[[i]] = 1]]; A[x] = Res]; 
 NSolution1 = Length[Select[AliceBob, A[#1[[1]]] == A[#1[[2]]] &]]; 
 NSolution2 = NSolution1; AppendTo[p, NSolution2]; 
 If[g < (100^2) / (NSolution2 + 100), g = (100^2) / (NSolution2 + 100); 
  g1 = Reverse[Dv]; g3 = NSolution1]; 
 Label[begin2]]; NSolution2 = 9900; Dv = {};
$\endgroup$
0
$\begingroup$

Module 1V : Optimization the Challange September 2019 "Tester" Probabilty Value of one BankNotes selected.

AliceBob = Permutations[Range[0, 99], {2}]; Label[begin]; Bank = 
 DialogInput[{name = {}}, 
  Column[{"BankNotes", InputField[Dynamic[name], String], 
    Button["Proceed", DialogReturn[name], ImageSize -> Automatic]}]]; Bank = 
 Reverse[{ToExpression[
    StringCases[Bank, DigitCharacter ..]]}]; q1 = {}; q2 = {}; S = 0; For[
 k = 1, k <= Length[Bank], k++, Dv = Reverse[Bank[[k]]]; NSolution = 0; 
 For[x = 0, x <= 99, x++, 
  Res = s11 = 
    s12 = s13 = s14 = s15 = s1 = s2 = s3 = s4 = s5 = s16 = s6 = s17 = {}; 
  s7 = s18 = s8 = s19 = s9 = s011 = s01 = s012 = s02 = s014 = s04 = s016 = {};
   s06 = s017 = 
    s07 = s019 = 
      s09 = s0120 = 
        s020 = s0121 = s021 = s0123 = s023 = s0125 = s025 = s0127 = s027 = {};
   s0128 = s028 = 
    s0129 = s029 = 
      s0130 = s030 = 
        s0131 = s031 = 
          s0132 = s032 = s0133 = s033 = s0134 = s034 = s0135 = s035 = {}; 
  Notes1[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes2[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes3[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes4[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes5[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes7[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes9[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes11[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes12[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes14[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes16[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes17[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes19[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes20[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes21[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes23[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes25[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes27[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes28[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes29[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes30[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes31[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes32[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes33[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes34[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Notes35[Dv[[1]], Dv[[2]], Dv[[3]], Dv[[4]], Dv[[5]], x]; 
  Sor = SortBy[{s11, s12, s13, s14, s15, s17, s19, s011, s012, s014, s016, 
     s017, s019, s0120, s0121, s0123, s0125, s0127, s0128, s0129, s0130, 
     s0131, s0132, s0133, s0134, s0135}, First]; 
  If[First[First[Sor[[1]]]] == First[First[Sor[[2]]]] && 
    Last[First[Sor[[1]]]] != Last[First[Sor[[2]]]], 
   If[ChoiceDialog[" Solution:" Indeterminet] == True, Goto[begin], 
    Goto[end]]]; Res = Last[First[Sor[[1]]]];
  For[i = 1, i <= 5, i++, If[Res[[i]] > 0, Res[[i]] = 1]]; A[x] = Res]; 
 NSolution = Length[Select[AliceBob, A[#1[[1]]] == A[#1[[2]]] &]];]; If[
 ChoiceDialog[" Solution:"  N[NSolution/9900*100] "%"] == True, 
 Goto[begin]]; Label[end];
$\endgroup$
0
$\begingroup$

Module II "Screen Monitor to show progress value" : optimization the Challange IBM Ponder this September / October 2019 Probabilty Value of BankNotes .

g1 = {}; g = ""; g3 = 0; NSolution2 = 9900; {Solution September, 
 DynamicModule[{s = {{5, 30}, {1, Infinity}}}, 
  Deploy[Style[
    Panel[Grid[
      Transpose[{{Style["Solution Banknotes", Red], 
         Style["Probability : ", Red], "Quantiy of Solution", "", 
         ""}, {InputField[Dynamic[Dv1]], 
         InputField[Dynamic[N[NSolution/9900*100, 4]], Number, Enabled ->
           False], InputField[Dynamic[NSolution], Enabled -> False], 
         InputField[Dynamic[" "], Enabled ->
           False], InputField[Dynamic[""], Enabled -> False]}}], 
      Alignment -> Right], ImageMargins -> 10], 
    DefaultOptions -> {InputField -> {ContinuousAction -> True, 
        FieldSize -> s}}]]], "... Graph...", 
 Dynamic[ListPlot[p]], "... October Solution ...", 
 DynamicModule[{a = 0, b = 0, s = {{5, 30}, {1, Infinity}}}, 
  Deploy[Style[
    Panel[Grid[
      Transpose[{{Style["Solution Banknotes Max", Red], 
         Style["Max Probability : ", Red], 
         Style["Max Quantiy of Solution", Red], " Probability ", 
         "Banknotes"}, {InputField[Dynamic[g1]], 
         InputField[Dynamic[N[g, 4]], Number, Enabled ->
           False], InputField[Dynamic[g3], Enabled -> False], 
         InputField[Dynamic[N[100/(NSolution2 + 100)*100]], Enabled ->
           False], InputField[Dynamic[Reverse[Dv]], Enabled -> False]}}], 
      Alignment -> Right], ImageMargins -> 10], 
    DefaultOptions -> {InputField -> {ContinuousAction -> True, 
        FieldSize -> s}}]]]}

$\endgroup$
0
$\begingroup$

The September question was extended on october 2019:

http://www.research.ibm.com/haifa/ponderthis/challenges/October2019.html:

Let's assume that Alice and Bob have two (possibly the same) integer amounts of money, uniformly distributed in the [0,99] range with a minimal number of banknotes. Using the standard US dollar banknotes denominations of 1, 5, 10, 20, and 50, if the set of notes of Alice and Bob is the same - the probability of the amount being the same is about 21%. Your task, this month, is to find the set of five banknote denominations that uniquely determines the set with the minimal number of notes while maximizing the above probability.

Solution with mathematica:

I made a video to show how the code works: https://www.youtube.com/watch?v=tpwrtEOLm-4

$\endgroup$
0
$\begingroup$

Module 1 "Functions" : The First optimization problem is to find Functions called "Notes1,Notes2... " such that Functions Minimize All the possibility for diffferentes Banknotes. And prepare variables "s11,s12,.s011.." for optimization the Challange in the Second Modules.

Notes1[d01_, d02_, d03_, d04_, d05_, n0p_] := 
 Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
  m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
  While[S != 0, 
   If[S >= d1, S = S - d1; m[1]++, 
    If[S >= d2, S = S - d2; m[2]++, 
     If[S >= d3, S = S - d3; m[3]++, 
      If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]]; 
  For[i = 1, i <= 5, i++, s1 = AppendTo[s1, m[i]]]; 
  AppendTo[s11, {Total[s1] 10^IntegerLength[5 - Count[s1, 0]] - 
     Count[s1, 0] + 5, s1}]]; 
Notes2[d01_, d02_, d03_, d04_, d05_, n0p_] := 
 Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
  m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
  While[S != 0, 
   If[S >= d2, S = S - d2; m[2]++, 
    If[S >= d3, S = S - d3; m[3]++, 
     If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]; 
  For[i = 1, i <= 5, i++, s2 = AppendTo[s2, m[i]]]; 
  AppendTo[s12, {Total[s2] 10^IntegerLength[5 - Count[s2, 0]] - 
     Count[s2, 0] + 5, s2}]]; 
Notes3[d01_, d02_, d03_, d04_, d05_, n0p_] := 
 Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
  m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
  While[S != 0, 
   If[S >= d3, S = S - d3; m[3]++, 
    If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]; 
  For[i = 1, i <= 5, i++, s3 = AppendTo[s3, m[i]]]; 
  AppendTo[s13, {Total[s3] 10^IntegerLength[5 - Count[s3, 0]] - 
     Count[s3, 0] + 5, s3}]]; 
Notes4[d01_, d02_, d03_, d04_, d05_, n0p_] := 
 Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
  m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
  While[S != 0, 
   If[S >= d1, S = S - d1; m[1]++, 
    If[S >= d3, S = S - d3; m[3]++, 
     If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]; 
  For[i = 1, i <= 5, i++, s4 = AppendTo[s4, m[i]]]; 
  AppendTo[s14, {Total[s4] 10^IntegerLength[5 - Count[s4, 0]] - 
     Count[s4, 0] + 5, s4}]]; 
Notes5[d01_, d02_, d03_, d04_, d05_, n0p_] := 
 Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
  m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
  While[S != 0, 
   If[S >= d1, S = S - d1; m[1]++, 
    If[S >= d2, S = S - d2; m[2]++, 
     If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]; 
  For[i = 1, i <= 5, i++, s5 = AppendTo[s5, m[i]]]; 
  AppendTo[s15, {Total[s5] 10^IntegerLength[5 - Count[s5, 0]] - 
     Count[s5, 0] + 5, s5}]]; 
Notes7[d01_, d02_, d03_, d04_, d05_, n0p_] := 
 Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
  m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
  While[S != 0, 
   If[S >= d1, S = S - d1; m[1]++, 
    If[S >= d2, S = S - d2; m[2]++, 
     If[S >= d3, S = S - d3; m[3]++, S = S - d5; m[5]++]]]]; 
  For[i = 1, i <= 5, i++, s7 = AppendTo[s7, m[i]]]; 
  AppendTo[s17, {Total[s7] 10^IntegerLength[5 - Count[s7, 0]] - 
     Count[s1, 0] + 5, s7}]]; 
Notes9[d01_, d02_, d03_, d04_, d05_, n0p_] := 
 Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
  m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
  While[S != 0, 
   If[S >= d1, S = S - d1; m[1]++, 
    If[S >= d2, S = S - d2; m[2]++, S = S - d5; m[5]++]]]; 
  For[i = 1, i <= 5, i++, s9 = AppendTo[s9, m[i]]]; 
  AppendTo[s19, {Total[s9] 10^IntegerLength[5 - Count[s9, 0]] - 
     Count[s9, 0] + 5, s9}]]; 
Notes11[d01_, d02_, d03_, d04_, d05_, n0p_] := 
 Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
  m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
  While[S != 0, 
   If[S >= d1, S = S - d1; m[1]++, 
    If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]; 
  For[i = 1, i <= 5, i++, s01 = AppendTo[s01, m[i]]]; 
  AppendTo[s011, {Total[s01] 10^IntegerLength[5 - Count[s01, 0]] - 
     Count[s01, 0] + 5, s01}]];
Notes12[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, If[S >= d1, S = S - d1; m[1]++, S = S - d5; m[5]++]]; 
   For[i = 1, i <= 5, i++, s02 = AppendTo[s02, m[i]]]; 
   AppendTo[s012, {Total[s02] 10^IntegerLength[5 - Count[s02, 0]] - 
      Count[s02, 0] + 5, s02}]];
Notes14[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, 
    If[S >= d2, S = S - d2; m[2]++, 
     If[S >= d3, S = S - d3; m[3]++, S = S - d5; m[5]++]]]; 
   For[i = 1, i <= 5, i++, s04 = AppendTo[s04, m[i]]]; 
   AppendTo[s014, {Total[s04] 10^IntegerLength[5 - Count[s04, 0]] - 
      Count[s04, 0] + 5, s04}]];
Notes16[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, 
    If[S >= d2, S = S - d2; m[2]++, 
     If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]; 
   For[i = 1, i <= 5, i++, s06 = AppendTo[s06, m[i]]]; 
   AppendTo[s016, {Total[s06] 10^IntegerLength[5 - Count[s06, 0]] - 
      Count[s06, 0] + 5, s06}]];
Notes17[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, If[S >= d2, S = S - d2; m[2]++, S = S - d5; m[5]++]]; 
   For[i = 1, i <= 5, i++, s07 = AppendTo[s07, m[i]]]; 
   AppendTo[s017, {Total[s07] 10^IntegerLength[5 - Count[s07, 0]] - 
      Count[s07, 0] + 5, s07}]];
Notes19[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, 
    If[S >= d3, S = S - d3; m[3]++, 
     If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]; 
   For[i = 1, i <= 5, i++, s09 = AppendTo[s09, m[i]]]; 
   AppendTo[s019, {Total[s09] 10^IntegerLength[5 - Count[s09, 0]] - 
      Count[s09, 0] + 5, s09}]];
Notes20[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]; 
   For[i = 1, i <= 5, i++, s020 = AppendTo[s020, m[i]]]; 
   AppendTo[
    s0120, {Total[s020] 10^IntegerLength[5 - Count[s020, 0]] - 
      Count[s020, 0] + 5, s020}]];
Notes21[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; While[S != 0, S = S - d5; m[5]++]; 
   For[i = 1, i <= 5, i++, s021 = AppendTo[s021, m[i]]]; 
   AppendTo[s0121, {Total[s021] 10^IntegerLength[5 - Count[s021, 0]] - 
      Count[s021, 0] + 5, s021}]];
Notes23[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, If[S >= d3, S = S - d3; m[3]++, S = S - d5; m[5]++]]; 
   For[i = 1, i <= 5, i++, s023 = AppendTo[s023, m[i]]]; 
   AppendTo[s0123, {Total[s023] 10^IntegerLength[5 - Count[s023, 0]] - 
      Count[s023, 0] + 5, s023}]];
Notes25[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]; 
   For[i = 1, i <= 5, i++, s025 = AppendTo[s025, m[i]]]; 
   AppendTo[s0125, {Total[s025] 10^IntegerLength[5 - Count[s025, 0]] - 
      Count[s025, 0] + 5, s025}]];
Notes27[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; While[S != 0, S = S - d5; m[5]++]; 
   For[i = 1, i <= 5, i++, s027 = AppendTo[s027, m[i]]]; 
   AppendTo[s0127, {Total[s027] 10^IntegerLength[5 - Count[s027, 0]] - 
      Count[s027, 0] + 5, s027}]];
Notes28[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, a1 = 0; 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, 
    If[S >= d1 && a1 <= 1, a1 = a1 + 1; If[a1 == 1, S = S - d1; m[1]++], 
     If[S >= d2, S = S - d2; m[2]++, 
      If[S >= d3, S = S - d3; m[3]++, 
       If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]]; 
   For[i = 1, i <= 5, i++, s028 = AppendTo[s028, m[i]]]; 
   AppendTo[s0128, {Total[s028] 10^IntegerLength[5 - Count[s028, 0]] - 
      Count[s028, 0] + 5, s028}]];
Notes29[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, a1 = 0; 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, 
    If[S >= d1 && a1 <= 2, a1 = a1 + 1; 
     If[a1 == 1 || a1 == 2, S = S - d1; m[1]++], 
     If[S >= d2, S = S - d2; m[2]++, 
      If[S >= d3, S = S - d3; m[3]++, 
       If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]]; 
   For[i = 1, i <= 5, i++, s029 = AppendTo[s029, m[i]]]; 
   AppendTo[s0129, {Total[s029] 10^IntegerLength[5 - Count[s029, 0]] - 
      Count[s029, 0] + 5, s029}]];
Notes30[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, a1 = 0; 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, 
    If[S >= d1 && a1 <= 3, a1 = a1 + 1; 
     If[a1 == 1 || a1 == 2 || a1 == 3, S = S - d1; m[1]++], 
     If[S >= d2, S = S - d2; m[2]++, 
      If[S >= d3, S = S - d3; m[3]++, 
       If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]]; 
   For[i = 1, i <= 5, i++, s030 = AppendTo[s030, m[i]]]; 
   AppendTo[s0130, {Total[s030] 10^IntegerLength[5 - Count[s030, 0]] - 
      Count[s030, 0] + 5, s030}]];
Notes31[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, a1 = 0; 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, 
    If[S >= d2 && a1 <= 1, a1 = a1 + 1; If[a1 == 1, S = S - d2; m[2]++], 
     If[S >= d3, S = S - d3; m[3]++, 
      If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]; 
   For[i = 1, i <= 5, i++, s031 = AppendTo[s031, m[i]]]; 
   AppendTo[s0131, {Total[s031] 10^IntegerLength[5 - Count[s031, 0]] - 
      Count[s031, 0] + 5, s031}]];
Notes32[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, a1 = 0; 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, 
    If[S >= d2 && a1 <= 2, a1 = a1 + 1; 
     If[a1 == 1 || a1 == 2, S = S - d2; m[2]++], 
     If[S >= d3, S = S - d3; m[3]++, 
      If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]; 
   For[i = 1, i <= 5, i++, s032 = AppendTo[s032, m[i]]]; 
   AppendTo[s0132, {Total[s032] 10^IntegerLength[5 - Count[s032, 0]] - 
      Count[s032, 0] + 5, s032}]];
Notes33[d01_, d02_, d03_, d04_, d05_, n0p_] := 
  Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, a1 = 0; 
   m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
   While[S != 0, 
    If[S >= d2 && a1 <= 3, a1 = a1 + 1; 
     If[a1 == 1 || a1 == 2 || a1 == 3, S = S - d2; m[2]++], 
     If[S >= d3, S = S - d3; m[3]++, 
      If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]; 
   For[i = 1, i <= 5, i++, s033 = AppendTo[s033, m[i]]]; 
   AppendTo[s0133, {Total[s033] 10^IntegerLength[5 - Count[s033, 0]] - 
      Count[s033, 0] + 5, s033}]];
Notes34[d01_, d02_, d03_, d04_, d05_, n0p_] := 
 Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, a1 = 0; 
  a2 = 0; m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
  While[S != 0, 
   If[S >= d1 && a1 <= 2, a1 = a1 + 1; 
    If[a1 == 1 || a1 == 2, S = S - d1; m[1]++], 
    If[S >= d2 && a2 <= 2, a2 = a2 + 1; 
     If[a2 == 1 || a2 == 2, S = S - d2; m[2]++], 
     If[S >= d3, S = S - d3; m[3]++, 
      If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]]; 
  For[i = 1, i <= 5, i++, s034 = AppendTo[s034, m[i]]]; 
  AppendTo[s0134, {Total[s034] 10^IntegerLength[5 - Count[s034, 0]] - 
     Count[s034, 0] + 5, s034}]]; 
Notes35[d01_, d02_, d03_, d04_, d05_, n0p_] := 
 Module[{d1 = d01, d2 = d02, d3 = d03, d4 = d04, d5 = d05, S = n0p}, a1 = 0; 
  a2 = 0; m[1] = m[2] = m[3] = m[4] = m[5] = 0; 
  While[S != 0, 
   If[S >= d1 && a1 <= 2, a1 = a1 + 1; 
    If[a1 == 1 || a1 == 2, S = S - d1; m[1]++], 
    If[S >= d2 && a2 <= 1, a2 = a2 + 1; If[a2 == 1, S = S - d2; m[2]++], 
     If[S >= d3, S = S - d3; m[3]++, 
      If[S >= d4, S = S - d4; m[4]++, S = S - d5; m[5]++]]]]]; 
  For[i = 1, i <= 5, i++, s035 = AppendTo[s035, m[i]]]; 
  AppendTo[s0135, {Total[s035] 10^IntegerLength[5 - Count[s035, 0]] - 
     Count[s035, 0] + 5, s035}]];
...
$\endgroup$

protected by Community Nov 3 at 11:22

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.