I was tasked to solve this challenge on a programming exam, but I'm not sure that I have properly solved it. I am inquisitive about what really is the solution to this task:
Make an application that will tell the user to input 3 numbers, identify the sequence, and provide the 4th integer. It should prompt if no relations is found
Note: Possible operators may include addition, subtraction, multiplication, division, exponent, and modulo division.
Sample Output:
2, 4, 6, 8
10, 9, 7, 4
1, 4, 9, 16
1, 1, 2, 6
120, 120, 60, 20
Here is my solution so far:
using System;
using System.IO;
namespace TestQuestionnaire
{
class Program
{
static void Main(string[] args)
{
var numbers = new int[3];
string answer;
bool exit = false;
while (!exit)
{
// Loop for 5 times
for (int n = 0; n <= 5; n++)
{
// User Input
Console.WriteLine("Please Enter 3 Numbers.");
for (var i = 0; i < numbers.Length; i++)
{
var error = false;
while (!error)
{
Console.Write("Enter Number: ");
error = int.TryParse(Console.ReadLine(), out numbers[i]);
if (!error) Console.WriteLine("Invalid Number! Enter a Valid Number and Try Again. ");
}
}
NextNumber(numbers);
}
// Prompt for exit
Console.WriteLine("Finished! Try Again? Y/N");
answer = Console.ReadLine()?.ToUpper();
if (answer == "N")
{
exit = true;
}
}
}
private static void NextNumber(int[] numbers)
{
int next = 0;
int interval_one = 0;
int interval_two = 0;
// determine if first two number is descending, ascending or equal (addition and subtraction)
if (numbers[0] < numbers[1])
{
interval_one = (numbers[1] - numbers[0]);
if (numbers[1] > numbers[2])
{
interval_two = (numbers[1] - numbers[2]);
}
else
{
interval_two = (numbers[2] - numbers[1]);
}
//determine if constant interval (eg, 2,4,6,8 or 1,2,3,4) otherwise evaluate more
if (interval_one == interval_two)
{
next = numbers[2] + interval_two;
}
else
{
next = numbers[2] + interval_two + (interval_two - interval_one);
}
}
else if (numbers[0] > numbers[1])
{
interval_one = numbers[0] - numbers[1];
if (numbers[1] > numbers[2])
{
interval_two = (numbers[1] - numbers[2]);
}
else
{
interval_two = (numbers[2] - numbers[1]);
}
if (interval_one == interval_two)
{
next = numbers[2] - interval_two;
}
else
{
next = numbers[2] - interval_two + (interval_one - interval_two);
}
}
else
{
if (numbers[0]/1 == numbers[1] && numbers[1]/2 == numbers [2])
{
next = numbers[2] / 3;
}
else if (numbers[0] * 1 == numbers[1] && numbers[1]*2 == numbers[2])
{
next = numbers[2] * 3;
}
}
Console.WriteLine("Predicted 4th Number: {0}", next);
}
}
}
Thanks!
I just have an Idea but I hope this can help
using +
2 4 6 8
2 2 2
10 9 7 4
1 2 3
1 1
1 4 9 16
3 5 7
2 2
diffrent way(*)
1 1 2 6
1 2 3# now +
1 1
use '/'
120 120 60 20
1 2 3# use +
1 1
There is no way to recognize all sequences of numbers, as each is defined by a very different relation. You would essentially have to hardcode each case as listed in the examples. And even then, there is no one correct answer. For your fourth example, I could see the sequence 1 1 2 2 3 3... being just as reasonable as 1 1 2 6.... In fact, the Online Encyclopedia of Integer Sequences finds 35,000 results for the the sequence 1 1 2 (see https://oeis.org/search?q=1%2C1%2C2&sort=&language=english&go=Search)
Putting that aside though, I'll give some pseudocode for the examples (I'm assuming, given that you are fine with Python or C#, that the language itself is not particularly important, and that you probably already know how to do the "getting input" and "returning results" portions.).
if the difference between each number is equal, add that difference to the last number and return it
if the difference between each number is the sequence 1 2 3..., return the last number plus the next difference (4 in this case)
If the numbers are the squares, return the next square (16 in this case)
If each number divided by the previous number is the sequence 1 2 3, return 4 * the last number
If each number divided by the next number is the sequence 1 2 3, return the last number divided by 4.
Of course, a more robust solution would account for negative sequences, or those that bounce back and forth between positive and negative. But again, it is an underdetermined problem.
Related
I have been trying to get this to work for 3 days, and I feel like I'm using the wrong approach, if anyone can correct me I will wax your car. Background, client asked to me make a simple pyramid algorithm. I want to select add everything to a list of objects and make everything on the left side true and everything on the right side false. Every other line reads the line 2 lines prior and adds multiple entries. The first time it adds a number like 1 it's one time, then it adds two 1's for each 1 until there is 4. So the first time it enters a 1 on line 1, then on line 3 it adds a 1 two times, then on line 5 it reads from line 3 and adds each of those 1's 2 times.
Here is a visual representation.
|1|
|2| |3|
|1|1| |4|5|
|2|2|3|3| |6|7|8|9|
|1|1|1|1|4|4|5|5| |10|11|12|13|14|15|16|17|
|2|2|2|2|3|3|3|3|6|6|7|7|8|8|9|9| |18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33
The order this list would be is:
1|2|3|1|1|4|5|2|2|3|3|6|7|8|9|1|1|1|1|4|4|5|5|10|11|12|13|14|15|16|17...
I keep getting close, but it fails to generate the correct output. `
for (int i = 1; i < 50; i = i * 2)
{
Response.Write(i.ToString() + " - ");
var previousLevel = (i / 2 / 2);
foreach (var oc in infoRows.Where(x => x.level == previousLevel))
{
for (int p = i; p > 0; p--)
{
Response.Write(oc.id + "*");
}
}
while (level <= i)
{
for (int r = 1; r <= i; r++)
{
InfoRow tempInforow = new InfoRow();
tempInforow.customerCode = GenerateCustomerNumber(position);
tempInforow.id = customerId;
tempInforow.sendtoidnumber = level.ToString();
tempInforow.status = 0; // GetStatus(position, totalCount);
tempInforow.position = position;
tempInforow.level = i;
infoRows.Add(tempInforow);
customerId++;
position++;
Response.Write(tempInforow.id + "-");
level++;
}
}
}
`
Essentially this generates the following:
1 - 1-
2 - 2-3-
4 - 1*1*1*1*4-5-6-7-
8 - 2*2*2*2*2*2*2*2*3*3*3*3*3*3*3*3*8-9-10-11-12-13-14-15-
16 - 4*4*4*4*4*4*4*4*4*4*4*4*4*4*4*4*5*5*5*5*5*5*5*5*5*5*5*5*5*5*5*5*6*6*6*6*6*6*6*6*6*6*6*6*6*6*6*6*7*7*7*7*7*7*7*7*7*7*7*7*7*7*7*7*16-17-18-19-20-21-22-23-24-25-26-27-28-29-30-31-
32 -
I've tried 30 different ways with switch statements, while statements, for and foreach statements, the closest I can get to this working is level 4.
Can someone suggest another way. Maybe a multidimensional array or idk what. Thank you.
Let's write the sequence down and have a look on what's going on:
# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ...
seq 1 2 3 1 1 4 5 2 2 3 3 6 7 8 9 1 1 1 1 4 4 5 5 10 ...
^ ^ ^ ^ ^ ^
| |
if # is power of 2 (e.g. 8 == 2**3)
we should copy and double # / 4 items (here 8 / 4 == 2 items)
starting from # / 4 item (here 8 / 4 == 2, starting from item #2)
Time to implement this algorithm
Code:
using System.Linq;
...
private static List<int> Pyramid(int size) {
if (size < 0)
throw new ArgumentOutOfRangeException(nameof(size));
if (size <= 3)
return Enumerable.Range(1, size).ToList();
List<int> result = new List<int>(size) { 1, 2, 3 };
for (int value = 4; result.Count < size; )
if (BitOperations.IsPow2(result.Count + 1)) {
int chunk = (result.Count + 1) / 4;
for (int i = 0; i < chunk && result.Count < size; ++i) {
result.Add(result[chunk - 1 + i]);
if (result.Count >= size)
return result;
result.Add(result[chunk - 1 + i]);
}
}
else
result.Add(value++);
return result;
}
Demo:
// First 31 items from the pyramid
Console.Write(string.Join("|", Pyramid(31)));
Output:
1|2|3|1|1|4|5|2|2|3|3|6|7|8|9|1|1|1|1|4|4|5|5|10|11|12|13|14|15|16|17
(I apologize for the atrocious formatting)
I am attempting to make a random number generator (min = 1, max = 10) that loops until either
a) a 1 is generated (serve as primary sentinel).
b) loop iterates 10 times (secondary sentinel) without generating 1.
I am looking for something like this:
6 3 8 4 1
"A one was received in 5 attempts,"
or
3 8 5 7 2 2 4 8 8 3
"A one was never received."
but the problem is that the loop continues even if a 1 is generated, and the "A one was never recieved." message displays.
The loop is as follows:
while (randomNumber.Next() != 1 || loopCounter <= 10));
{
loopCounter++;
Console.WriteLine(randomNumber.Next(10));
Thread.Sleep(100);
if (randomNumber.Next() == 1)
{
Console.WriteLine($"A one was recieved in {loopCounter} attempts.")
break;
}
if (loopCounter <= 10)
{
Console.WriteLine("A one was not recieved.")
break;
}
}
giving something like
1 4 6 9 7 1 3 3 1 9 "A one was not recieved."
You more or less had the right idea for deducting whether each of the two conditions were met (aside from the sleeping thread ?).
But if you do it after initialising variables to track what you were doing rather than checking as you go along it's easier to produce a method that meets the requirements for what I'm assuming is a homework question.
Random rand = new Random();
int randomNumber = 0;
int maxLoops = 10;
string numbersSoFar = "";
for (int i = 1; i <= maxLoops; i++)
{
//Generate random number between 1 and 10:
randomNumber = rand.Next(1, 10);
numbersSoFar += randomNumber + " ";
if (randomNumber == 1)
{
Console.WriteLine(numbersSoFar);
Console.WriteLine("1 was found on loop number: " + i);
break;
}
else if (i == 10)
{
Console.WriteLine(numbersSoFar);
Console.WriteLine("10 loops completed, no 1 found.");
}
}
Since one of the conditions is that you have a maximum number of loops, you can use this in a for loop, rather than a while loop giving you access to an immediate iterator to compare against rather than declaring an extra value coupled with a while loop. This way it terminated automatically where as in your question you'd need a breakout/termination clause additionally for that.
Your main issue is that Next() returns a new random integer on each call, and without arguments returns any valid integer, so you have about a 1/(2^32) chance of getting 1. Instead you should be calling it once on each iteration and reading that result a few times. Your loop could look something like this:
List<int> nums = new List<int>();
for(int i = 0; i < 10; ++i)
{
nums.Add(randomNumber.Next(1, 10));
if(nums.Last() == 1)
{
break;
}
}
Console.Write(String.Join(" ", nums) + " ");
if(nums.Last() == 1)
{
Console.WriteLine("A 1 was received after " + nums.Length + " attempts");
}
else
{
Console.WriteLine("A 1 was not received.");
}
Im trying to understund how do I find whether the number is Happy Number or not,
I know that i need to check if the unit digit and the digit in the highest number location are greater
then the numbers in the middele.
`example:
given number: 63240
the unit: 6
the number in the highest location:0
are both of them greater then 3 and 2 and4(middle) ? yes
result: true (for that case)
the quation is:
write a program that get a number from user, the program will print if the given number from the user is a happy number or not
I know how to find the units and the highest number location, but got stack figure it out how to
how to use the digits in the middle in order to find the answer for that..
notice that the only class we've learned so fat is Math,(not even string yes)
we also learned while and for but nothing so far..
I also know that in order to go through all digit in given number i need to use the while loop,
but I dont know how do I use it in order to use them to get to the answer..
my code so far:
int number;
int units;
int highestDigitLoc;
bool isHappyNumber = true;
int count = 0;
Console.WriteLine("enter a number:");
number = int.Parse(Console.ReadLine());
while(number > 0)
{
count++;
units = number % 10;
highestDigitLoc = number / 10;
}
thanks
This link explains what Happy Number's are in a simple way. Basically you have to keep suming the square of each digit present in the number, until the result equals 1. This proccess can go on indefinitely, but fortunately we know for certain that if the sum equals 4, it will never result in a Happy Number. Therefore, we can do the following:
private static bool IsHappy(int n)
{
if (n == 1)
return true;
else if (n == 0 || n == 4)
return false;
else
return IsHappy(SumDigitSquares(n));
}
private static int SumDigitSquares(int n)
{
if (n < 10)
return n * n;
else
return SumDigitSquares(n % 10) + SumDigitSquares(n / 10);
}
Usage:
bool result = IsHappy(63240); //false
Well, your question very vague, however, we can turn the number into an array of digits int[] digits
using System.Linq;
...
int[] digits = null;
while (true) {
Console.WriteLine("enter a number:");
// string : let's solve for arbitrary long numbers (no necessary int)
string number = Console.ReadLine().Trim();
if (string.IsNullOrEmpty(number))
Console.WriteLine("Empty string is not enough");
else if (number.All(c => c >= '0' && c <= '9')) {
// This code preserves leading zeroes
digits = number.Select(c => c - '0').ToArray();
// This code removes leading zeroes
//digits = number
// .SkipWhile(c => c == '0')
// .Select(c => c - '0')
// .DefaultIfEmpty()
// .ToArray();
break;
}
else
Console.Write("Not a valid integer value. Please, try again.");
}
Then we can use this int[] digits to implement any logic required.
Please, note, that we preserve leading zeroes:
"63240" -> int[] {6, 3, 4, 2, 0}
"063240" -> int[] {0, 6, 3, 4, 2, 0}
e.g.
let a number be happy if and only if
It contains at least 3 digits (in order to have middle ones)
Max of the first and last digits is greater than max of all the other digits
In our case with 63240
63240 has 5 digits, the condition holds
Max(0, 6) == 6 > Max(3, 2, 4) == 4, the condition holds
Code:
bool isHappyNumber =
digits.Length >= 3 &&
Math.Max(digits[0], digits[digits.Length - 1]) >
digits.Skip(1).Take(digits.Length - 2).Max();
Edit: let's implement isHappyNumber with good old for loops:
int maxFirstAndLast = digits[0] > digits[digits.Length - 1]
? digits[0]
: digits[digits.Length - 1];
int maxMiddle = 0;
for (int i = 1; i < digits.Length - 1; ++i)
if (digits[i] > maxMiddle) then
maxMiddle = digits[i];
bool isHappyNumber =
digits.Length >= 3 &&
maxFirstAndLast > maxMiddle;
//Remeber to add using System.Linq;
public static bool IsHappyNumber(int num)
{
var numbers = new List<int>();
while (true)
{
int sum = 0;
var digits = num.ToString().Select(x => int.Parse(x.ToString())).ToList();
foreach (var digit in digits)
sum += digit * digit;
if (numbers.Contains(sum))
break;
numbers.Add(sum);
num = sum;
}
return numbers.LastOrDefault() == 1;
}
i have to find a solution for this task :
"Supermarkets are increasingly equipped with automatic cash registers. Most of these funds only accept payment by credit card, although a significant proportion of consumers still pay cash (with banknotes and coins).
One of the problems encountered with the cash payment is the rendering of money: how to make a given sum optimally, ie with the minimum number of coins and notes? This is a problem for every one of us every day, let alone the automatic cash registers.
In this exercise, i m asked to try to find an optimal solution to make change in a specific case: when an automatic cash register contains only 2 € coins, 5 € and 10 € banknotes.
To simplify the problem, we will consider that all these coins and bills are available in unlimited quantities.
Here are some examples of currency:
The return of money is expressed by a Currency object. This item has 3 properties: piece2, billet5 and billet10 which respectively store the number of coins of 2 €, 5 € tickets and 10 € tickets.
For example, if we take example 2 of the table (6 €), we should get a Money object with:
Piece2 worth 3 (3 pieces of 2 €)
Ticket5 is worth 0 (no ticket of 5 €)
Ticket10 is worth 0 (no ticket of 10 €)
Task : Implement the MonnaieOptimale(int s) method that returns a Currency object containing the coins and notes whose sum is s. If it is impossible to return the currency (as in example 1), return null.
To get it best the solution will always have to make change when possible and with the minimum number of coins and tickets."
Data: s is always a strictly positive integer (long) less than or equal to 9223372036854775807
the general structure of the solution is the following:
Suggestions ??
Firstly, simple greedy approach (always get the largest i.e.10) is not working here, as the system is not canonical, consider s = 11, you will get "Impossible" if you use coin 10, but it is possible with { 5, 2, 2, 2 }.
I have a slightly different idea here, using the parity of odd /even numbers:
If s is even, do the greedy approach but never uses coin 5
If s is odd, keep using coin 5 until s becomes even, then do step 1.
For eg: s = 18, solution = { 10, 2, 2, 2, 2 }. s = 23, solution = { 5, 10, 2, 2, 2, 2 }
Why it works, is because one can notice, for coin system { 2, 10 }, you can make any even s using greedy approach (it is canonical to even domain).
Plus the fact that for any odd number minus another odd number will make a even number, so for odd s we can use one coin 5 to make s even to reduce the problem.
From this logic, I think at most one 5 coin would be used for any s, and only when s = 1 or 3 the answer is "Impossible"
i solve it mannually like this:
public static Monnaie MonnaieOptimale(long s)
{
if (s<10)
{
if (s%2 =0) {Monnaie.billet10 = 0 ; Monnaie.billet5 = 0 ; Monnaie.piece2 = s/2 }
else if (s == 5) {Monnaie.billet10 = 0 ; Monnaie.billet5 = 1 ; Monnaie.piece2=0 }
else if (s == 7) {Monnaie.billet10 = 0 ; Monnaie.billet5 = 1 ; Monnaie.piece2=1 }
else Monnaie.billet10 = 0 ; Monnaie.billet5 = 1 ; Monnaie.piece2= 2
}
else
{
if (s%2 =0)
{
Monnaie.billet10 = Math.Floor(s/10);
if ((Monnaie.billet10 * 10) != s) {Monnaie.billet5 = 0 ; Monnaie.piece2= (s%10)/2 }
}
else
{
private lastDigit = s%10;
if (lastDigit ==1){Monnaie.billet10 = ((s/10)-1) ; Monnaie.billet5 = 0 ; Monnaie.piece2=3 }
else if (lastDigit ==3){Monnaie.billet10 = ((s/10)-1) ; Monnaie.billet5 = 0 ; Monnaie.piece2=4 }
else if (lastDigit ==5){Monnaie.billet10 = (s/10) ; Monnaie.billet5 = 1 ; Monnaie.piece2=0 }
else if (lastDigit ==7){Monnaie.billet10 = (s/10) ; Monnaie.billet5 = 1 ; Monnaie.piece2=1}
else {Monnaie.billet10 = (s/10) ; Monnaie.billet5 = 1 ; Monnaie.piece2=2}
}
}
}
using System;
public class Program {
public static void Main() {
int re10 = 0, re5 = 0, re2 = 0, s = 197;
while (s / 2 != 0) {
while (s / 5 != 0) {
while (s / 10 != 0) {
if (s % 10 % 5 == 0) {
re10 = s / 10;
s = s % 10;
}
else {
if (s / 10 > 1) {
re10 = s / 10 - 1;
s = s % 10 + 10;
}
break;
}
}
if (s % 5 % 2 == 0) {
re5 = s / 5;
s = s % 5;
} else
if (s / 5 > 1) {
re5 = s / 5 - 1;
s = s % 5 + 5;
}
break;
}
re2 = s / 2;
s = s % 2;
}
if(re5==3){re10+=1;re5-=2;}
Console.WriteLine("billet 10 :" + re10);
Console.WriteLine("billet 5 :" + re5);
Console.WriteLine("billet 2 :" + re2);
Console.WriteLine("Total : "re2 * 2 + re10 * 10 + re5 * 5);
}
}
billet 10 :18
billet 5 :3
billet 2 :1
Total : 197
Question: Print all the number who has unique digits only.
Input : n =15
output: 1 2 3 4 5 6 7 8 9 10 12 13 14 15
Here 11 is not included because it has 1 two times, same way 123, 456 .. are also valid but 121 1344 are not valid because there is same digit more than once.
I am running loop from 1- n and checking each number.
I am using Hash-map to determine the uniqueness of number.
Is there any better solution of above problem.
i'm not sure , but something like that..
List<int> numbers = new List<int>(){};
numbers =numbers.Where(p=>validCheck(p)==true).ToList();
static bool validCheck(int n)
{
return (n.ToString().Length==n.ToString().Disctinct().Count());
}
You could use LINQ, convert the number into a string and check if the length of the string is equal to the number of distinct charchters.
for (int i = 1; i < n; i++){
if (i.ToString().Length == i.ToString().Distinct().Count())
Console.Out.Write(i + " ");
}
as a semi useful library function where you seed it with a start and how many you want.
public static IEnumerable<int> UniqueDigits(int start, int count)
{
for (var i = start; i < (start + count); i++)
{
var s = i.ToString();
if (s.Distinct().Count() == s.Length)
{
yield return i;
}
}
}
then
UniqueDigits(0,15).ToList().ForEach(Console.WriteLine);
or
foreach (var digit in UniqueDigits(100,50))
{
Console.WriteLine(digit);
}
This is how I eliminate the numbers that have a duplicate characters.
Console.Write("Input:");
int number = int.Parse(Console.ReadLine());
List<int> numbers = new List<int>();
List<int> acceptedNumbers = new List<int>();
for (int i = 1; i <= number; i++)
{
numbers.Add(i);
}
foreach (var num in numbers)
{
bool rejected = false;
char[] numChars = num.ToString().ToCharArray();
foreach (var numChar in numChars)
{
if (numChars.Where(n => n == numChar).Count() > 1)
{
rejected = true;
}
}
if (!rejected)
{
acceptedNumbers.Add(num);
}
}
acceptedNumbers.ForEach(n => Console.Write($"{n} "));
Console.Read();
A string is an IEnumerable - so you can use a LINQ statement to solve your problem:
Numbers.Where(N => N.ToString().Distinct().Count() == N.ToString().Length);
The query is checking how many characters of the string of your number distinct and comares this number with the number of total characters.
Here is the whole code printing out all distinct numbers until 20:
List<int> Numbers = new List<int>();
for (int i = 1; i <= 20; i++)
{
Numbers.Add(i);
}
IEnumerable<int> AcceptedNumbers = Numbers.Where(N => N.ToString().Distinct().Count() == N.ToString().Length);
foreach (int AcceptedNumber in AcceptedNumbers)
{
Console.WriteLine(AcceptedNumber);
}
My thoughts:
Run the Loop from 0 to n
For each batch of 10 ( like from 0 to 9 , 10 to 19, 230 to 239..), pick the digits apart from the last one. These digits map to the counter which tends to be skipped. Rest all are to be emitted. For eg : for batch 12x , pick 1 & 2 , now we know that we have to skip numbers at position 1 and 2 , and rest all are acceptable so no need to do any processing for them.
Keep the above digits in sorted manner in an arrayList and keep a pointer at index 0. Lets call it 'ptr'. While running through that batch, check if count ( which moves from 0 to 9 ) for each batch is equal to the array[ptr]. If no, emit the number out. Else, skip it and do ptr++.
When you are doing step 2, check if any digits are duplicate. If yes, skip the entire batch of 10.
There are no string operations happening, so it should bring in the efficiency
Another solution is using integer division and modulo (no number to string conversion). You can verify the uniqueness of a number with the following method (assume digits is int array having 10 elements).
public static bool IsUnique(int num) {
int[] digits = new int[10];
num = Math.Abs(num);
while (num > 0) {
int r = num % 10;
num /= 10;
digits[r] ++;
if (digits[r] > 1) {
return false;
}
}
return true;
}
Working example http://ideone.com/9emEoz
There are only 9 * 9! / (10 - n)! unique-digit numbers with n digits. For larger n, you might want a next lexicographic algorithm to avoid unnecessary iterations. (For example, there are only 544,320 7-unique-digit numbers, yet your program would need to iterate through almost 10 million numbers to produce them!)
Here's my attempt at a next lexicographic procedure for a set of n-unique-digit numbers (where n > 1):
(1) From left to right, start with the digits 10, then ascend from 2.
For example, the first 4-digit number would be 1023.
(2) Increment the right-most digit that can be incremented to the next available
higher digit unused by digits to its left. Ascend to the right of the
incremented digit with the rest of the available digits, starting with lowest.
Examples: 1023 -> 1024 (4 is unused by the digits left of 3)
^
9786 -> 9801 (8 is unused be the digits left of 7)
^
9658 -> 9670 (7 is unused by the digits left of 5)
^