How Many Moves to Solve the IMPACT Riddle Using Specific Rules?

  • Context: Undergrad 
  • Thread starter Thread starter MrJones
  • Start date Start date
  • Tags Tags
    Nuts
Click For Summary

Discussion Overview

The discussion revolves around solving a riddle involving the rearrangement of letters to form the word "IMPACT" using specific move rules. Participants explore various methods, including programming approaches, to determine the minimum number of moves required to achieve the solution.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant expresses frustration at not being able to solve the riddle after multiple attempts and seeks help.
  • Another participant mentions a numerical approach but prefers to visualize the letters instead.
  • A participant claims to have solved the riddle in 10 steps using a program that alternates between the two types of moves.
  • There is a discussion about the programming methods used, with one participant describing a breadth-first search algorithm that finds the shortest solution path.
  • Some participants express confusion regarding the complexity of the program and its output.
  • Another participant shares the complete code of their program, detailing how it implements the two types of moves to find the solution.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best approach to solve the riddle, with some favoring programming methods while others prefer manual reasoning. There is also uncertainty regarding the efficiency and complexity of the programming solutions discussed.

Contextual Notes

The discussion includes various assumptions about the effectiveness of different problem-solving strategies and the limitations of the programming approaches mentioned. Some participants express uncertainty about the clarity of the program's output and its implications for solving the riddle.

MrJones
Messages
8
Reaction score
0
Hello, Folks! This is my first post and I'm pretty excited about finding this web forum with so many forums dedicated to different fields of sciences, but I thought I'd start here first. I've had this riddle for approximately a week and a half, and it has completely befuddled me:

"Mr. McPita is playing a word game and he has received the letters that spell his name. There is only one word he can make (IMPACT), but first he will have to reorder the letters. To this end, he allows himself two types of moves:

1: Place the letters in the odd positions before the letters in the even positions: M C P I T A => M P T C I A

OR

2: Bring the letter in the first position to the end of the line: M C P I T A => C P I T A M

Using the fewest number of moves (using the above rules) create the word IMPACT."

I'm sure there's probably an easy program that could be written to figure this out, but I am completely at a loss here and I am dying to figure this out. Can someone show me the steps to the answer?? I feel like I've done this 100 different ways, and the closest I've come is IMTPAC.
 
Mathematics news on Phys.org
Yes.

I thought about using numbers, but I didn't think it would work as well for me.
 
Sorry, didn't mean to make you look like you were talking to yourself. o:) I deleted my post when I realzied I had nothing of value to add.
 
Oh, well I believe it would be valuable to someone who would rather solve the puzzle in a numerical manner, but I prefer to see the letters to solve the riddle.

I'm sure it's rather simple and I'm just not in the right frame of mind to solve it
 
I wrote a quick program that solved it in 10 steps, using 4 "type 2" moves and 6 "type 1" moves.
The 5th word (of all 11) is "CATIMP"
DaveE
The moves alternate from one to the other, except twice.
 
Last edited:
That's fantastic... 10 moves!

I finally got it approximately 2 hours ago, but it took me 21 steps.

10 steps? I have to try this.
 
davee123 said:
I wrote a quick program that solved it in 10 steps, using 4 "type 2" moves and 6 "type 1" moves.

What did your program do? Did it use a brute force permutational approach and you simply waited for it to spit out a valid answer? Or did you use some algorithm?

It seems to me that, unless you used the brute force approach, you would first have to solve the problem - i.e. doing 80% of the heavy-lifting before even being able to write a program to finish it.
 
I just did a breadth-first search, which guarantees that the first solution it finds is the shortest-length path. There might be several solutions that are all 10 steps long-- It didn't check for those.

To be more explicit, it performed a loop on all known strings-- each of which has a "shortest path" to them. Then, for each one, it performs a "type 1" and a "type 2" modification. If the resultant string is not already in the list of known strings, it adds it to the list, along with the originating string and the modification type. Hence:

Round 1:
Known strings:
MCPITA, distance: 0, originating string: none, explored: no
MCPITA --- Type 1 ---> MPTCIA
MCPITA --- Type 2 ---> CPITAM

Round 2:
Known strings:
MCPITA, distance: 0, originating string: none, explored: yes
(skip)
MPTCIA, distance: 1, originating string: MCPITA, explored: no
MPTCIA --- Type 1 ---> MTIPCA
MPTCIA --- Type 2 ---> PTCIAM
CPITAM, distance: 1, originating string: MCPITA, explored: no
CPITAM --- Type 1 ---> CIAPTM
CPITAM --- Type 2 ---> PITAMC

Round 3:
Known strings:
MCPITA, distance: 0, originating string: none, explored: yes
(skip)
MPTCIA, distance: 1, originating string: MCPITA, explored: yes
(skip)
CPITAM, distance: 1, originating string: MCPITA, explored: yes
(skip)
MTIPCA, distance: 2, originating string: MPTCIA, explored: no
MTIPCA --- Type 1 ---> MICTPA
MTIPCA --- Type 2 ---> TIPCAM
PTCIAM, distance: 2, originating string: MPTCIA, explored: no
PTCIAM --- Type 1 ---> PCATIM
PTCIAM --- Type 2 ---> TCIAMP
CIAPTM, distance: 2, originating string: CPITAM, explored: no
CIAPTM --- Type 1 ---> CATIPM
CIAPTM --- Type 2 ---> IAPTMC
PITAMC, distance: 2, originating string: CPITAM, explored: no
PITAMC --- Type 1 ---> PTMIAC
PITAMC --- Type 2 ---> ITAMCP

Etc.

Anyway, it's probably unnecessarily efficient in this example, because there's only 1024 different permutations that are 10 long-- you could try all the permutations that were 1 long, then 2, then 3, etc, until you got a solution, which would yield the same result, but would do... 2046 actual calculations of the string? That's pretty trivial. The above solution is a tad more efficient in a case like this, but would be MUCH more efficient if (say) the solution were something like 100 permutations out rather than 10.

DaveE
 
Last edited:
Over my head. And I'm a programmer. :redface:
 
  • #10
Wow... So apparently the program was not so simple. At least it doesn't appear that way...

So what did it find the combination to be (1,2,1,2,2?)

I'm having a hard time reading what it did
 
  • #11
MrJones said:
So apparently the program was not so simple.

I didn't think it was that complicated-- maybe I've been doing too many projecteuler problems or something. The entirety of the code is:

Code:
#!/usr/bin/perl

%strs = ('MCPITA' => { dist => 0, from => '', type => 0, exp => 0, });
MLOOP: for($i=0;$i<100;$i++) {
    foreach my $str (keys %strs) {
        next if($strs{$str}{exp});
        $m1 = move1($str);
        if(!exists($strs{$m1}) || $strs{$m1}{dist} > ($strs{$str}{dist}+1)) {
            $strs{$m1} = { dist => ($strs{$str}{dist} + 1), from => $str, type => 1, };
            last MLOOP if($m1 eq "IMPACT");
        }
        $m2 = move2($str);
        if(!exists($strs{$m2}) || $strs{$m2}{dist} > ($strs{$str}{dist}+1)) {
            $strs{$m2} = { dist => ($strs{$str}{dist} + 1), from => $str, type => 2, };
            last MLOOP if($m2 eq "IMPACT");
        }
        $strs{$str}{exp} = 1;
    }
}

$str = "IMPACT";
while($strs{$str}{dist} && !$strs{$str}{done}) {
    $strs{$str}{done} = 1;
    print "$str \<-- $strs{$str}{from} ($strs{$str}{type})\n";
    $str = $strs{$str}{from};
}

sub move1 {
    my($str) = @_;
    my($odds,$evens);
    for(my $i=0;$i<length($str);$i++) {
        if($i % 2) { $odds .= substr($str,$i,1); }
        else { $evens .= substr($str,$i,1); }
    }
    return "$evens$odds";
}

sub move2 {
    my($str) = @_;
    return substr($str,1).substr($str,0,1);
}



MrJones said:
So what did it find the combination to be (1,2,1,2,2?)

The output of the program is:
Code:
IMPACT <-- TIMPAC (2)
TIMPAC <-- TPIAMC (1)
TPIAMC <-- TAPMIC (1)
TAPMIC <-- TMAIPC (1)
TMAIPC <-- CTMAIP (2)
CTMAIP <-- CATIMP (1)
CATIMP <-- PCATIM (2)
PCATIM <-- PTCIAM (1)
PTCIAM <-- MPTCIA (2)
MPTCIA <-- MCPITA (1)

(Which just shows the progression in reverse)

DaveE
 

Similar threads

  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 26 ·
Replies
26
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 125 ·
5
Replies
125
Views
20K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 55 ·
2
Replies
55
Views
5K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K