Analysis of Child Prodigies |
---|
This one-star logic puzzle has 4 noun types, 4 nouns per type, 4 link, 11 facts, and no rules. It needs 96 marks and 6 grids. I will explain how to create its puzzle module in JavaScript. This is what you need to glean from the text of a logic puzzle.
A logic puzzle must have at least two noun types (say "First Name" and "Last Name"), and at least two nouns per type (say "John" and "Jane" are the first names, and "Smith" and "Doe" are the last names).
A logic puzzle must have the same three verbs. Verbs help you define the facts of the puzzle. The three verbs are:
Verb.IsNot
usually has the name "is not" and is denoted by a 'X'.Verb.Is
usually has the name "is" and is denoted by a 'O'.Verb.Maybe
usually has the name "may be" and is denoted by a blank.Note that the verb characters are what you enter in the grids you see in a logic puzzle magazine.
A logic puzzle must have at least one link, where the first link is the "with" link. If you see a clue like "John's last name is not Doe.", it has the verb "is not" and the link "with". You can see by this example that the link "with" is implied by the clue. In general, if you do not see an explicit relationship in a clue, use the link "with", defined as Link.With
.
And a logic puzzle must have at least one fact or rule. A logic puzzle without facts or rules is not really a logic puzzle, is it? Okay, let's begin with the nouns.
Reading the text of the puzzle you see that the four noun types are "Field", "First Name", "Last Name", and "Age". Note that I usually capitalize the names of the nouns when I first encounter them. The fields are "Mathematics", "Painting", "Sculpture", and "Violin", so there must be four nouns per type. The first names are "Grady", "Rose Anne", "Megan", and "Michael". The last names are "O'Keefe", "Riley", "Blumenthal", and "Elliot". The obvious ages are 16 and 14, so the other two ages still need to be determined, given the ages are from 9 to 20.
Clue 5 states the painter is 14 years old, two years older than Michael. This means Michael is 12 years old. We now have three of the ages - 12, 14, and 16.
Clue 4 states Megan is eight years older than the Elliot child (who isn't Rose Anne). If Megan is the oldest, she could be 20 (12 + 8), 22 (14 + 8), or 24 (16 + 8). But the oldest age allowed is 20, so Megan may be 20. If Megan is not the oldest, she may be 12, 14, or 16, which means another child would be 4 (12 - 8), 6 (14 - 8), or 8 (16 - 8). But since no child is less than 9, Megan can only be the oldest at 20. We now have all four ages: 12, 14, 16, and 20.
Note: If I was not able to easily calculate the ages, I would have a rule do that for me. The puzzle "Astrophysics Conference" does exactly that.
You may have noticed that clue two presents unique nouns in terms of order. Since the puzzle does not ask for the solution in terms of order, and there are no other clues that involve order, I decided NOT to add another category ("Order") with the nouns "1", "2", "3", and "4".
Here are my nouns, grouped by type. Note that I sorted the nouns within each type.
Field | First Name | Last Name | Age |
---|---|---|---|
Mathematics | Grady | Blumenthal | 12 |
Painting | Megan | Elliot | 14 |
Sculpture | Michael | O'Keefe | 16 |
Violin | Rose Anne | Riley | 20 |
Most puzzles will give you all of the nouns. But some puzzles (even one-star puzzles) may make you work to find all of the nouns. Anyway, we have 4 noun types, with 4 nouns per type. Let's move on to the links.
Next, I want to examine the clues for the relationships in the puzzle. I found the following relationships.
Question: how do you tell a program what it means for two nouns to be "more than 4 years apart"? I will answer that question when I discuss the puzzle module.
Facts tie together the nouns, verbs, and links you found in the puzzle. Hopefully, all of the clues can be expressed as facts. Otherwise, you will need rules. The following clues can be expressed as facts.
When it comes to programming the facts in a puzzle module, you may find it vexing how the nouns, verbs, and links are tied together. For example, clue two states that Rose Anne is not the violinist, but there is no noun called "violinist" (though we do have the noun "violin"). In Mystery Master terms, this clue means "Rose Anne is not with the violin." Don't worry, you'll catch on to the distinction (really).
As it turns out, all of the clues in the puzzle have been expressed as facts, so there are no rules for this puzzle. Yeah.
Now it is time to create the JavaScript file for our logic puzzle. In your editor of choice, create the file "ChildProdigies.js". First, define the function ChildProdigies, which is sorta like a class file in Java. Within this function, we need to define several sections. Your module should look like the following.
You can create most JavaScript files with this basic template. You define the properties (name and title), nouns, verbs, links, facts, and rules. For this puzzle, we are happy to accept the default values for the verbs, so there is nothing to enter in the verbs section. Also, there are no rules for this puzzle, so the rules section is empty as well. The following methods are used to enter the nouns, links, and facts.
puzzle.addNounType("Noun type name")
nounType.addNoun("Noun name")
puzzle.addLink("Link name", nounType);
puzzle.addFact("clue #", noun1, verb, link, noun2, "Fact name");
Below is the JavaScript for entering the nouns.
The real programming of a puzzle module is when you need to define links and rules. Fortunately, this puzzle does not need rules. But we do need to define our links, and that involves programming. Each link has a function that determines whether one noun is or is not related to another noun. It is implied that both names have the same noun type as the link. We never have to define the function for the first link "with", but we do for our other links: "more than four years apart from", "eight years older than", and "two years older than". Being able to program the links will make you an expert in constructing puzzle modules. Rhe noun type for these three links is "Age".
If you look at the API documentation, you can see the members of the Link class. The important ones are num (the zero-based number of the link), name (the string argument you give in addLink), and nounType (the second argument of addLink). Most functions for links can also be defined via the SmartLink class. These functions define the relationship between two nouns using the num property of the noun. Unfortunately for us, we cannot avail ourselves of the SmartLink class. Below is the JavaScript for entering the links.
As you can see, our functions are defined using the noun's name, which is converted to a number via the parseInt
function. That is why we cannot use the SmartLink class.
Entering facts is easy compared to links and rules. To enter most facts, the basic format is:
puzzle.addFact("clue #", noun1, verb, link, noun2, "fact name");
Please take a look at the JavaScript module.