On 12/12/2018 05:26, Hoang Quoc Dat wrote: > find out 1 similar program but the coding logic is like: The computer keeps > guessing the middle number of the range and narrow down the range by > focusing on only the upper/lower part of the range after receiving our > answer. > > I somehow have come to believe that the Python language and our logical > thinking can do better than that option of choosing the middle number all > the time but I still cannot find out the proper answer
Actually, that is quite an efficient algorithm. It even has a name: the "binary chop". But can you think of a better one? Forget about the computer. Ask how you would do it using pen and paper. How would you guess the number? Once you understand that you should be able to program Python to do the same thing. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor