# Problems with Codercise P.1.1

**URL:** <https://discuss.pennylane.ai/t/problems-with-codercise-p-1-1/4119>\
**Category:** Codebook\
**Created:** [February 18, 2024, 1:08pm UTC](https://discuss.pennylane.ai/t/problems-with-codercise-p-1-1/4119 "2024-02-18T13:08:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![erqs](https://avatars.discourse-cdn.com/v4/letter/e/aeb1de/32.png) [@erqs](https://discuss.pennylane.ai/u/erqs)\
**Post date:** [February 18, 2024, 1:08pm UTC](https://discuss.pennylane.ai/t/problems-with-codercise-p-1-1/4119/1 "2024-02-18T13:08:34Z")

</div>

Hi,

I am currently trying to solve the P.1.1. Codercise but I am having trouble getting to the correct answer. If I understood correctly, the “guess\_the\_unitary(unitary)” function should output [1,0] or [0,1] depending on whether U is equal to Z or -Z. My circuit follows the circuit in the picture:  
 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/9/91429befccd40b9ba2f1bebef21373c798738f77.png)  
And I get the expected output according to my understanding. However, I am getting an error that says “Incorrect: the extracted state does not match the input state.” Are those the expected outputs of the function according to the input? Or did I understood wrong what we need to output? I could post the code but that would be probably giving away the answer to the Codercise. I could provide the code if it helps to determine what might be wrong.

Cheers,

Erick

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [February 19, 2024, 10:54pm UTC](https://discuss.pennylane.ai/t/problems-with-codercise-p-1-1/4119/2 "2024-02-19T22:54:07Z")

</div>

Hey @erqs! Welcome to the forum 🕶

If you can post your code that isn’t working that would be great 🙂

---

<div class="post-metadata">

**Author:** ![erqs](https://avatars.discourse-cdn.com/v4/letter/e/aeb1de/32.png) [@erqs](https://discuss.pennylane.ai/u/erqs)\
**Post date:** [February 20, 2024, 8:34am UTC](https://discuss.pennylane.ai/t/problems-with-codercise-p-1-1/4119/3 "2024-02-20T08:34:19Z")

</div>

Hi Isaac,

Thanks for the quick reply, after looking into my code I found what the problem was. I was using `U` instead of `unitary` inside the function. Although the result was the correct output because `U = unitary` in this case, the tests were probably not recognizing it well.

Cheers,  
Erick

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [February 20, 2024, 10:44pm UTC](https://discuss.pennylane.ai/t/problems-with-codercise-p-1-1/4119/4 "2024-02-20T22:44:08Z")

</div>

Ah! Nice! Glad you were able to find the error 🙂. If you encounter any other problems please don’t hesitate to ask!
