Links for August 8, 2005
- Photo of your fridge I’ve got this idea in a notebook from a few years back. I wanted to couple it with each household’s demographic profile and tax-return status
Joe’s iPhoto AppleScripts for Date Manipulation have been updated. I’ve been working on these for a while towards the goals of making Automator actions and a standalone Application, but some unknown incompatibility introduced by iPhoto 5.0.4 pushed this to the front burner.
Some areas of improvement:
I still don’t know why the previous scripts stopped working with 5.0.4, but I was thankfully able to get these all working with the newest iPhoto in a few hours this morning. Good application design really does make a difference. I know I’m still not working in true OOP, but breaking the code down into simple, self-contained chunks really makes maintenance simpler. The return curve (that agonizing time spent staring one’s own code and having no idea how it works) is much shorter when each component is named descriptively, has a concise, easy to grasp function and doesn’t draw from anything but it’s explicity input parameters.
Idea for next time: If these scripts obliterated the existing clipboard, would that be a dealbreaker? Or just an annoyance? What if they ran a lot faster?
I’m looking for a way to save and restore pre-existing clipboard data.
I have a few Studio projects that use UI scripting. Sending text to a non-scriptable control by pasting from the clipboard is significantly faster than using the Keystroke command. What I’d like to do is store the complete contents of pasteboard “general”, execute my UI stuff, then repopulate the pasteboard with the archived values.
Because my goal is to leave the clipboard data as I found it, this needs to work with any kind of clipboard data. The problems I’m having relate to complex data being dumbed down. For example, an image copied from Safari becomes a plain text URL after storing and retrieving. Conceptually, moving a big lump of data should be possible, regardless of supported formats.
One other related question: Is the list returned by types of pasteboard “general” prioritized? If I had to pick one of the returned types, how would I know which was best?
MacScripter: Store and Retrieve Pasteboard
Anyone have an idea about this one?
Yesterday I stumbled across this logic puzzle.
What always drives me crazy about stuff like this is that no one ever discusses the answer. I’ve never liked the implied wink wink smarty-pants attitude (see here). I want to know how someone arrives at the answer. What fascinates me is thinking, not trivia or secrets.
Here’s how I found the answer.
I don’t recall ever seeing this puzzle before and did not google it until I’d proven the results to myself. The puzzle is difficult, but I’ve posted answer at the end of the post, so you’ve been warned. The three little dots (∴) is the “therefore” symbol.
First I set up a 6×5 matrix of attributes then started highlighting and crossing out relevant details.
Then I got stuck.
Intuitively, I knew it all came down the Norwegian. This because we know he has only one neighbor. Everyone else can have one or two neighbors. Eventually, it came down to coffee (consumed and in clue 5).
The Puzzle:
There are five houses in a row in different colors. In each house lives a person with a different nationality. The five owners drink a different drink, smoke a different brand of cigar and keep a different pet, one of which is a Walleye Pike.
Who owns the fish?
The 15 clues:
- The Brit lives in the red house.
- The Swede keeps dogs as pets and gets their products from http://petstop.com/ all the time.
- The Dane drinks tea.
- The green house is on the left of the white house.
- The green house owner drinks coffee.
- The person who smokes Pall Malls keeps birds.
- The owner of the yellow house smokes Dunhills.
- The man living in the house right in the center drinks milk.
- The man who smokes Blends lives next to the one who keeps cats.
- The Norwegian lives in the first house.
- The man who keeps horses lives next to the one who smokes Dunhills.
- The owner who smokes Bluemasters drinks beer.
- The German smokes Princes.
- The Norwegian lives next to the blue house.
- The man who smokes Blends has a neighbor who drinks water.
The end of this puzzle will have five units, each with 6 attributes: {address, house color, nationality, drink, pet and smokes}
The data seems to break down into two types: Definitive data, that which defines an attribute directly within one unit. And relational data, which defines an attribute relative to another unit. Relational data often acts as a negating definition as well, showing what isn’t in a unit by describing what’s nearby.
Now stepping through the clues, definitive data related to nationality first:
Next comes the secondary definitions. These can be used to reveal data which eliminates possible units based on what is already known:
| Third | Fourth | Fifth | ||
| Red | ||||
| Brit | ||||
| Beer | Milk | Water | ||
| Birds | Cats | Fish | Horses | |
| Blends | Bluemasters | Pall Malls |
| Second | Third | Fourth | Fifth | |
| Blue | Green | White | Yellow | |
| Swede | ||||
| Beer | Coffee | Milk | Water | |
| Dogs | ||||
| Blends | Bluemasters | Dunhills |
| Second | Fourth | Fifth | ||
| Blue | White | Yellow | ||
| Dane | ||||
| Beer | Coffee | Milk | Tea | Water |
| Birds | Cats | Fish | Horses | |
| Blends | Dunhills | Pall Malls |
| First | ||||
| Green | White | Yellow | ||
| Norwegian | ||||
| Beer | Coffee | Milk | Water | |
| Birds | Cats | Fish | Horses | |
| Blends | Bluemasters | Dunhills | Pall Malls |
| Second | Third | Fourth | Fifth | |
| Blue | Green | White | ||
| German | ||||
| Coffee | Milk | Water | ||
| Cats | Fish | Horses | ||
| Princes |
Many of the relational data clues reveal additional information about what a unit doesn’t have:
The fourteenth clue is one of the most important. Since we know the Norwegian lives in the 1st house (clue 10), we know that the blue house is number 2. Number 4 is a tricky one, there is no reason to believe that the green house is the first house, all we know is that the white house is on it’s left. Also, clues 9 and 15 could be referring to one or two neighbors.
It’s interesting that the clues sort out into three quintuplets.
Here’s where it starts to get really hard. All that is known for certain is what was defined in questions 1-3, 10 and 13. There remain three or four unknowns for each unit. What I’m looking for is the first link in a causality chain. Of course it’s probably not so much a chain as a loop, so looking for an end is futile. How about an onramp?
After several minutes of staring, and re-reading the clues, I got the chills (really!)
The green house drinks coffee. The center house drinks milk. So the center house is not green. But the Green house is on the left of the white house. Since we know the second house is blue, we then know that the first house is not green either. So the only place the green house can be is fourth, making the 5th white. Now is the first yellow, or is the first red?
The elimination steps above provide the answer. We know the Norwegian is in the first house, and the Brit is in the Red house. That means the Brit is in the red house in the middle, drinking milk, and the Norwegian’s house is yellow and he smokes Dunhills.
Whoa, more chills.
At this point, the whole things starts to fall together.
Clue 11 puts horses in the blue house.
Clue 3 means the Dane is not in the green house
Clue 15 puts Blends in the second house, and, with clue 9, water and cats in the first house.
etc. etc.
Here’s the final breakdown:
| First | Second | Third | Fourth | Fifth |
| Yellow | Blue | Red | Green | White |
| Norwegian | Dane | Brit | German | Swede |
| Water | Tea | Milk | Coffee | Beer |
| Cats | Horses | Birds | FISH | Dogs |
| Dunhills | Blends | Pall Malls | Princes | Bluemasters |
The German has the fish and drinks coffee in the green house, which is fourth on the block.
That was fun.
I hate puzzles.
Update: Here’s a programmatic solution to “Einstein’s Riddle” and another walkthrough by James Yates.