Brussel's choice def brussels_choice_step(n, mink, maxk): This problem is adapted from another jovial video "The Brussel's Choice" of Numberphile (a site so British that you just know there has to be...



Brussel's choice

def brussels_choice_step(n, mink, maxk):



This problem is adapted from another jovial video "The Brussel's Choice" of Numberphile (a site so British that you just know there has to be a Trevor and a Colin somewhere in there) whose first five minutes you should watch to get an idea of what is going on. This function should compute and

return the list of all numbers that the positive integer n can be converted to by treating it as a string and replacing some substring m of its digits with the new substring of either 2*m or m/2, the latter

substitution allowed only when m is even so that dividing it by two produces an integer.


This function should return the list of numbers that can be produced from n in a single step. To keep the results more manageable, we also impose an additional constraint that the number of digits in the chosen substring m must be between mink and maxk, inclusive. The returned list must contain the numbers in ascending sorted order.


mink maxk Expected result<br>42<br>1<br>2<br>[21, 22, 41, 44, 82, 84]<br>1234<br>1<br>1<br>[1134, 1232, 1238, 1264, 1434, 2234]<br>1234<br>[634, 1117, 1217, 1268, 1464, 1468,<br>2434, 2464]<br>88224<br>2<br>3<br>[44124, 44224, 84114, 84124, 88112,<br>88114, 88212, 88248, 88444, 88448,<br>176224, 176424, 816424,816444]<br>123456789 |7<br>[61728399, 111728399, 126913578,<br>146913569, 146913578, 246913489,<br>246913569, 246913578]<br>(a list with 65 elements, the last three of which are<br>[1234567169, 1234567178, 1234567818 ])<br>123456789 |1<br>

Extracted text: mink maxk Expected result 42 1 2 [21, 22, 41, 44, 82, 84] 1234 1 1 [1134, 1232, 1238, 1264, 1434, 2234] 1234 [634, 1117, 1217, 1268, 1464, 1468, 2434, 2464] 88224 2 3 [44124, 44224, 84114, 84124, 88112, 88114, 88212, 88248, 88444, 88448, 176224, 176424, 816424,816444] 123456789 |7 [61728399, 111728399, 126913578, 146913569, 146913578, 246913489, 246913569, 246913578] (a list with 65 elements, the last three of which are [1234567169, 1234567178, 1234567818 ]) 123456789 |1

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here