Showing posts with label puzzle. Show all posts
Showing posts with label puzzle. Show all posts

Friday, January 23, 2009

A Unix/Linux "Where's Waldo?" Or "Who Wants Some PI?"

Hey there,

I thought I'd finish off this miserable week (lots of work; little sleep) with a puzzle for everyone, like we do from time to time, if you ever want to check out older posts on seemingly random numbers and the M I U puzzle. There are even more that you can find by just searching the index of the blog.

Today, I'm leaching off a somewhat-familiar challenge: Where's Waldo? Except, in this version he's hiding somewhere in the first million numbers to the right of the decimal point of PI. Finding him will require some really simple conversion, but I have checked to verify that he is, in fact, in there (in more ways than one, depending on how you decide to do your translation of integers to... what have you? :)

Hope you guys have fun with this. I'll post my answers (and their respective rationales) in a near-future post. I've left off the leading 3, since it throws off the nice pretty columns.

CLUE/SPOILER-ALERT: In this version, Waldo is not wearing his trademark hat!!! ;)

Enjoy, and have some PI - Click the picture below to be taken to my offsite page that contains the the million digits. It won't work in Blogspot and it would probably destroy the RSS feed, anyway ;)

Cheers,

who wants more pi?

, Mike




Discover the Free Ebook that shows you how to make 100% commissions on ClickBank!



Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Friday, December 19, 2008

Confusion And Lame Encryption On Linux And Unix

Hey there,

Today, since the holidays are bringing me so much joy (heavy, heavy sarcasm ;), I thought it would be fun to write a post that makes use of some of the principles we've posted on this blog over the past year and combine them to create a treasure hunt of sorts. Actually, a lot of my holiday posts are going to be a little experimental. Since readership goes way down during the holiday season, it's a great time to write less conservative posts. Who knows what I'll be able to get away with? Not me; but I can't wait to find out :)

This isn't an ordinary treasure hunt, of course. No buried treasure or, really, anything of value at the end (Sometimes, I think I missed my calling in life when I passed on being a motivational speaker ;). Not much more than the pride in the knowledge that you figured it out and/or the passive-aggressive loathing you'll feel as you obsess over how I'm not so clever as I think, after all (although, hate me in moderation. You don't want to forget to stick another pin in my effigy before you burn it). This is quickly turning into a very dark post ;)

Of course, I, like most people I know who are around my age and have families of their own, dread the holidays. I love the fact that my kids are having fun, but the women (no offense, ladies...) in my family take this whole shebang way too seriously and the long hard journey to the day after the day after Christmas almost always includes at least one emotional breakdown, semi-psychotic episode or in-fighting about who did what better than whom and enlightening conversations that begin with "can you believe what he/she ...blah, blah, blah." I think if we all just got back to the commercialism that the holidays are really all about, everything would be perfectly fine and we'd all be happy again.

Here's a good tip, that I've found always serves the user well: Whenever I start to feel like I'm going to kill a relative during the peak of the festivities, I think to myself: What would Jesus do? I pause, reflect and then just figure "screw it" and try to get on with my life ;)

Anyway, before I lift your spirits up too high, here's what I've got for you today (hint: the next few lines are laden with clues. All that stuff above was crazy talk. And, if you're a family member of mine, of course I didn't mean a word of it ;) The jumble of numbers that looks like an octal dump was encrypted using a perl script that we posted to this blog some time ago. Of course the encrypted bash script has had it's name and attribution removed so those of you who can read octal won't get off easy ;) The script itself is all mashed together using a security method we've practiced in a few posts on this blog which makes scripts less likely to be mucked with by compressing them and, essentially, making them really long one-liners.

If you figure out what the script is and can email me the name (which is listed in the post that the obfuscated and lame-encrypted script originally came from; in the script headers - plain as day), I'll rewrite cabletv.sh for you, since zap2it changed their output format a month after our reader base (and this is impressive, I think) began apparently kicking the cr## out of them 24x7 (on top of the massive count of regular folk who used it through a web browser, as it was intended to be viewed). My apologies to zap2it, of course. Hopefully, they're not too upset. Really, I'd be ecstatic if I could get a Google PR of 7 and an Alexa Rank of 2,977 with 253,590 backlinks (I'm just guesstimating ;).

My time and effort is about the only thing I can afford to give this Christmas. All the money's going toward buying the kids' presents, because I want them to remember their childhood fondly (which gives me panic attacks ;) and not as a time of recession, conservation and perceived punishment for some huge corporation's massive screw-ups. Hopefully, my sheltering doesn't end up producing intolerable adults who'll scorn my existence later in life and/or try to have me declared incompetent so they can take control over my pocket change ;)

Happy Holidays to you all and enjoy the hunt :)

P.S. Check this post for a halfway decent way to download this code without having to manually convert it back from a single line! Look for the step-by-step method I use, when I can't get to the admin interface of this blog, in section 2.

Cheers,


Creative Commons License


This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License

043 041 057 142 151 156 057 142 141 163 150 012 012 151 146 040
133 040 044 043 040 055 154 164 040 062 040 055 141 040 044 043
040 055 156 145 040 060 040 135 073 164 150 145 156 040 145 143
150 157 040 042 125 163 141 147 145 072 040 044 060 040 125 122
114 040 123 145 141 162 143 150 137 124 145 162 155 050 163 051
042 073 145 143 150 157 040 042 125 122 114 040 167 151 164 150
040 157 162 040 167 151 164 150 040 150 164 164 160 050 163 051
072 057 057 054 040 146 164 160 072 057 057 054 040 145 164 143
042 073 145 170 151 164 040 061 073 146 151 073 151 146 040 133
040 044 043 040 055 145 161 040 060 040 135 073 164 150 145 156
040 167 150 151 154 145 040 162 145 141 144 040 170 040 171 073
144 157 040 165 162 154 075 044 170 073 040 163 145 141 162 143
150 137 164 145 162 155 163 075 044 171 073 040 044 060 040 044
170 040 042 044 171 042 073 144 157 156 145 073 145 170 151 164
040 060 073 145 154 163 145 040 165 162 154 075 044 061 073 163
150 151 146 164 073 163 145 141 162 143 150 137 164 145 162 155
163 075 044 100 073 146 151 073 142 141 163 145 075 060 073 156
165 155 075 061 073 163 164 141 162 164 075 060 073 155 165 154
164 151 160 154 145 137 163 145 141 162 143 150 075 060 073 156
157 164 137 146 157 165 156 144 075 060 073 146 157 162 040 170
040 151 156 040 044 163 145 141 162 143 150 137 164 145 162 155
163 073 144 157 040 151 146 040 133 040 044 155 165 154 164 151
160 154 145 137 163 145 141 162 143 150 040 055 145 161 040 060
040 135 073 164 150 145 156 040 163 145 141 162 143 150 137 163
164 162 151 156 147 075 044 170 073 155 165 154 164 151 160 154
145 137 163 145 141 162 143 150 075 061 073 145 154 163 145 040
163 145 141 162 143 150 137 163 164 162 151 156 147 075 042 044
173 163 145 141 162 143 150 137 163 164 162 151 156 147 175 053
044 170 042 073 146 151 073 144 157 156 145 073 145 143 150 157
040 042 123 145 141 162 143 150 151 156 147 040 106 157 162 040
107 157 157 147 154 145 040 111 156 144 145 170 040 106 157 162
040 044 165 162 154 040 127 151 164 150 040 123 145 141 162 143
150 040 124 145 162 155 163 072 040 044 163 145 141 162 143 150
137 164 145 162 155 163 056 056 056 042 073 145 143 150 157 073
156 165 155 137 162 145 163 165 154 164 163 075 140 167 147 145
164 040 055 161 040 055 055 165 163 145 162 055 141 147 145 156
164 075 106 151 162 145 146 157 170 040 055 117 040 055 040 150
164 164 160 072 057 057 167 167 167 056 147 157 157 147 154 145
056 143 157 155 057 163 145 141 162 143 150 077 161 075 044 163
145 141 162 143 150 137 163 164 162 151 156 147 134 046 150 154
075 145 156 134 046 163 141 146 145 075 157 146 146 134 046 160
167 163 164 075 061 134 046 163 164 141 162 164 075 044 163 164
141 162 164 134 046 163 141 075 116 174 141 167 153 040 047 173
040 151 146 040 050 040 044 060 040 176 040 057 157 146 040 141
142 157 165 164 040 074 142 076 056 052 074 134 057 142 076 040
146 157 162 057 040 051 040 160 162 151 156 164 040 044 060 040
175 047 174 141 167 153 040 055 106 042 157 146 040 141 142 157
165 164 042 040 047 173 160 162 151 156 164 040 044 062 175 047
174 141 167 153 040 055 106 042 074 142 076 042 040 047 173 160
162 151 156 164 040 044 062 175 047 174 141 167 153 040 055 106
042 074 057 142 076 042 040 047 173 160 162 151 156 164 040 044
061 175 047 140 073 167 150 151 154 145 040 072 073 144 157 040
151 146 040 133 040 044 156 157 164 137 146 157 165 156 144 040
055 145 161 040 061 040 135 073 164 150 145 156 040 142 162 145
141 153 073 146 151 073 167 147 145 164 040 055 161 040 055 055
165 163 145 162 055 141 147 145 156 164 075 106 151 162 145 146
157 170 040 055 117 040 055 040 150 164 164 160 072 057 057 167
167 167 056 147 157 157 147 154 145 056 143 157 155 057 163 145
141 162 143 150 077 161 075 044 163 145 141 162 143 150 137 163
164 162 151 156 147 134 046 156 165 155 075 061 060 060 134 046
150 154 075 145 156 134 046 163 141 146 145 075 157 146 146 134
046 160 167 163 164 075 061 134 046 163 164 141 162 164 075 044
163 164 141 162 164 134 046 163 141 075 116 174 163 145 144 040
047 163 057 074 141 040 150 162 145 146 075 134 042 134 050 133
136 134 042 135 052 134 051 134 042 040 143 154 141 163 163 075
154 076 057 134 156 134 061 134 156 057 147 047 174 141 167 153
040 055 166 040 156 165 155 075 044 156 165 155 040 055 166 040
142 141 163 145 075 044 142 141 163 145 040 047 173 040 151 146
040 050 040 044 061 040 176 040 057 136 150 164 164 160 057 040
051 040 160 162 151 156 164 040 142 141 163 145 054 156 165 155
053 053 054 044 116 106 040 175 047 174 141 167 153 040 047 173
040 151 146 040 050 040 044 062 040 074 040 061 060 040 051 040
160 162 151 156 164 040 042 107 157 157 147 154 145 040 111 156
144 145 170 040 116 165 155 142 145 162 040 042 040 044 061 040
042 060 042 040 044 062 040 042 040 106 157 162 040 120 141 147
145 072 040 042 040 044 063 073 040 145 154 163 145 040 151 146
040 050 040 044 062 040 075 075 040 061 060 060 040 051 040 160
162 151 156 164 040 042 107 157 157 147 154 145 040 111 156 144
145 170 040 116 165 155 142 145 162 040 042 040 044 061 053 061
040 042 060 060 040 106 157 162 040 120 141 147 145 072 040 042
040 044 063 073 145 154 163 145 040 160 162 151 156 164 040 042
107 157 157 147 154 145 040 111 156 144 145 170 040 116 165 155
142 145 162 040 042 040 044 061 040 044 062 040 042 040 106 157
162 040 120 141 147 145 072 040 042 040 044 063 040 175 047 174
147 162 145 160 040 055 151 040 044 165 162 154 073 151 146 040
133 040 044 077 040 055 156 145 040 060 040 135 073 164 150 145
156 040 154 145 164 040 163 164 141 162 164 075 044 163 164 141
162 164 053 061 060 060 073 151 146 040 133 040 044 163 164 141
162 164 040 055 145 161 040 061 060 060 060 040 135 073 164 150
145 156 040 156 157 164 137 146 157 165 156 144 075 061 073 151
146 040 133 040 044 156 157 164 137 146 157 165 156 144 040 055
145 161 040 061 040 135 073 164 150 145 156 040 142 162 145 141
153 073 146 151 073 146 151 073 154 145 164 040 142 141 163 145
075 044 142 141 163 145 053 061 073 146 151 162 163 164 137 160
141 147 145 075 060 073 145 154 163 145 040 142 162 145 141 153
073 146 151 073 154 145 164 040 163 154 145 145 160 137 164 151
155 145 075 044 173 122 101 116 104 117 115 175 057 066 060 060
073 145 143 150 157 040 042 116 157 164 040 111 156 040 124 157
160 040 044 163 164 141 162 164 040 122 145 163 165 154 164 163
072 040 123 154 145 145 160 151 156 147 040 044 163 154 145 145
160 137 164 151 155 145 040 163 145 143 157 156 144 163 056 056
056 042 073 163 154 145 145 160 040 044 163 154 145 145 160 137
164 151 155 145 073 144 157 156 145 073 151 146 040 133 040 044
156 157 164 137 146 157 165 156 144 040 055 145 161 040 061 040
135 073 164 150 145 156 040 145 143 150 157 040 042 116 157 164
040 106 157 165 156 144 040 111 156 040 106 151 162 163 164 040
061 054 060 060 060 040 111 156 144 145 170 040 122 145 163 165
154 164 163 040 055 040 107 157 157 147 154 145 047 163 040 110
141 162 144 040 114 151 155 151 164 042 073 145 143 150 157 073
146 151 073 145 143 150 157 040 042 117 165 164 040 117 146 040
101 160 160 162 157 170 151 155 141 164 145 154 171 040 044 156
165 155 137 162 145 163 165 154 164 163 040 122 145 163 165 154
164 163 042 073 145 143 150 157 073 145 170 151 164 040 060


, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Sunday, June 1, 2008

Perl Script To Help Solve the "M I U" puzzle on Linux or Unix

Updated 6/02 - Blogspot bracket interpretation was showing the script incorrectly.

Hey There,

For this "Lazy Sunday" post, as promised, we're going to be taking a look, again, at formal systems and the "MI to MU" puzzle presented by Douglas R. Hofstadter in his book "Godel, Escher, Bach: An Eternal Golden Braid." And, also as promised, I've put together a Perl script to walk you through it, that should run on most Linux and Unix flavours (including Cygwin for Windows).

At the end of today's post, I've attached a simple Perl program that will let you attack this puzzle and solve it, while being certain that you're adhering to "the rules." I'm not a big fan of following the rules, in general (you can get a lot more done, and make significant breakthroughs, by ignoring convention ;), but a "formal system" can't exist without them.

Many of you may have already solved this puzzle on your own. If you'll permit me the opportunity to throw you a hint (assuming you haven't solved it yet), the answer is all in the way you perceive your boundaries, as laid out by the rules. The first time I tried to solve this I ended up with a few pieces of paper describing a decision-tree that I could barely comprehend (even though I'd written it ;). The third time I tried it, I realized that I was making assumptions, based on the "rules" presented, that were completely incorrect. In fact, by following the rules exactly (and removing any thought-prejudice I had with regards to what the rules made possible) I was able to solve it in the minimum number of steps.

Needless to say, this script isn't "perfect." For instance, I didn't bother to include extra code to do case-insensitive input matching and settled with creating a simple menu that only accepts the number of your selection as input (So, for instance, when you're presented with your options, you'll have to type 4 - rather than the first letter of the option - and if you're asked for string input, you'll need to enter "I" rather than "i", etc).

I spent most of my time writing this script trying to figure out how many different ways the puzzle could permutate and stray from the rules (and, of course, fixing those holes) rather than making it aesthetically pleasing. It will probably offend Perl purists, as well, since I wrote it as quickly as possible, with little regard for efficiency and elegance of the code ;)

For a refresher on the rules of this puzzle, and examples of valid rule applications, check out yesterday's post regarding formal systems.

Here's hoping you enjoy a little brain-teaser as much as I do, and that this simple Perl script helps break you out of any "strange loops" you might have in your subconscious that prevent you from reaching the solution!

Cheers


Creative Commons License


This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License

#!/usr/bin/perl

#
# mimu.pl - Solve the M I U formal system MI to MU puzzle by the rules
#
# 2008 - Mike Golvach - eggi@comcast.net
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#

$start = "MI";
print "\nYour string is $start\n\n";

until ( $start eq "MU" ) {
if ( $start eq "M" ) {
print "\nYou Cannot Solve This\n";
print "Puzzle Within This Formal\n";
print "System From This Point On\n";
print "Try Again!\n\n";
exit;
}
print "Which rule to you want to apply?\n";
print "1. Add a U to end of string if string ends in I\n";
print "2. Duplicate a pattern following an M - Mx = Mxx\n";
print "3. Convert III to U\n";
print "4. Remove UU\n";
print "5. Quit\n";
print "?> ";
$response = <STDIN>;
if ( $response == 1 ) {
$test = $start;
$test =~ s/^.*(I)$/$1/;
if ( $test eq "I" ) {
$start = $start . "U";
print "\nYour string is now $start\n\n";
} else {
print "\nLast letter is not an I, cannot add U\n\n";
print "Your string is still $start\n\n";
}

} elsif ( $response == 2 ) {
print "\nWhat string do you want to duplicate?\n\n";
$response = <STDIN>;
chomp($response);
if ( $response =~ /^ * *$/ ) {
print "\nNo Input Received\n\n";
print "Your string is still $start\n\n";
next;
}
if ( $start =~ /^M$response.*$/ ) {
print "\nDuplicating $response\n\n";
$start =~ s/^(M)($response)(.*)$/$1$2$2$3/;
print "Your string is now $start\n\n";
} else {
print "\nThe string $response does not follow your M\n\n";
print "Your string is still $start\n\n";
}
} elsif ( $response == 3 ) {
undef @tripIs;
$string = $start;
$char = 'III';
$offset = 0;

$result = index($string, $char, $offset);
if ( $result == -1 ) {
print "\nCannot Find III in your string\n\n";
print "\nYour string is still $start\n\n";
next;
}

while ($result != -1) {
push(@tripIs, "$result");
$offset = $result + 1;
$result = index($string, $char, $offset);
}
print "\nFrom left to right, which offset\n";
print "of III would you like to replace?\n\n";
if ( defined @tripIs ) {
foreach $triplet (@tripIs) {
print "${triplet}: III\n";
$count++;
}
}
print "\n";
chomp($response = <STDIN>);
$temp = substr($string, $response, 3);
if ( $temp ne "III" ) {
print "\nCannot Find III At Index $response\n\n";
print "\nYour string is still $start\n\n";
} else {
substr($string, $response, 3) = 'U';
$start = $string;
print "\nYour string is now $start\n\n";
}
} elsif ( $response == 4 ) {
undef @doubleUs;
$string = $start;
$char = 'UU';
$offset = 0;

$result = index($string, $char, $offset);
if ( $result == -1 ) {
print "\nCannot Find UU in your string\n\n";
print "\nYour string is still $start\n\n";
next;
}

while ($result != -1) {
push(@doubleUs, "$result");
$offset = $result + 1;
$result = index($string, $char, $offset);
}
print "\nFrom left to right, which offset\n";
print "of UU would you like to remove?\n\n";
if ( defined @doubleUs ) {
foreach $doubleu (@doubleUs) {
print "${doubleu}: UU\n";
$count++;
}
}
print "\n";
chomp($response = <STDIN>);
$temp = substr($string, $response, 2);
if ( $temp ne "UU" ) {
print "\nCannot Find UU At Index $response\n\n";
print "\nYour string is still $start\n\n";
} else {
substr($string, $response, 2) = '';
$start = $string;
print "\nYour string is now $start\n\n";
}
} elsif ( $response ==5 ) {
print "\nYou quit with your string at $start\n\n";
exit;
} else {
print "WTF?\n";
print "\nYour string is still $start\n\n";
}
}
print "\nYour string is $start\n\n";
print "Puzzle Solved! Congrats\n\n";
exit;


, Mike

Saturday, May 31, 2008

Looking At Formal Systems On Linux and Unix

Hey There,

For today's post, we're going to put out a brain-teaser that won't get solved (at least on this blog) until tomorrow. It's based on a formal system (which is basically a set of rules, with specific applications, used as a method to solve an equation or problem) invented by Emil Post back in the 1920's and is most commonly referred to as a "post production system."

This basic formal system was re-popularized by Douglas R. Hofstadter in his book Godel, Escher, Bach: An Eternal Golden Braid" when he introduced the concept to folks, who weren't especially crazy about such abstract notions, by way of a little puzzle.

For today's post, we're going to reproduce (paraphrased, of course) that puzzle and let you see if you can solve it (or, if you can prove that it can't be solved, which is a possibility).

For tomorrow's post, we'll be putting up a script for Linux or Unix that will make this whole process much easier and will give you the option to "attack" this problem as quickly or slowly as you prefer. While the script will relieve you of the pleasure of completing this mental exercise (if it's at all possible to complete), it will either get you to the answer very quickly or make you wonder how long it might possibly take to solve. Considering the ingredients, that may turn out to be a huge chunk of your time ;)

And here we go. I hope you enjoy this puzzle as much as I did:

We begin with an absolute. You are starting out with a single string (which is absolutely defined, within the context of this formal system and puzzle, as a set of characters in a specific order - e.g. MI is not the same as IM). That absolute (or starting point) is simply "MI." (Note that all punctuation marks are "not" parts of the strings ;)

Give the string "MI," your goal will be to convert that string into the string "MU." Please note that, although a string like MIMUIM is a valid member of the M I U formal system, given the starting string of MI, you will never be able to have an M anywhere but in the first position. Sadly, this does not make finding the answer easy ;)

There are 4, and only 4, rules in this formal system, and you can only correctly solve the puzzle by applying any and/or all of them, one at a time, for as long as it takes to get you to "MU."

Rule 1: If your string ends with an "I", you can add a "U" to the end of it.

Ex: MI can become MIU.

Rule 2: If you have a string of the form "Mx," you can change that to "Mxx." Note here that the variable x can refer to a string (not necessarily just one character) and that only the letters M, I and U will ever exist in any string you produce by application of these rules. x is simply meant to be used as a variable notation.

Ex: MI can become MII
MIU can become MIUIU


The one thing to remember about this rule is that, once you've picked your character, or string, you can only duplicate it once per invocation of the rule. For instance, this is not acceptable:

Ex: MIU cannot become MIUIUII (duplicating "IU" and then duplicating the "I" before the "U," after the "I." You could do the following, however, in a number of steps:
MIU can become MIIUIU (by duplicating the "I" first, and then duplicating the "IU" from the resultant string)

Rule 3: If the substring "III" appears in your string, you can replace "III" with "U," but you may not do the opposite:

Ex: MIII can become MU
Ex: MU cannot become MIII


Rule 4: If "UU" occurs within your string (at any point), you can remove it from the string:

Ex: MIUUI can become MII

Using these 4 "rules of production" (or "rules of inference") can you take your initial string "MI" and change it to "MU"? Also, if it's not possible, is that provable? And, if it is possible, what's the fastest way to do it?

Have fun trying to figure it out. If you already own the aforementioned book, you may know the solution already (it's hidden somewhere in the approximately 700+ pages). Sometimes, though, your individual path to the solution will teach you a lot more than you'd learn by being told the answer :)

Enjoy,

, Mike