Home > Mathematica, Mathematics > Pilgrim’s Progress

Pilgrim’s Progress

The New York Times Number Play: Daniel Finkel’s Pilgrim’s Puzzle is an interesting puzzle.

It was an opportunity to play with Mathematica in assisting finding a solution by cut down trial and error.

I used the following to code the conditions of the puzzle and visualise candidate answers,


fun[x_String] := Module[
{char, set = {{0, 0}}, sum = 0},
char = Characters[x];
Which[# == "s", sum = 2 sum; AppendTo[set, Last@set + {0, -1}],
# == "n", sum = sum/2; AppendTo[set, Last@set + {0, 1}],
# == "e", sum = sum + 2; AppendTo[set, Last@set + {1, 0}],
# == "w", sum = sum - 2; AppendTo[set, Last@set + {-1, 0}]
] & /@ char;
{sum, set}
];
gr[x_String] := Module[
{plot, sm, pts},
{sm, pts} = fun[x];
plot = Graphics[{Point[{0, 0}], {Red, Thick, Line@pts}},
GridLines -> {Range[0, 4, 1], Range[-4, 0, 1]},
PlotRange -> {{0, 4}, {0, -4}}];
Column[{sm, plot}]
];

“ssseenwwsseeee” yielded a possible solution.

I visualize it in the following animated gif. The number in the upper right hand corner is the progressive tax owing.

nytimes_nun

Advertisements
Categories: Mathematica, Mathematics
  1. No comments yet.
  1. August 28, 2013 at 6:35 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: