[Community Puzzle] Merlin's Magic Square

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @Lisa-Has-Ideas,validated by @Konstant,@Remi and @Rafarafa.
If you have any issues, feel free to ping them.

I know I must have solved it some time ago.
That’s it - Coding Games and Programming Challenges to Code Better

Very similar, yet not the same. Here I could invoke the great wizard ‘Xor’. In the other puzzle the grid size could be too large for this approach.

1 Like

And also (as I understand it), each button in that “Very Hard” puzzle all have the same effect.
In This puzzle here, there are 3 different effects based on the location of the button on the square.

The real difference is that you have to find only one button in this puzzle, whereas you a to find a real solution in the other, and with a variable size. That makes the difficulty “very hard”.

3 Likes

Merlin Magic square solution is a easy one or difficult.

That has to be a record for number of Test cases.

1 Like

I’m a bit confused, maybe I’m just missing something obvious?

If the initial sequence is

~ * ~
~ ~ ~
~ * ~

And you do a transformation by pushing 8 (the bottom row will transform)

~ * ~
~ ~ ~
* ~ *

If you push 8 again (it will reverse what it just did)

~ * ~
~ ~ ~
~ * ~

Then 4 (it will reverse the left most column)

* * ~
* ~ ~
* * ~

Then 6 (it will reverse the right most column)

* * *
* ~ *
* * *

Which does get the correct result, as the first test case is 8 8 4 6 ( with 6 being the answer ).

*** Edited for correctness as per @cedricdd

1 Like

Hi,

When you push 4, the affected ones are 1,4,7 but in your example you are changing 1,4,7,8 & 9.

2 Likes

Why is the 4th, and 5th solution is ***, ***, *** ???

I mean, the solution should be ***, ~, ***…

Hi Life –
I’m not sure what you mean. Can you ask it a different way?

Hi everyone,
i’m trying to solve this in python. I’m quite new to programing, and i have difficulties to find a way for solving this puzzle. For now, all i have done is :

  • changing everything in lists (rows and inputs)
  • replacing elements of row when pressing 8 or 2
    My process seems a bit off, and very very long, so do you have a hint for me?

Hi Halarik—
thanks for posting, and thanks for playing my puzzle.

You’re going through a learning process for sure so “struggling thru it” is good for you.

I would suggest you write in pseudocode first.
In other words, write out in plain simple English what you want the computer to do.
Then if you can’t figure out how to translate some of that into python just Google it with the word python at the end like “check if two lists match exactly python“

I also provided in the puzzle two links that will show you someone playing it or let you play it yourself in case that is helpful to inspire the pseudocode.

Thank you for your answer Lisa,
i’ll try this

1 Like

Hi there,
I’m trying to solve this puzzle in C++ but I wonder if there is an issue on it ? :face_with_open_eyes_and_hand_over_mouth:
Some of tests cases work (also some “hard” one) but some don’t. Really strange.
Let me show the inputs for Test case 2. For convenience, my program uses ‘1’ for lit and ‘0’ for non lit.

Each time a key is pressed, the program shows the input, the key pressed, and the output.

Initial input:
~ ~ *
* * ~
* * ~
Apply Lizzo pressed buttons
0 0 1 
1 1 0 
1 1 0 
Key pressed : 4
1 0 1 
0 1 0 
0 1 0 

1 0 1 
0 1 0 
0 1 0 
Key pressed : 5
1 0 1 
0 0 0 
0 1 0 

The test case said : Expected 8 .
This seems really strange. No single key can solve this puzzle in that state :face_with_monocle:
Did I omit something ?

Hi,

When you press the button 5 it will reverse the position 2, 4, 5, 6 & 8

1 Like

:open_mouth:
I missed that ! It was not so explicit for me. I read “reverse the button 5” .
For the others cases, the text enumerated all the buttons that are inverted… but not for the button ‘5’ … :fear:

Many thanks @cedricdd

Hello, I am sure my problem has a absolutely obvious answer, but I seem to be overlooking it. I am coding in javascript btw. Here is some pseudocode:

MMS = MagicSquareSolver(StartSquare, All the buttons Lizzo presses)

for (let k go from 1 to 9){
      Test = MagicSquareSolver(MMS, k)
      if (Test == perfect){
          answer=k
          return answer;
     }
}
function MagicSquareSolver (Square, arr){
     alltheButtons=getalltheButtonsNeededtobepressed(arr);
     for (let i 0 to alltheButtons.length){
           if (Square[alltheButtons[i]=="*"){
              Square[alltheButtons[i]="~";
           } else{
              Square[alltheButtons[i]="*";
       }
       return Square;
}

The Problem I have is that When going through the test process, the MMS array (which should always be the one that lizzo did) changes with the Tests I do, so when I test if 5 is the correct button, it tries it as if lizzo pressed all the buttons she did + 1 to 4. I don´t know if this was clear, please let me know if it wasn´t.

Hope someone can help!

You can compile/run it without error? – when there is no closing square-bracket?