You are given an integer, perhaps a very long long integer, composed of only the
ID: 3530245 • Letter: Y
Question
You are given an integer, perhaps a very long long integer, composed of only the digits 1 and/or 2. You have the ability to change a 1 digit into a 2 and a 2 digit into 1 and must determine the minimum number of changes that you can make resulting in no 2 digits remaining in the number that are in a position (in terms of powers of ten) higher than any 1 digit. Enter initial configuration: 2222212 Changes: 1 Note: When the only one digit is converted into a two digit the requirement is satisfied. Enter initial configuration: 11111211 Changes: 1 Note: When the only two digit is converted into a one digit the requirement is satisfied. You could also change the two 1 digits into 2 digits but that would require two changes. We want to determine the minimum number of changes necessary. Enter initial configuration: 2211221 Changes: 3 Converting all of the 1 digits into 2 digits requires the least amount of work. Enter initial configuration: 1122112 Changes: 2 Enter initial configuration: 21112221 Changes: 2 Note: Change the first 2 to a 1 and the last 1 to a 2. Enter initial configuration: - 123 Error! Please try again! Enter initial configuration: 123 Error! Please try again! Enter initial configuration: 2113221 Error! Please try again! Enter initial configuration: 21212 Changes: 2 Note: No negative values! No numbers that contain digits other than 1 or 2.Explanation / Answer
The answer is 2, because it's closest to
1111111122222222
num2=Reading the number from the right, after the first one's digit, how many two's are there?
num1=Reading from the right, how many one's are there?
answer is the lesser of num1, num2. This is an hypothesis, and untested.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.