Almost everybody knows this game: someone has a number in his head and the other one has to guess what number that is.
The only hints that this person give is: too high or too low.
I'm trying to create a function to find the highest number in a directory. I have a directory with files 001.jpg, 002.jpg, 003.jpg, 004.jpg and so on towards 067.jpg. But i want a function that finds this highest number.
I thought the following algoritm would be nice to use:
Start at 100. Check of 100.jpg exists. If no, divide by 2. Check of 50.jpg exists. If no, divide by 2. But in this case it's YES. So, divide by 2 and sum that(?) 50 + 25 = 75. Check if 75.jpg exists... and so on...
Is there a function already like this or are there other smart functions for this problem