(Solved) – Code in Macros or Python to return a list of numbers according to Specific Conditions

  • by
(solved)-–-code-in-macros-or-python-to-return-a-list-of-numbers-according-to-specific-conditions

4 numbers are to be picked at random from a bag containing numbers 1 to 20
For convenience purposes, said numbers are grouped as;
1 – 5
6 – 10
11- 15
16- 20

Numbers chosen in the Number Pattern (2101) means 2 numbers are chosen from numbers (1-5), 1 number from numbers (6-10), no number, i.e. 0 number from numbers (11 – 15)
and 1 number from numbers (16-20).

Let Type of numbers under consideration be e for (Even) number, o for (Odd) number and p for a (Prime) number.

What code in excel(macros) or Python such that chosen pattern, for example 2101 and Number Type
(eeop) will return a list of numbers that fit these conditions? then go on to repeat for another number pattern (1120) and number type (oepe).

For example Number Pattern; (2101) @ Number Type (eeop)
and
Number Pattern; (1120) @ Number Type (oepe) returns following number list;

Number Pattern (2101) @ Number Type (eeop)
02 04 09 17;

02 04 09 19

Number Pattern (1120) @ Number Type (oepe)
01 06 11 12;

01 06 11 14;

01 06 13 14;

01 08 11 12;

01 08 11 14;

01 08 13 14;

01 10 11 12;

01 10 11 14;

01 10 13 14;

05 06 11 12;

05 06 11 14;

05 06 13 14;

05 08 11 12;

05 08 11 14;

05 08 13 14;

05 10 11 12;

05 10 11 14;

05 10 13 14

Thank you in advance.
(P.S. – Im new to this platform…apologies in advance for any indiscretion)

Leave a Reply

Your email address will not be published. Required fields are marked *