## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
• Create your own community
##### Activity
@githg22_gitlab: Is that one of the contest problems? If so, you should be able to do it without measurement, so that your solution can in principle be used when your input register is in superposition.

@githg22_gitlab: Taking a hint from the problem statement itself, I'd suggest that the last sentence is especially relevant here.

"This operation can be implemented using just the X gate and its controlled variants."

Harshit Garg
@githg22_gitlab
@cgranade It's more like I'm using an extra qubit that needs to be reset and that functor wouldn't keep the operation Adj
And I can't find a way to test it locally through python
Sagar Mishra
@achieveordie
I've got a small question, Can we apply the unwrapping operator on LittleEndian? I don't think we can do that because of the no-clone theorem, I can solve the increment problem with array of qubits, but cannot wrap my mind to do that on LittleEndian. I couldn't find any relevant operation in Microsoft.Quantum.Arithematic to apply X gate on Little Endian either...
Harshit Garg
@githg22_gitlab
Yup you can do that
Just write !
Just write register!
Stupid gitter
LittleEndian is basically a different name for Qubit[], literally no other difference
Sagar Mishra
@achieveordie
Won't that be qarray = LittleEndian!?
I mean, I get what you mean, but I still find it a bit uncomfortable without having to use using()
Also, as a side question, does the changes that we make on the unwrapped array reflected automatically in the user-defined LittleEndian?
Harshit Garg
@githg22_gitlab
I think it does
So umm
Cam you give a hint as to how you solved the problem?
I've been stuck at this for the past 24 hours
Sagar Mishra
@achieveordie
I hope it isn't against the protocol, say you've got N=3. On a paper, write down the values in LittleEndian format from 0 to 7 and then write down the required result, again in LittleEndian format. You'll notice something, one of the qubits will always flip no matter what while the others will flip if a certain condition is satisfied(hence the usage of Controlled X) I hope this will help you.
Also, I tried using the unwrap operator and I got a compilation error saying the expression can only be applied on user-defined type while LittleEndian is a custom user-defined(Microsoft.Quantum.Arithematic.LittleEndian)
Harshit Garg
@githg22_gitlab
That's weird I could use it in my code
Its not against the rules btw, in warmup you're free to discuss hints
Sagar Mishra
@achieveordie
what was your syntax?
like the expression?
Harshit Garg
@githg22_gitlab
(register!)
Length(register!)
Sagar Mishra
@achieveordie
And if that is so, did you solve problem C?
Harshit Garg
@githg22_gitlab
For example
Yeah I solved C
Sagar Mishra
@achieveordie
and if I wanted to access some element, how would do that in LittleEndian?
Any hints?
Harshit Garg
@githg22_gitlab
register![1]
C is actually similar to a problem in Quantum Katas
It's kind of a hack-y method
Sagar Mishra
@achieveordie
In which notebook is it?
Harshit Garg
@githg22_gitlab
Superposition
Sagar Mishra
@achieveordie
X(LittleEndian![0]); is this a valid expression?
nevermind, I'm stupid.
wasted 24 hours on something this stupid
Harshit Garg
@githg22_gitlab
hehe it happens
Were you writing LittleEndian instead of register?
Sagar Mishra
@achieveordie
yep, not the first time when I've doubted my sanity. Thanks for the help
Harshit Garg
@githg22_gitlab
Thank you sir Increment problem was so simple I was thinking wayy too much
@githg22_gitlab: If you allocate an extra qubit, then it has to be returned to |0⟩ at the end of the using block. As you note, you can't use measurement to do that in an adjointable operation; given that resetting is a special case of measurement, the Reset operation will also fail to preserve adjointability. The trick is that you need to coherently reset the qubit to |0⟩ without measurement. You can do that because you know exactly what state it's in at the end of the using, and can unprepare it using only unitary operations. The within/apply feature of Q# or the ApplyWithCA operation will be very handy here.

By the way, @crazy4pi314 will be streaming with @bettinaheim about the Q# compiler today in a little under three hours if anyone is interested to join at https://twitch.tv/crazy4pi314. More details at https://twitter.com/crazy4pi314/status/1271837229221101569.

Stream starting in just a few moments at https://www.twitch.tv/crazy4pi314!
vashisth malik
I know the difference between Identity and X gate and there adjoint are they themselves. But i did not understand coding part like this part "operation Solve (unitary : (Qubit => Unit is Adj+Ctl)) : Int " is in this part we are calling qubit to unitary ? Any resource to understand this will be helpful?
@VashisthMalik_twitter: The type of an operation that takes an input of type 'T and that returns an output of type 'U is written as 'T => 'U; thus, unitary : (Qubit = > Unit is Adj + Ctl) indicates that unitary takes a Qubit input and returns Unit. The is Adj + Ctl tells you that unitary is adjointable and controllable (very important for some of the contest problems!). In this case, we can read the signature of Solve as telling us that it takes an adjointable and controllable single-qubit operation, and returns an Int.
Stream's now live, by the way, if you want to learn more about the internals of the Q# compiler! 💕
vashisth malik
on which i perform functor like Adjoint Unitary (?) . what is the name of qubit ? is it qubit itself?
vashisth malik