Camillia
asked on
Practice question for interview - digits
This is more difficult. Not a visualization.
I get 1,000,051 employees.
1 to 9
20 to 29
30 to 39
40 to 49
50 to 59
60 to 69
70 to 79
80 to 89
90 to 99 is 189 digits
Then 100 to 999 is 270 digits
1000 to 9999 is 360 digits
10000 to 99999 is 450 digits
100,000 to 999,999 is 540 digits
1,000,000 to 1,000,029 is 210 digits
189+270+360+450+540+210 = 2019
1,000,030 to 1,000,051 = 21
Total is 2040.
Ends in 1 because no employee number 0
This one is tricky and you need to write down the groups to see.
I get 1,000,051 employees.
1 to 9
20 to 29
30 to 39
40 to 49
50 to 59
60 to 69
70 to 79
80 to 89
90 to 99 is 189 digits
Then 100 to 999 is 270 digits
1000 to 9999 is 360 digits
10000 to 99999 is 450 digits
100,000 to 999,999 is 540 digits
1,000,000 to 1,000,029 is 210 digits
189+270+360+450+540+210 = 2019
1,000,030 to 1,000,051 = 21
Total is 2040.
Ends in 1 because no employee number 0
This one is tricky and you need to write down the groups to see.
ASKER
thanks, let me see.
I made an error in the last row.
Up to 1,000,029 is 2019 digits.
then 1,000,030 is 7, 1,000,031 is 7 1,000,032 is 7 and 2019 +21 = 2040
So the number is 1,000,032 (not 051).
Total is 1,000,032
Up to 1,000,029 is 2019 digits.
then 1,000,030 is 7, 1,000,031 is 7 1,000,032 is 7 and 2019 +21 = 2040
So the number is 1,000,032 (not 051).
Total is 1,000,032
ASKER
Thanks, John. I'll check it. Had to call it quits for the day :) thanks for all the help today.
If there are about 190 digits for the first 100, then the first 1000 should have a lot more than 270 digits, I would think.
100-109 --> 30 digits
110-119 --> 30 digits
...
190-199 --> 30 digits
______________________
100-199 -->10 * 30 = 300 digits
200-299 = 300 digits
900-999 = 300 digits
_________________________
100-999 = 9 * 300 = 2700 digits
110-119 --> 30 digits
...
190-199 --> 30 digits
______________________
100-199 -->10 * 30 = 300 digits
200-299 = 300 digits
900-999 = 300 digits
_________________________
100-999 = 9 * 300 = 2700 digits
since only 2040 digits are needed, and if there were 1000 employes, we would need over 2700 digits, then N < 1000.
Hope you can take it from here.
Hope you can take it from here.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
According to the example provided, digits are not unique and re-used, so that changes how we calculate.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, it's a bit like buying numbers to stick on the front of their lockers.
It's a shame they didn't use leading "0"s :)
It's a shame they didn't use leading "0"s :)
ASKER
The answers weren't right. But it's ok. If I get this on the test, I'll skip it.
>> Between 100 and 999 each employee number uses three digits at most that's 899 x 3 digits which = 2697
Off by one: If there are 999 employees, then (999 - 100 + 1) = 900 employees will have 3 digit numbers, in which case there are 900 x 3 digits = 2700 digits.
From this we conclude that 100 < N < 999.
Off by one: If there are 999 employees, then (999 - 100 + 1) = 900 employees will have 3 digit numbers, in which case there are 900 x 3 digits = 2700 digits.
From this we conclude that 100 < N < 999.
>> The answers weren't right. But it's ok.
It looks to me like d-glitch is giving you the correct answer.
What answer are expecting?
>> If I get this on the test, I'll skip it.
If you do not have time to answer all the questions, then skip the hardest ones, I guess. But, the point of this partitioning exercise is to see how well you think. I advise to show the partitioning that you learned here and come up with an answer even if it turns out to be wrong.
>> It's a shame they didn't use leading "0"s :)
In a real company, they probably would do that, or just start the numbering scheme with 10000 (reserved for the CEO). :)
It looks to me like d-glitch is giving you the correct answer.
What answer are expecting?
>> If I get this on the test, I'll skip it.
If you do not have time to answer all the questions, then skip the hardest ones, I guess. But, the point of this partitioning exercise is to see how well you think. I advise to show the partitioning that you learned here and come up with an answer even if it turns out to be wrong.
>> It's a shame they didn't use leading "0"s :)
In a real company, they probably would do that, or just start the numbering scheme with 10000 (reserved for the CEO). :)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I put the answer in the test and I get incorrect. Let me try again.
Please give us the link for this online test whether it be practice or for credit.
BTW, this problem is quite a bit harder than your previous problem. As you can see, this problem even got some experts close but not quite on target. One of the pitfalls is to realize that when counting from 0 or from 100, you have to take special care because we are used to counting from 1.
BTW, this problem is quite a bit harder than your previous problem. As you can see, this problem even got some experts close but not quite on target. One of the pitfalls is to realize that when counting from 0 or from 100, you have to take special care because we are used to counting from 1.
You can solve this by brute force in two columns of an Excel spreadsheet:
Put a 1 in Col 1, Rows 1-9, and a 2 in Col 1, Rows 10-99, and a 3 in Col 1, Rows 100-999.
Then do a running total in Col 2 and look for 2040.
This takes less than 2 minutes and confirms my answer.
You can also solve this programmatically with for-loops or recursion.
Put a 1 in Col 1, Rows 1-9, and a 2 in Col 1, Rows 10-99, and a 3 in Col 1, Rows 100-999.
Then do a running total in Col 2 and look for 2040.
This takes less than 2 minutes and confirms my answer.
You can also solve this programmatically with for-loops or recursion.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes, 716 is correct. I just double checked.
Interesting because the practice hint says count ALL digits even if re-used.
ASKER
Helped me solve this one
How many digits are needed to assign numbers to 283 employees using the numbers 1 through 283?
741.
How many digits are needed to assign numbers to 283 employees using the numbers 1 through 283?
741.
That is correct.
ASKER
Yeah, this thread and your explanations helped. Thanks
The rest are three-digit numbers.