MindReader

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa 365 Puzzlers  Calendar 2017

Mensa 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

Problem Description

Drawing by Steve McGarry

Here's a simple "Mind Reading" program which can be quite amazing.  

 Think of a two digit number, subtract the sum of the digits from the number and look up the symbol which corresponds to the result.  Visualize the symbol and click the "Show me" button.  The program will usually display

Background & Techniques

I ran across this mind reader puzzle in the "Favorite Links" section of a recent issue of WinXPnews newsletter  (Vol 5,5 Issue 161).    I have not identified the original author, but search Google for "Mindreader sum digits" and you'll find a number of online versions. 

Non-programmers are welcome to read on, but may want to skip to the bottom of the page to download executable version of the program.

There are about 60 lines of user written code here, which  puts it in the  Beginners category.   The only semi-tricky part is the use of an OnDrawCell exit for displaying the result numbers and their associated symbol.  Each cell requires two DrawText calls with different fonts; "Arial" for the numbers and "Wingdings" for the symbols.  The table is filled from a set of symbols selected to avoid those that might standout by being darker than the others.

A TImage control is used to display the result and there is a bit of code required to center the symbol within the image.   The left coordinate is 1/2  the difference between the width of the image and the width of the symbol.  Makes sense if you think about it and the technique can be used in many "centering" applications.   The width of the available space minus width used gives you the total unused space.  To center the line or image we need half this unused space on the left leaving the other half on the right.   Vertical centering uses the same idea with the two heights.  

Oh - one more tricky part - the advanced technology required to perform the mind reading task.  But I'll let you discover that for yourselves.  

Running/Exploring the Program 

bulletDownload source
bulletDownload  executable

Suggestions for Further Explorations

Any image, letter, words, names, etc. could be substituted for the symbols used here.  

 

Original Date: February 5, 2005

Modified: July 29, 2017

 
  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2017, Gary Darby    All rights reserved.