last day (15 days later) » 

06:18
4
Q: The Missing Digit

Joshua CrottsBackground: This is an Amazon interview question with a slight twist on it. Question: Given a string of random integers from 0 to 250 exclusive [0, 250) with one digit missing, find the missing digit. That is, a string without any delimiters (something like 23, 54, ...; is 2354.... instead), a...

Good idea. My bad! This is my first post here...
My apologies; I'll be sure to look there next time. I wonder if anyone can solve this!
@JoshuaCrotts What is the winning criteria? [tags:fastest-code] need a fixed way to measure the answers.
For other answerers: Don't answer this challenge yet, it is not clear enough.
I'll clear up the winning criteria; my apologies. The winning criteria is whoever can at least PROGRAM the algorithm in the language of their choice. Sure, this problem CAN be solved by hand without a machine, but I want to see if anyone can write a program for this particular set [0, 250). If multiple people succeed, the winning criteria will be determined by the fastest runtime of the program. Memory has no limitation; use as much as you want, but obviously lower will be a tiebreaker if times are somehow the same.
@JoshuaCrotts On which computer are the programs run? Also: "What should be done on multiple possible solutions?"?
@fedes. It is not possible for more than 1 number to be missing from a sequence. The samples ARE somewhat weak, but are merely randomly generated. Again, the idea behind this is to see if it's possible to write a program to do this calculation. Narrowing it down is easy, but actually figuring out what the number is (especially with incredibly large datasets) would be nearly impossible for a human.
@user202729 Every number will appear in the sequence at least once, except for one arbitrary number. That's how these large strings were generated in the first place.
06:18
It is possible that there are multiple possible solutions (e.g., the remaining string is 232 from the set of numbers [2, 23, 32] - either 23 or 32 is missing, and I can't know how you generated).
The random numbers were generated as such:
Populate a 250-sized array. Remove an arbitrary generated index. Concatenate this indexes' value to the string. After 249 removals, one would be left. This is what you need to find.
And by populate, I mean 0 to 250 exclusive.
Am I understanding the question correctly? Let's see with the small example above.
Like, let's take a set of 0 to 20 exclusive.
I'll generate one.
The set, instead of [0, 1, 2, ..., 249], is [2, 23, 32] and the resulting string is 232.
17
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19]
171
[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19]
17114
[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 18, 19]
1711416
[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 18, 19]
171141611
[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 18, 19]
17114161113
[0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 18, 19]
171141611136
[0, 2, 3, 4, 5, 7, 8, 9, 10, 12, 15, 18, 19]
1711416111368
[0, 2, 3, 4, 5, 7, 9, 10, 12, 15, 18, 19]
I apologize for the long message
Let's use this example
The line without the obvious arraylist brackets is the string.
Each time the number is removed, it's concatenated onto the string.
06:23
Ok, stop. I understood how you generate it, but from the string it is not always possible to get the number.
Eventually going down to the bottom, and we have 4 as our last number. 19 numbers out of 20, and I don
Use [2, 23, 32] as the example set, and you'll see.
I don't understand where you're getting that set from.
Replace what you are using as example ([0, 1, ..., 19]) with this set.
And generate the numbers.
Well... that's just not how the problem was intended. It's supposed to go from 0 to whatever the max value is.
06:25
Take the set [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
In this case, being 250.
Okay
Remove values randomly
Until you have [2, 23, 32] left.
Ah, I do see your point now.
Now I need to figure out how to restructure the entire problem since this was something I did not account for.
I suppose I could restructure it to ask the users to find all of the combinations possible.
And not necessarily solely for the example sets I generated.
I have now edited the question a little more; hopefully, this clears things up slightly.
On which computer are the programs run?
Are we supposed to take the number of numbers (range) as input?
How are programs measured?
What do you mean by the question, "...which computers are the programs run?"
06:37
Because for questions, there must be a definite way to measure program performance.
I mean, you can use big O if you can calculate it, or just runtime.
What would be fastest-code?
I think in this example, fastest-algorithm would be better.
06:39
See how the question is specified (on which computer and how are programs scored)
Well, ColeraSu is right here...
--- Which way to formulate the question is up to the OP, as long as it follows the site rules.
Rules and (probably) rules.
-----------------------
Must programs support any range? Or just `[0, 250)`?
This probably goes against one of the rules (per glancing over them), but for the contest, it is [0, 250). It would be IDEAL to be able to handle as many as possible.
But, for the sakes of this contest, it is the range specified.
The problem is, any algorithm that should only handle [0, 250) is O(1).
Even if the numbers are scrambled?
Probably you are not understanding what big O complexity means. Yes.
Because there is effectively no N in the problem.
That is true.
I think I'll just close the contest for all intensive purposes, as there are many faults with it.
I do apologize for the confusion; I
I'll take better consideration of this next time.
06:48
Ok. Actually the challenge idea by itself is good (as many users noted), just that there is too much confusion.
Now you knew how to use the Sandbox.
07:00
Looking for you to fix that. I've come up with a efficient algorithm (though I can't prove the complexity).

  last day (15 days later) »