Cupid's Arrow

[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

Selecting from the numbers 1 through 9, place one digit in each of the circles representing points on Cupid's bow according to the following rule:

Each pair of digits connected by a black line must form a 2-digit number that is evenly divisible by 7 or13, For example 7 and 8 connected by a line would be appropriate because the number 78 is divisible by 13. You can consider the 2 digits in either order and no digit may be used more than once.

For every solution you find" said Cupid before flying off, "you win someone's heart. If you can find a solution in which the numbers connected by the bow string qualify as well, you will always be in love!"

Adapted from "Wonders of Numbers", Clifford Pickover

Background & Techniques

This is mainly another little programming exercise using our old standby Combo unit to generate all permutations of 5 of 9 digits.  We will test each set to see if it satisfies the conditions.  An Edges array of points defines the circles that are connected.  For referencing in Edges, circles are numbered like this.    

The 6 parts of the bow and arrow (excluding the bow string) are defined in the first 6 points of the array.  The 7th and 8th entries identify the circles connected by the bowstring.  

As we get each permutation, we'll check if the first 6 edges define numbers that are divisible by 7 or 13 taking the numbers in either order.   Function  IsOK performs the test for a particular edge, returning true if that edge meets the condition for the current permutation.  The current permutation is is contained in an array Combos.Selected[1] through Combos.Selected[5] after each call to Combos.GetNext.  

If it is a solution, we'll perform an IsOK check for the bowstring points and just add a note if they also satisfy the condition,

The only other tricky parts might be the use of the FormPaint method to draw the bow.  This is necessary since we are drawing the bow directly on the form's canvas.   And we use an OnClick exit for the listbox to draw the solution numbers on the bow.

   

Running/Exploring the Program 

bulletBrowse source code extract
bulletDownload Source
bulletDownload executable 

Suggestions for Further Explorations

I wonder why Dr. Pickover chose 7 and 13 as the divisors.  What other divisors would work?
What would be the effect digits 0 through 9 were used?  
  
Created: July 24, 2003

Modified: May 15, 2018

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