By Nickolas, 2 years ago,

Microsoft's Quantum Team has good news for quantum enthusiasts and coders looking for new challenges. We are excited to announce Microsoft Q# Coding Contest — Summer 2018! By entering the contest, you can hone your quantum coding skills by tackling problems of varying difficulty and implementing solutions in the quantum programming language Q#. Winners will receive a Microsoft Quantum T-shirt!

Quantum computing is a radically different computing paradigm compared to classical computing. Indeed, it is so different that some tasks that are believed to be classically intractable (such as factoring integers, computing discrete logarithms on elliptic curves, or simulating physical systems) can be performed efficiently on a quantum computer. Microsoft recently introduced the Quantum Development Kit which includes Q# — a new programming language to express quantum programs in a way that makes it easier for classical coders to enter the space. Q# integrates into Visual Studio or Visual Studio Code development environments, and is available as a command line tool. Visual Studio Code allows development under Windows, macOS, and Linux.

The contest will run from July 6 — 9 and will consist of increasingly challenging tasks on introductory topics in quantum computing: superposition, measurement, oracles and simple algorithms.

The rules of the contest are:

• The contest will have 12 15 tasks of various complexity levels.
• To solve each task, you will write Q# code to implement the described transformation on the given set of qubits or to analyze the state of a set of qubits. Solutions are accepted in Q# only.
• The solution is correct if it passes all tests from a predefined test set. You will know whether the solution is correct soon after submitting it.
• Participants are ranked according to the number of correctly solved tasks.
• Ties are resolved based on lowest total penalty time for all tasks, which is computed as follows. For each solved task, a penalty is set to the submission time of that task (the time since the start of the contest). An extra penalty of 20 minutes is added for each failed submission on solved tasks (i.e., if you never solve the task, you will not be penalized for trying that task).
• The top 50 ranked participants will receive a Microsoft Quantum T-shirt.
• NO PURCHASE NECESSARY. Must be 16 years of age or older. Game ends 7/9/18. For details, see Official Rules.

From June 29 to July 2, we will offer a warmup round with simpler tasks on the topics covered in the main contest. Participation in the warmup round is entirely optional. The warmup round gives you an opportunity to get familiar with the contest environment and submission system beforehand, as well as refresh or learn the basics of quantum computing and Q# programming language. During the warmup round everybody is encouraged to discuss the tasks and the solutions. 24 hours after the start of the warmup round we will publish explanations and solutions to the easiest three problems. Once the warmup round is over, we will publish the editorials on the contest page explaining both the quantum computing logic behind the solution and the Q# implementation.

To start, please refer to Q# installation instructions and language reference.

Quantum computing and Q# materials:

For first time Codeforces users:

1. Create user account here.
2. Register for the warmup round here.
3. Register for the contest here.
4. Once the warmup round starts on June 29, access the problems and see additional contest materials here.
5. Once the contest starts on July 6, access the problems here.

Good luck! We hope you enjoy the contest!

Update. Explanations for problems A, D and G of the warmup round are published.

Update. The warmup round is over. Explanations for all problems are published.

• +413

 » 2 years ago, # |   +12 Is it rated?)
•  » » 2 years ago, # ^ |   +47 No.For those familiar with past Codeforces contests, this contest is most similar to Surprise Language Rounds.
•  » » » 2 years ago, # ^ |   0 Thanks!
•  » » » 2 years ago, # ^ |   -10 this contest is most similar to 1 april contest
 » 2 years ago, # |   -10 Is it a hiring contest?
•  » » 2 years ago, # ^ |   +45 Just another person who doesn't solve problems because of getting fun
•  » » 2 years ago, # ^ |   +67 No. This contest is educational and aims to encourage people to learn quantum computing and Q#.
 » 2 years ago, # |   +14 Wow, that sounds amazing! Sadly I have 3 exams in the 3 days of the contests, but I will probably participate in the warm-up round. Btw, what level of knowledge is required about quantum computing in order to participate? also, if the practice and contests rounds will be available after the contest ends for people who failed to participates on time it would be great :D
•  » » 2 years ago, # ^ |   +48 I aimed to make a lot of the tasks accessible for people with no quantum computing background, who will start by learning what is superposition, what are the basic gates used in quantum computing, what is measurement etc. Of course, there are also some tasks which are definitely more challenging, just in case people with quantum computing training show up. But only the contest will show whether I got the balance right :-)I think the problems will be available on Codeforces for a few weeks after the contest. We plan to publish the test harnesses as well, so that everybody can try and solve the problems offline.
•  » » » 2 years ago, # ^ |   +2 I haven't used Q# to solve any problems, though I installed Q# two month ago. Will this contest fit me?
•  » » » » 2 years ago, # ^ |   +42 Yes, definitely. With the compiler already installed, you're ahead of a lot of others :-)
 » 2 years ago, # |   +3 I have heard of Q# about 2 months ago but haven't try it. I will give it a shot this time.
 » 2 years ago, # |   -247 stupid language, useless. this is a waste of my time. codeforce should give more brainf*ck language contests. because codeforces’ retardness is f*cking my brain. stupid codeforces. stupid contestants
•  » » 2 years ago, # ^ |   -59 ⬆️It seems that this guy drunk.
•  » » » 2 years ago, # ^ | ← Rev. 2 →   -89 It’s too negative.
•  » » » 2 years ago, # ^ |   -105 can you even proper english? no wonder codeforces is hopeless. this china guy broken english
•  » » » » 2 years ago, # ^ |   -27 If you don’t want me to speak English,please open your translate. 我不明白你为什么对Codeforces有如此大的仇恨，也不明白你为什么要用此般语言去辱骂，如果你觉得Codeforces给你带来了不好的影响，请你注销账号，关闭网站。如果你觉得你说的话值得所有人去追捧，那么请您解释-92和您的Contribution是-23的原因。如果您觉得我的话侵犯到您，我可以向您道歉。但是请您端正您的态度，没有人强求您参加这场比赛，也不强求您必须参与Codeforces。
•  » » » » 2 years ago, # ^ | ← Rev. 2 →   +32 Is "can you even proper english?" proper English? It breaks my google-translate.
•  » » » » 2 years ago, # ^ |   +28 Whatever, we should keep calm. Hold your fire. & do not hurt others.
 » 2 years ago, # |   +8 Excited to code Q#. Are the problems typical problem-solving style or some kind of different one? Like, using unitary matrix or something.-
•  » » 2 years ago, # ^ |   +19 The tasks are definitely very different from typical competitive programming problems. And yes, you pretty much can't avoid using unitary matrices :-)
 » 2 years ago, # |   +11 Is quantum computing background required for this contest?
•  » » 2 years ago, # ^ |   +17 I aimed to make a lot of the tasks accessible for people with no quantum computing background, who will start by learning what is superposition, what are the basic gates used in quantum computing, what is measurement etc. We'll see whether I got that right :-)
 » 2 years ago, # |   +22 I had a doubt. Will I be able to test my code on the custom invocation like code of any other language? Please pardon if you do not find this comment sensible enough.
•  » » 2 years ago, # ^ |   +25 This is a very sensible question. Unfortunately, due to the unusual nature of the tasks each of them requires a custom test harness, which is more complicated than the usual console I/O. Custom invocation would have to be per-problem to provide the same test harness as the problem does, but that's essentially the same as just submitting the problem, so we didn't provide a separate custom invocation.If you want to run some Q# code but don't want to install it on your machine, you can use https://tio.run/#qs-core
 » 2 years ago, # |   +31 Can I do this contest without using any Mrkvosoft tools?:^)
•  » » 2 years ago, # ^ |   +3 Haven't actually tried it yet. But from what I can see from Setting up the Q# development environment, you only need to install dotnet, and the development kit. Afterwards you can use any editor you want, and compile/run the programs via the terminal.
•  » » 2 years ago, # ^ |   +17 You can write untested code and submit. lol
•  » » 2 years ago, # ^ |   +42 Well, technically speaking Codeforces back end uses Q# compiler which is a Microsoft tool, so once you sumbit the code to the contest, you're using a Microsoft tool. But then, Codeforces back end runs on Windows, so the same applies to any CF contest :-)If you mean running Q# locally, and are willing to tolerate Q# compiler but are averse to tools like Visual Studio and Windows, then (as Jakube already said) you can use Linux or Mac with .NET Core which is open source.
•  » » » 2 years ago, # ^ |   +22 I wouldn't call CF a MS tool, not anymore than I'd call an airplane a Kernighan/Ritchie tool :DYeah, I don't want to use Windows and if possible not use VS. My first adventure with VS OSS (I don't remember why prebuilt versions didn't work) on Arch Linux ended up with running out of /tmp space, my first adventure with VS on Windows VM ended up with running out of RAM and virtual disk space and my second adventure with VS OSS on Arch Linux ended up with uninstalling it because it was unnecessarily taking up space.
•  » » » » 2 years ago, # ^ |   +1 You should be able to use VSCode to developt Q#, I believe. VSCode is cross platform.
•  » » » » » 2 years ago, # ^ |   -26 cross platform So is the Brainfuck compiler.
 » 2 years ago, # |   +44 Will system tests be handled by quantum computers? :D
•  » » 2 years ago, # ^ |   +28 No, but you won't be able to tell the difference :-)Quantum systems of up to 30 qubits can be simulated perfectly on a (not very powerful) classical computer. The tasks in the contest use at most 16 qubits, just to be on the safe side.
 » 2 years ago, # |   +1 Is there any materials about Quantum Programming?I'm very interested in this but having no idea how to learn about it.
•  » » 2 years ago, # ^ |   +16 I have been studying Ronald de Wolf's lecture notes for the past couple of days and would recommend. It seems possible to pick up QC pretty fast if you are already comfortable with linear algebra and bit bashing.
•  » » » 2 years ago, # ^ |   +8 Exm, what does "bit bashing" mean? And thanks a lot for your book.
•  » » » » 2 years ago, # ^ |   +18 I mean tricks with bitwise operations. A lot of XOR, AND, popcount so far. Or another way to look at it, linear algebra over GF(2) is used in addition to over the complex numbers.
•  » » 2 years ago, # ^ |   +6 There are also John Preskill's lecture notes. "Quantum Computation and Quantum Information" by Nielsen & Chuang is a very useful book. I'll try and assemble a list of useful links a bit later today.
 » 2 years ago, # |   +11 Interested in this contest but won't participate for my poor knowledge of quantum mechanics and unfamiliarity with Q# and even C#.
 » 2 years ago, # |   0 I'm interested in Q#, and looking forward to this contest!
 » 2 years ago, # |   0 Can only use Q#? 这次比赛只能用Q#吗 Google Translate....Chinese->English.....
•  » » 2 years ago, # ^ | ← Rev. 2 →   +15 You can only use Q#.参与者只能用Q#Google Translate....English->Estonian->Spanish->French->Japanese->Russian->Swahili->German->Xhosa->Chinese->Taiwanese->Simplified Chinese
•  » » » 2 years ago, # ^ |   0 lol
•  » » » 2 years ago, # ^ |   0 Thanks
 » 2 years ago, # |   +9 Is there any guide to the quantum algorithms for Complete Idiots (tm)?
•  » » 2 years ago, # ^ |   +19 Try this
•  » » » 2 years ago, # ^ |   +1 I've already tried, got to page 3, read few more pages and understood that I did not understood anything (after page 3). I guess there are some prerequisites for most of the material on the subject. The question is more if there are classical-programmer-oriented materials available.
•  » » » 2 years ago, # ^ |   +1 What I want is more or less a specification of the abstractions provided by the Q# language. I do not really want to deep into the quantum physics math (not yet). Not only because it is too high matter for me, but also because it looks incomplete and not well understood by those who write on it (the latter conclusion is made based on the language they use; remember "if you cannot describe a thing in simple words, you don't understand it").
•  » » » » 2 years ago, # ^ |   +6 Try searching documentation on the microsoft page, I recently found about this article that really helped me write first quantum program
•  » » » » 2 years ago, # ^ |   +16 For Q# language-based introductions, best sources are Q# language reference (it has an intro to quantum concepts before diving into Q#) and this blog.
•  » » » » » 2 years ago, # ^ |   0 The blog you referenced is what I was looking for. Thanks!
 » 2 years ago, # |   0 may i use any other language other than Q#
•  » » 2 years ago, # ^ |   +5 No
•  » » 2 years ago, # ^ |   +38 You may manipulate the quantum state of CF to achieve AC or use a quantum computer to crack encryption, gain access to CF and give yourself AC.
 » 2 years ago, # |   -59 Expected ranklist: ... Remaining ones are difficult to decide.
 » 2 years ago, # |   +1 Oops, why doesn't the following work for G?  operation Solve (x : Qubit[], y : Qubit, k : Int) : () { body { Set(Zero,y); CNOT(x[k],y); } } 
•  » » 2 years ago, # ^ |   +3 Is there any materials for quantum oracle? I'm stuck in G :'(
•  » » » 2 years ago, # ^ |   +24 Sorry, I have no idea what's going on. :(
•  » » » 2 years ago, # ^ |   +10 The wiki page of Deutsch-Jozsa algorithm have what you want.
•  » » » » 2 years ago, # ^ |   0 Thanks. Actually I saw Deutsch-Jozsa algorithm before(Yet not fully understood). But how this can be applied to Problem G?
•  » » » » » 2 years ago, # ^ | ← Rev. 2 →   0 There is a paragraph saying the actual function of a quantum oracle.
•  » » » » » » 2 years ago, # ^ |   +23 Wow, thanks! I guess I shouldn't initialize y to 0. :P
•  » » » » » » » 2 years ago, # ^ | ← Rev. 2 →   0 Magic! I thought we need to use teleportation.. Am I correct that CNOT may result in different phase, but this is allowed by the problem?
•  » » » » » » » 2 years ago, # ^ |   0 I think the problem in initializing y is that makes the function non-invertible (the initial state of y is lost) and from tutorial: "oracles have to have an adjoint defined for them"
•  » » » 2 years ago, # ^ |   0
•  » » 2 years ago, # ^ |   +8 I think this may break the superposition of y qubit
•  » » 2 years ago, # ^ |   0 You shouldn't set it to zero. You need to act on the previous state of the qubit.
•  » » » 2 years ago, # ^ |   0 Maybe I didn't understand this task correctly. I tried to read an article about oracles but it's too mathy. Should I set y:=x[k] and don't change x[k] at the same time?
•  » » » » 2 years ago, # ^ |   0 There is a theorem which prohibits copying the (arbitrary unknown) state of a qubit without changing the state of the original one (no-cloning theorem).You need to set y := y XOR x[k], and not change x[k].
•  » » » » » 2 years ago, # ^ |   +15 This single sentence is more useful than that article!
•  » » » » » 2 years ago, # ^ |   0 So in oracles the phase of the qubit does not matter? E.g. what if I apply Z to the answer? Or e.g. submit |+> instead of |->.
•  » » » » » » 2 years ago, # ^ |   0 The absolute phase of the whole system doesn't matter; you can always multiply the whole state by a complex number of norm 1 and it won't change anything. However, relative phase (phase by which you multiply only some parts of superposition and not the others) matters. and states are effectively the same, but and are not (they are orthogonal).
 » 2 years ago, # |   +20 How can I find that "Tutorial blogpost", where the specification of an Oracle is given?
•  » » 2 years ago, # ^ | ← Rev. 2 →   0
 » 2 years ago, # |   0 It seems the checker does not recognize compilation errors. Sent non-compilable code and got WA.
•  » » 2 years ago, # ^ |   0 It does give compile errors.
 » 2 years ago, # |   0 Guys I would like to ask a question.Since this is a practice contest, I think its ethical to take help.However, I would still ask you guys, should I ask a question related to the contest ?
•  » » 2 years ago, # ^ |   0 I think it's probably better to ask rather than remain with WA on task A for the next day ;)
•  » » 2 years ago, # ^ |   +5 Sure, the warmup round is supposed to help participants learn the basics and prepare for the main contest. We'll publish detailed editorials for problems A, D and G tomorrow, but you can ask for hints now.
•  » » » 2 years ago, # ^ |   0 Any hints for E & F?
•  » » » » 2 years ago, # ^ |   +8 Hint for E: Look at the vector representations of the Bell states and see how you can fiddle with them to get |B0> to |00>, |B1> to |01>, etc. In particular, most fundamental quantum operations are reversible, so try to go through your solution for B in reverse.Hint for F: It's way easier than it may seem. It's actually a purely classical programming task, nothing quantum. You have 3 bitstrings A, B and C, either A=B or A=C. Which is it?
•  » » » » » 2 years ago, # ^ |   0 Need some more hints for F :/ACed all other problems, this remains with WA3.First attempt was to check till first difference between bits0 & bits1. WA1. Now I check all differences, WA3. Code seems clear.Are there some important things like not-reseting-output-qubit for oracles?
•  » » » » » » 2 years ago, # ^ |   0 Well, somehow it works now.
•  » » » » » » » 2 years ago, # ^ |   0 You can't say anything about which state it was based on measurements of qubits which have the same value in both bitmasks. I suspect your AC submission should fail because it effectively makes the decision based on the last bit of the masks, not on the differing bit. But I can't figure out why it was accepted right now (it's well past midnight here...)For your submissions which check only positions where the bitmasks differ, the idea is correct but the logic in the condition is incomplete, it covers only half of the cases.
•  » » » » » » » » 2 years ago, # ^ |   0 Actually, last version still checks only differences. It makes the decision based on last qubit with difference from bitstrings. It does nothing when founds a match :)
 » 2 years ago, # |   -10 Why no online IDE for this?The linked one isn't working properly.
 » 2 years ago, # |   +10 I want to test my Q# method but I don't really know how. I understand that I can make a C# driver class (since I'm using Visual Studio Code, that is done for me), but I can't call the Q# method because it takes a Qubit[], which in C# seems to be a QArray(). Now, normally, this would be no problem, and I would just look up the documentation for QArray and Qubit to see how to create them, but I can't find documentation for these two classes anywhere. I suppose I am just bad at looking, any help would be appreciated.
•  » » 2 years ago, # ^ |   +1 Qubits can not be allocated in C# code. You need to write a Q# wrapper around your solution that would: allocate the qubits with using keyword, prepare the state in which you need your qubits to be per problem statement, call your solution, analyze the return (you can use DumpMachine to dump the state of the simulator without measuring it). Testing and Debugging section of Q# documentation provides more information.
•  » » » 2 years ago, # ^ |   +5 Thanks for the help, it makes sense, but I still can't get it to work in practice. I made a testing operation in the qs file and put dump machine in the operation, like so namespace GenBell { open Microsoft.Quantum.Canon; open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Extensions.Diagnostics; operation Operation (qs : Qubit[]) : () { body { //solution DumpMachine("test.txt"); } } operation TestOp() : () { body { using(qs = Qubit[2]) { Operation(qs); } } } } So I expect it to print out the program state to test.txt. I have also tried DumpMachine(()) to print to console. However, either way, nothing seems to happen when I run the Driver code, which looks like this: using Microsoft.Quantum.Simulation.Core; using Microsoft.Quantum.Simulation.Simulators; namespace GenBell { class Driver { static void Main(string[] args) { using(var sim = new QuantumSimulator()){ TestOp.Run(sim); System.Console.WriteLine("This gets printed"); } } } } Wierdly, it says TestOp does not exist in the current context, but it still seems to run (though of course nothing happens). I tried to figure out how to make it defined but the compiler seems dead set on ignoring my test method ): Can you explain the reason for the weird behavior?
•  » » » » 2 years ago, # ^ |   0 Same here. I was unable to get any debugging output. Running on macOS if that could matter.
•  » » » » 2 years ago, # ^ | ← Rev. 3 →   +6 You should use 'DumpMachine("")' to write to console. This is wrong in the documentation and I just sumitted an issue. This works on TIO.run. ('DumpMachine(())' writes to a file named '()' on my machine.)Edit: Also running simulations that don't return anything get optimized away or something, so the quick fix is to return some dummy value. fixed code
•  » » » » » 2 years ago, # ^ |   +8 A method I also use for printing to console is Message(str), works with no problems.
 » 2 years ago, # |   0 Nickolas, One question please. Are the inputs of Problem G any random state of qubits? Like, x[k] = α|0 >  + β|1 >  with any proper α and β?
•  » » 2 years ago, # ^ |   +3 Yes, in oracle tasks oracles should work on arbitrary state of input qubits.
•  » » » 2 years ago, # ^ |   0 Thanks. I suddenly wonder how multi-bit logic gates actually work on a real quantum computer atomically :| Amazing!
•  » » » » 2 years ago, # ^ |   +3 Typically a multi-qubit gate would be approximated by a sequence of one- and two- qubit gates which can be implemented natively on the hardware. A set of gates which can approximate any gate is called universal.
 » 2 years ago, # | ← Rev. 4 →   +21 Is there a Q# issue-tracker somewhere? Some of the error-messages are not very helpful and look like a bug in the compiler: error QS0001: Internal error: The index was outside the range of elements in the list. occurs if the body of an operation with a return value contains only comments. (Just an empty body does produce a proper error message.) error QS0001: Internal error: Parsing produced an error node without logging an error occurs really often for me, mostly when I guess the syntax wrongly. Some examples of such wrong syntax are: & as bitwise operator, ! or ~ as boolean not, braced-initializer for a new array, a single-statement for-loop without {}, a single-statement else without {}. error QS0001: Internal error: ("C:\\\\prog.qs", Ln: 112, Col: 2): The combinator 'many' was applied to a parser that succeeds without consuming input and without changing the parser state in any other way. (If no exception had been raised, the combinator likely would have entered an infinite loop.) occurs if your create imbalanced curly brackets by commenting some }. Surprisingly, deleting them instead of commenting produced a different (more reasonable) error. I also encountered a strange crash that is quite sensitive to code changes (The crash does not occur on TIO.): Codedriver.csusing System; using Microsoft.Quantum.Simulation.Simulators; namespace Solution { public class Driver { public static void Main(string[] args) { using (var sim = new QuantumSimulator()) { string res = MMain.Run(sim).Result; System.Console.WriteLine($"Did: | {res}"); } System.Console.WriteLine("Done."); } } }  prog.qsnamespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Extensions.Diagnostics; operation F() :(){ body { using (q = Qubit[2]) { using (A = Qubit[1]) { X(q[0]); H(q[0]); CNOT(q[0], q[1]); DumpMachine(""); ResetAll(q); } } } } operation MMain() : String { body { F(); F(); mutable mess = ""; return mess; } } } Crash: Microsoft.Quantum.Simulation.Simulators.Exceptions.ReleasedQubitsAreNotInZeroState: Released qubits are not in zero state.It looks like the unused qbit A got flipped.Edit: I just figured out how to dump to console ('DumpMachine("")'): Ouput of above code on my machineIds: [2;1;0;] Wavefunction: 0: 0.707107 0 1: 0 0 2: 0 0 3: -0.707107 0 4: 0 0 5: 0 0 6: 0 0 7: 0 0 Ids: [2;1;0;] Wavefunction: 0: 0.707107 0 1: 0 0 2: 0 0 3: 0 0 4: -0.707107 0 5: 0 0 6: 0 0 7: 0 0 Unhandled Exception: System.AggregateException: One or more errors occurred. (Released qubits are not in zero state.) ---> Microsoft.Quantum.Simulation.Simulators.Exceptions.ReleasedQubitsAreNotInZeroState: Released qubits are not in zero state. at Microsoft.Quantum.Simulation.Simulators.QuantumSimulator.QSimQubitManager.ReleaseOneQubit(Qubit qubit, Boolean usedOnlyForBorrowing) at Microsoft.Quantum.Simulation.Common.QubitManager.Release(QArray1 qubitsToRelease) ... Something's seriously wrong on my machine xD. •  » » 2 years ago, # ^ | 0 There is a package for bitwise operations: https://docs.microsoft.com/en-us/qsharp/api/prelude/microsoft.quantum.extensions.bitwise?view=qsharp-preview •  » » » 2 years ago, # ^ | 0 You can actually just use &&&. (As I'm most used to C++, I tried a single & first and it didn't work.) The main complaint is not about the different syntax, but rather about the error message. Internal error to me implies that something broke inside the compiler. (Just like GCC telling you it's confused by earlier errors, bailing out.) •  » » 2 years ago, # ^ | +18 The issue tracker is here, though for some reason it calls issues "ideas".I totally agree that the error messages are, ahem, not ideal. We are working on a new parser which should eliminate all of the weird messages at once.  » 2 years ago, # | 0 I have a question. let's say q[0] is in state |0> + |1>. I use the operation CNOT(q[0],q[1]) so I have |00>+|11>. Now measure res=M(q[0]). Now if I do res2=M(q[1]) will I always get the exact same measurement or different. i.e does measuring q[0] collapse q[1] or will q[1] still remain in superposition. •  » » 2 years ago, # ^ | 0 A quantum bit will be set to |0 > if measured value is 0 otherwise |1 > after measuring so yes, it will break the superposition. •  » » 2 years ago, # ^ | 0 You will always get the same measurement, and the qubits are said to be entangled with each other. This process is known as Quantum Entanglement. More info here. Quantum Entanglement Wikipedia  » 2 years ago, # | ← Rev. 2 → +13 The document says: The qubits should be in the computational Zero state at the end of the statement block; simulators are encouraged to enforce this. Is it enforced in the judger of this contest? I got WA in Problem I if I don't reset them, and got AC if I do. I wonder whether this means I produced a wrong answer or the judger was unhappy because I didn't reset. •  » » 2 years ago, # ^ | +3 On TIO and on my machine, this is enforced and you get a Microsoft.Quantum.Simulation.Simulators.Exceptions.ReleasedQubitsAreNotInZeroState exception. I'd expect similar behaviour on codeforces.Judging by the fact that no submission got the Runtime error verdict, I'd guess that exceptions get reported as WA and not as RE.Either way, it would be nice to get confirmation on this. •  » » » 2 years ago, # ^ | +16 You are right, the simulator enforces that the qubits must be released in zero state, and the tester converts any exception to WA. In problems on superposition and oracles this is necessary: the tester checks that the generated state/returned oracle is correct by applying some operations to the qubits and checking that in the end they are in zero state, so incorrect solution is indicated by this exception.I will try to improve the checker for tasks which allow some degree of separation between RE and WA (like measurement tasks and Deutsch-Jozsa algorithm) for the main contest.  » 2 years ago, # | +25 Fastest Editorial ever!!! It comes out (partially) 2 days before contest even ends O:  » 2 years ago, # | +10 Any hidden tricks for Deutsch Josza? I don't know what am I doing wrong.  operation Solve (N : Int, Uf : ((Qubit[], Qubit) => ())) : Bool { body { mutable res = true; using(q1 = Qubit[1]) { Set(One, q1[0]); H(q1[0]); using(qs = Qubit[N]) { // generate input space for(i in 1..N) { H(qs[i-1]); } Uf((qs, q1[0])); // applying Hadamard again for(i in 1..N) { H(qs[i-1]); } for(i in 1..N) { if(M(qs[i-1]) == One ) { set res = false; } } } } return res; } }  •  » » 2 years ago, # ^ | 0 I don't get how M(qs[i-1]) could give one because applying H twice will get them back to initial state. •  » » 2 years ago, # ^ | +8 You have to make sure the qubits you release are in zero state. Otherwise, as discussed above, the simulator will throw ReleasedQubitsAreNotInZeroState exception which is interpreted as WA. •  » » » 2 years ago, # ^ | 0 Thanks a lot Nickolas!, that was the exact issue. I was confused as I got WA.  » 2 years ago, # | +1 completely new to this topiclearn quantum computing in 6 dayswow  » 2 years ago, # | 0 Hey would it be possible to include a driver program so that we could test our code in the actual contest? I'm having trouble in using online IDE link given. •  » » 2 years ago, # ^ | 0 Most of the tester code is Q#, and for most problems it literally contains the solution code. So, unfortunately, we can't provide the test harness during the contest without revealing the solutions.Custom invocation on Codeforces would have to be per-problem to provide the same test harness as the problem does, but that's essentially the same as just submitting the problem, so we didn't provide a separate custom invocation. •  » » » 2 years ago, # ^ | 0 The driver code doesn't need to check the validity of the output, just print it to the console so that the programmer can check it and possibly debug the program. That's how I made my driver programs, but it took some time to write them. •  » » » 2 years ago, # ^ | 0 Maybe the driver doesn't create the state of the qubits just allows us to actually make the states and call our solution function. •  » » 2 years ago, # ^ | 0 We have added Custom Invocation to the main contest; hope that helps!  » 2 years ago, # | +5 Will the actual contest have tougher problems? otherwise it would become a time race. •  » » 2 years ago, # ^ | +3 Yes, it will. This one is a warmup round, after all :-)  » 2 years ago, # | 0 Is there any difference between the functions ResultAsInt and PositiveIntFromResultArr? •  » » 2 years ago, # ^ | 0 From their implementation at https://github.com/Microsoft/Quantum I don't see any, other than the check for potential overflow in PositiveIntFromBoolArr. Nice catch :-)  » 2 years ago, # | +15 I am worried that the judge does not working because it always returned AC for every problem. Can someone confirm it is possible to get WA ? •  » » 2 years ago, # ^ | 0 Yes, I was able to obtain WA for deliberately incorrect solutions.  » 2 years ago, # | 0 i have no object oriented programming knowledge.I have been using only functional(haskell) and procedural languages(C,C++).Will Q# suit me in this case.If not is their any alternative?PS even though c++ has oops i have never tried or used it. •  » » 2 years ago, # ^ | 0 Yes, it will. Q# is not object-oriented. •  » » 2 years ago, # ^ | +10 Try it and see. Worst case scenario, you learn OOP.  » 2 years ago, # | +3 Is it ok that smart tabs do not work at all in Q# sources in Visual Studio 2017?Basically, whenever I press Enter to create a new line, a new line is created, but it's empty and does not contain any indentation:  body { <<< cursor is now there } I've already went to Tools -> Options -> Text Editor -> All Languages -> Tabs and switched "Indenting" to "Smart", but it didn't help with Q# source files. Indentation in C# works as expected. •  » » 2 years ago, # ^ | 0 Works on my machine. •  » » 2 years ago, # ^ | 0 I suspect that either this setting is overridden by the setting for "plain text" files or VS doesn't have enough information to figure out the smart way to indent. I set mine to "block" which works, it's not ideal but better than "none".  » 2 years ago, # | 0 Is there any analogue of AssertQubitState, but for n-qubit states? I was able to find AssertProbInt, but it checks probabilities only and does not check phase shifts. Basically, I want to write a unit-test for problem B. •  » » 2 years ago, # ^ | +10 Not that I'm aware of.For testing B, I ended up applying adjoint transformation and checking that the result is an all-zero state using AssertAllZero.  » 2 years ago, # | +43 Thanks, that was very educational — I've read about quantum computing before and had a very basic understanding that the state vector could be evolved through unitary matrices and measurement, but actually coding it help understanding a lot, particularly that it's non-trivial to construct the unitary matrices from gates.I'm feeling pretty happy that I managed to derive Deutsch-Jozsa for N=1 before reading the Wikipedia page. It's still hurting my brain that even though the oracle doesn't modify any of the input qubits, the algorithm throws away the output and just manipulates the inputs. •  » » 2 years ago, # ^ | +5 Do you have an intuitive explanation for Deutsch-Jozsa? •  » » » 2 years ago, # ^ | ← Rev. 2 → 0 Deutsch-Jozsa creates a uniform superposition of all possible inputs. Then, it negates the phase of all inputs that satisfy the predicate. Finally, it applies hadamard to all qbits again. The phase of the all-zero qbit array will be the sum of all the phases of the intermediate state because hadamard maps ∣0⟩ to (|0⟩+|1⟩)/√̅2 and |1⟩ to (|0⟩-|1⟩)/√̅2 and so the contribution of each state to the all-zero state is its phase multiplied by 1/√̅2ⁿ. If the function is balanced, the contributions cancel out, and if it is constant, they add up to either -1 or 1. Therefore, the function is constant exactly if we measure the all-zero array. •  » » » » 2 years ago, # ^ | 0 That sheds some light, thanks! But how/why the oracle modifies the phase of the inputs? Is it because of the entanglement? Then, it negates the phase of all inputs that satisfy the predicate. •  » » » » » 2 years ago, # ^ | ← Rev. 2 → 0 The phase flip is implemented using an ancillary qubit that is initialized with 1/√̅2(|0⟩-|1⟩). The entire state will be given by  1/√̅2^n|0…000⟩⊗1/√̅2(|0⟩-|1⟩) + 1/√̅2^n|0…001⟩⊗1/√̅2(|0⟩-|1⟩) + 1/√̅2^n|0…010⟩⊗1/√̅2(|0⟩-|1⟩) + 1/√̅2^n|0…011⟩⊗1/√̅2(|0⟩-|1⟩) ⋯ + 1/√̅2^n|111…0⟩⊗1/√̅2(|0⟩-|1⟩) + 1/√̅2^n|111…1⟩⊗1/√̅2(|0⟩-|1⟩) The oracle will take the input qubits to the left and flip the qubit to the right.  1/√̅2^n|0…000⟩⊗1/√̅2(|0⟩-|1⟩) // value 0, oracle is nop + 1/√̅2^n|0…001⟩⊗1/√̅2(|1⟩-|0⟩) // value 1, oracle flips + 1/√̅2^n|0…010⟩⊗1/√̅2(|1⟩-|0⟩) // value 1, oracle flips + 1/√̅2^n|0…011⟩⊗1/√̅2(|0⟩-|1⟩) // value 0, oracle is nop ⋯ + 1/√̅2^n|111…0⟩⊗1/√̅2(|0⟩-|1⟩) // value 0, oracle is nop + 1/√̅2^n|111…1⟩⊗1/√̅2(|1⟩-|0⟩) // value 1, oracle flips But because 1/√̅2(|1⟩-|0⟩) = -1/√̅2(|0⟩-|1⟩), this yields:  1/√̅2^n|0…000⟩⊗1/√̅2(|0⟩-|1⟩) // value 0 - 1/√̅2^n|0…001⟩⊗1/√̅2(|0⟩-|1⟩) // value 1 - 1/√̅2^n|0…010⟩⊗1/√̅2(|0⟩-|1⟩) // value 1 + 1/√̅2^n|0…011⟩⊗1/√̅2(|0⟩-|1⟩) // value 0 ⋯ + 1/√̅2^n|111…0⟩⊗1/√̅2(|0⟩-|1⟩) // value 0 - 1/√̅2^n|111…1⟩⊗1/√̅2(|0⟩-|1⟩) // value 1 At this point, we can forget about the ancillary qubit, as it is not entangled with any of the others, so our state is simply  1/√̅2^n|0…000⟩ // value 0 - 1/√̅2^n|0…001⟩ // value 1 - 1/√̅2^n|0…010⟩ // value 1 + 1/√̅2^n|0…011⟩ // value 0 ⋯ + 1/√̅2^n|111…0⟩ // value 0 - 1/√̅2^n|111…1⟩ // value 1   » 2 years ago, # | 0 Can someone explain C to me? •  » » 2 years ago, # ^ | +1 It is very similar to generating the first Bell state ; you just need to synchronize the state of the qubits after the second one with the state of the first qubit the same way you do it for the second qubit. •  » » » 2 years ago, # ^ | 0 Okay, but why isn't this correct: I am doing for same thing for every qubit as I did for B: codenamespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (qs : Qubit[]) : (){ body{ let n=Length(qs); for (k in 0..n-2){ H(qs[k]); CNOT(qs[k],qs[k+1]); } if (n==1){ H(qs[0]); } } }} •  » » » » 2 years ago, # ^ | +6 H gate creates superposition of two states, then CNOT gate changes the state of target qubit based on the state of control qubit. When you use H gate second time, you split the existing two states into four, which you don't need to do. Consider what your code does for N = 3: •  » » » » » 2 years ago, # ^ | 0 Ahh, thanks, got AC now  » 2 years ago, # | 0 Are tests running? It seems like all submissions are in queue but none is being evaluated •  » » 2 years ago, # ^ | +3 That's because a system test of another contest was running. You just have to wait until the system test ends.  » 2 years ago, # | 0 I realized that the pdf with problem explanations has some issues with copying the code which makes it fail compilation. I'll be fixing it in the following editorials. Meanwhile, here is the code from the pdf that you can copy and run. A.qsnamespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (q : Qubit, sign : Int) : () { body { if (sign == -1) { X(q); } H(q); } } }  D.qsnamespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (q : Qubit) : Int { body { if (Measure([PauliX], [q]) == Zero) { return 1; } return -1; } } }  G.qsnamespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (x : Qubit[], y : Qubit, k : Int) : () { body { CNOT(x[k], y); } } }   » 2 years ago, # | 0 What's wrong in this code for problem H?? I'm getting WA. Codeoperation Solve (x : Qubit[], y : Qubit) : () { body { mutable counter = 0; for(i in 0..Length(x)-1) { if(M(x[i]) == One) { set counter = counter + 1; } } set counter = counter % 2; using(q1 = Qubit[1]) { if(counter == 1) { Set(One, q1[0]); } else { Set(Zero, q1[0]); } CNOT(q1[0],y); Set(Zero,q1[0]); } }Thanks in Advance!! •  » » 2 years ago, # ^ | 0 You must not measure any qubits. •  » » » 2 years ago, # ^ | 0 It worked. Thanks dalex!! What's the reason behind it?? •  » » » » 2 years ago, # ^ | 0 I think it's because when measuring qubit, you put it as 1 or 0. So if you have qubit with superposition, mesuring it will make qubit 1 or 0 (depends on where it is) •  » » » » » 2 years ago, # ^ | 0 So does this mean that the oracle should return the input qubit register without any changes? •  » » » » » » 2 years ago, # ^ | 0 It said this in statement: The operation doesn't have an output; the "output" of your solution is the state in which it left the qubits. •  » » » » » » 2 years ago, # ^ | 0 Yes, it should return input qubits without changes, and output qubit should be xor-ed with the function you calculate.  » 2 years ago, # | 0 operation Solve (qs : Qubit[]) : () { body { let n = Length(qs); for (index in 1 ..n) { X( qs[index]); } } }http://codeforces.com/contest/1001/submission/39862662 ( the last index is out of bound)why it's WRONG ANSWER instead of RUNTIME ERROR •  » » 2 years ago, # ^ | +5 Right now all incorrect solutions produce WA verdict, regardless of what exception they throw. I'll try to introduce some separation between WA and RE verdicts for the main contest.  » 2 years ago, # | ← Rev. 3 → 0 This is my code for the H question. It seems to work for all sorts of superpositions as well, but I got a wrong answer. Is there an issue with using an extra qubit and discarding it, as I did below? namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (x : Qubit[], y : Qubit) : () { body { using (output = Qubit[1]){ for (index in 0..Length(x)-1){ CNOT(x[index], output[0]); } CNOT(output[0], y); } } } }  •  » » 2 years ago, # ^ | 0 Well qubit output shouldn't exist in first place. •  » » » 2 years ago, # ^ | 0 Wrong algorithm •  » » » » 2 years ago, # ^ | 0 Why shouldn't it exist? •  » » » » » 2 years ago, # ^ | ← Rev. 2 → 0 Because you should CNOT with y, not outputYou don't know the state of y, so you should use output as replacement •  » » 2 years ago, # ^ | +8 You are allowed to allocate extra qubits, but (as discussed above) you have to reset them to state before releasing them. In this code the allocated qubit is still entangled with x and y when it is released, so it throws ReleasedQubitsAreNotInZeroState exception, which in turn is treated as WA. •  » » 2 years ago, # ^ | +8 try setting output to zero at the end. qubits must be released in zero state.  » 2 years ago, # | ← Rev. 2 → 0 I need help with this part of I problem: Uf : ((Qubit[], Qubit) => ())How should this array be represented. If I wanted to, let's say CNOT first and second element, what should I write? CNOT(Uf.Qubit[0],Uf.Qubit[1])? •  » » 2 years ago, # ^ | +9 That's not an array, it's a function. You can use if calling Uf(x, y), where x is an array of N qubits and y is a single qubit. This function will act as a oracle for the described function. Read https://codeforces.com/blog/entry/60319 •  » » » 2 years ago, # ^ | 0 Oh, I didn't know about that. Thanks!  » 2 years ago, # | 0 What about syntax highlighting plugins for other editors than VS? If I want to use, say, Sublime Text or Vim (and compile with .NET SDK or by submitting), is there a way to get correct syntax highlighting? C# syntax isn't the same. •  » » 2 years ago, # ^ | +6 In vim I used F# syntax highlighting (syntax file is easy to find). F# seems closer to Q# than C#. But of course, a designated syntax for Q# would be better. •  » » 2 years ago, # ^ | +23 I haven't looked specifically at these editors yet. We do syntax highlighting via TextMate grammars, so if these editors support TextMate grammars, you can get qsharp.tmLanguage.json file from one of the extensions for VS/VS Code and use it to configure your editor.  » 2 years ago, # | 0 In problem G, is y guaranteed to be initialised to ?I wanted to set it to by first measuring it, which puts it in one of the Pauli Z basis states, and then flipping it if the measured eigenvalue was - 1. It gave WA.I'm aware entanglement means I shouldn't measure in oracles, but if y is entangled with something (not ), then I'm not going to set its value to xk using just CNOT anyway. •  » » 2 years ago, # ^ | +15 y does not have to be initialized to . In that case, the oracle should set y to (link to oracle tutorial blog).Also, Potentially big spoiler for problem Ione way of using this is calling the oracle with which results in , i.e. the oracle return value in the phase. •  » » » 2 years ago, # ^ | +10 Ah, seems like I didn't read that blog correctly — I thought the function determines what state y will be in and it can use or discard the initial state of y as it sees fit. Makes sense this way from a QM perspective.  » 2 years ago, # | ← Rev. 2 → +25 The warmup round is over! Here are the editorials for the tasks.  » 2 years ago, # | 0 Can someone write me I problem, so I can examine it. I have hard time dealing with compilation errors.. •  » » 2 years ago, # ^ | 0 IsConstantBooleanFunction from the samples implements problem I, but with parameters N and Uf swapped.  » 2 years ago, # | +3 Why the solutions are closed for viewing? •  » » 2 years ago, # ^ | 0 Open now :-)  » 2 years ago, # | +13 About how hard / harder than warm up round will the next Q# round be? For example, rate this round X/10, and next one Y/10. I am a fan of /10 scores •  » » 2 years ago, # ^ | +15 X/10 scores imply the existence of a contest which is 10/10. Since the warmup round and the main contest are the only two quantum programming contests I'm aware of, and the main contest is harder than the warmup, the main has to be 10/10 :-)On a serious note, the tasks in the main contest will range from ones similar in complexity to the harder ones from the warmup round to much harder. But the existence of the warmup round (editorial and open solutions) should make some of the tasks easier than the similar-level ones in the warmup.  » 2 years ago, # | ← Rev. 6 → 0 For people interested in the very mathematical form of QM (using matrices and vectors), here's a physics problem where the physics is just an interpretation of the math, problem 9, QM beamsplitter: consider a beamsplitter that takes two photon beams (light beams) as input, described as and (the input Fock state is ) and produces two photon beams as output, described as , , where each of n1, n2, n1', n2' describes the number of photons in the given beam; all photons are indistinguishable the creation operators of the input and output beams — a creation operator creates one photon (also known as ladder operators for some reason) are tied by the following relations: \$ show that the transformation from basis to and vice versa is unitary; why does it have to be, physically? what's the physical/practical meaning of θ? if the input state is , compute the output state and the probabilities that we'll measure a photon in output beam 1, output beam 2 same as above, if the input state is — compute the output state and relevant probabilities or the expected number of photons we should measure in each output beam especially for , can there be interference between output beams? (Dirac claimed that a photon can only interfere with itself, like in the double slit experiment) how do the answers to the above questions change when photons are considered distinguishable, e.g. with different wavelengths in the two input beams? my solutionsunitary transformationA unitary matrix satisfies . It's true that ; the second matrix is Hermitian adjoint.The reason why it has to be unitary is conservation of the number of photons / energy between the input and output. thetaMany reasons can be offered, my own is that cos2θ is the fraction of energy of input beam i transmitted into output beam i and sin2θ is the fraction transmitted into output beam 3 - i. Maybe there's a better explanation. output states for 1 photonSince by definition and similarly for input beam 2 and output beams, we have where we used the fact that the vacuum state is the same on the output as on the input — if zero photons go in, zero photons go out.Measuring the number of photons in output beam 1 can be described generally using a counting operator N'1 with eigenvalues/vectors: , with a similar operator for output beam 2. A measurement of beam 1 of our output state will collapse it to with probability cos2θ, giving result 1 photon, or to with probability sin2θ, giving result 0 photons. If we measure beam 2, the probability of getting the result 1 photon is sin2θ and the probability of getting 0 is cos2θ. Note that the total number of measured photons is 1, which is consistent with unitarity. output states for 2 photonsIt's very similar to previous case with some more complicated calculations. Since we can apply creation operators repeatedly, the formula connecting vacuum and our state is Now let's compute \$We used boson commutation relations — photons are bosons, so they satisfy , similarly for output operators. That means the output state is A measurement will collapse this into the state with probability cos22θ or into either of the states with probability sin22θ / 2. The expected number of photons is again 1·cos22θ + 2·sin22θ / 2 = 1, as expected (heh); however, a probability of finding a photon at an output is cos22θ + sin22θ / 2.Btw, the third commutation relation I didn't mention is (identity). The reason the magic sqrt appears in the definition of creation operators is this and normalisation of all state vectors to 1. If this magic number for state is kn, then for a single beam, The rest is just a natural choice of$k_0=1\$ and . I used a to denote a corresponding annihilation operator that's defined with a corresponding magic constant. interferenceNote that interference = one measurement affecting another, which is the same as asking if entanglement is possible.The answer lies in the previous part: we actually obtained an entangled state. Note what happens after the mentioned measurement: if we measured x photons in output beam 1, we'll always measure 2 - x photons in output beam 2 afterwards. However, if the measurement of beam 1 wasn't performed, we could measure 0, 1 or 2 photons in beam 2.The mathematical approach to QM is helpful in knowing what should happen without endless philosophical debates. distinguishable photonsThe commutation relations I mentioned will still hold (except the one with identity, which is 0 instead). However, if we denote the distinct photon types' creation operators as , then the resulting state is separable (the subscripts of numbers describe what kind of photons the states consist of — e.g. red or blue). In fact, we could write each input state as and similarly for output states, since each photon type has an independent operator set that only acts on its own state.Different particles don't interfere with each other.
 » 2 years ago, # | ← Rev. 2 →   0 How does the checker for problem G look like?
•  » » 2 years ago, # ^ |   +5 Essentially it uses operation AssertOperationsEqualReferenced from Microsoft.Quantum.Extensions.Testing namespace to compare your submission with the reference implementation of the oracle.
•  » » » 2 years ago, # ^ |   0 Why this doesnt work for problem B ? operation Solve (qs : Qubit[], index : Int) : () { body { if(index==0) { H(qs[0]); CNOT(qs[0],qs[1]); } if(index==1) { H(qs[0]); Z(qs[1]); CNOT(qs[0],qs[1]); } if(index==2) { H(qs[0]); X(qs[1]); CNOT(qs[0],qs[1]); } if(index==3) { X(qs[0]); H(qs[0]); X(qs[1]); CNOT(qs[0],qs[1]); } } } 
•  » » » » 2 years ago, # ^ |   0 This code generates wrong state for index = 1. Z gate flips the sign of qubit in state , but you apply it to qs[1] which is in state , so it has no effect, and the state generated is instead of . If you apply Z gate on the same qubit as H gate, it will work.
•  » » » » » 2 years ago, # ^ | ← Rev. 2 →   0 OK correct me if I'm wrong, I'm new to Quantum Computing and find some part of it confusing . First we have two qubits |00> , q[0] and q[1] as both |0>. After applying H on q[0]we get (|00> + |10>)1/√2, now what does q[0] and q[1] refer to, does q[0] mean |00> and q[1] as |10> ? And if q[0] refers to |00> then what will be the result of applying the flip gate X on q[0], and on q[1] ?
•  » » » » » » 2 years ago, # ^ |   0 q[0] and q[1] are both qubits. and are terms in the expression for superposition state, they don't correspond to qubits, the first digit in each of the terms corresponds to q[0] and the second — to q[1]. After applying H gate to q[0], the state of the two-qubit system is , the state of q[0] is and the state of q[1] is still . Once you apply an entangling gate to the qubits, like CNOT, you won't be able to represent the state of the system as a tensor product of states of separate qubits.
 » 2 years ago, # |   0 Small correction for the solution to task E: B_1 gets mapped to |10>.
 » 2 years ago, # |   +20 How is the time limit exceeded determined? In terms of real execution time of the code on the cf server (so a classical computer) or supposed runtime on a quantum computer (measured by e.g. number of operations)?I can imagine that an efficient quantum algorithm simulated on a classical computer can be significantly slower than the usual classical algorithm for the same problem.Or maybe there won't be problems where this is an issue?
•  » » 2 years ago, # ^ |   +10 Real execution time on CF server.I don't expect there will be problems for which it will be an issue. Reasonable correct solutions are small enough to not time out accidentally. For most problems, there doesn't exist a classical algorithm — you can't really generate a quantum state or distinguish quantum states classically.Problems which can be solved classically — for example, the task of figuring out whether a function is constant or balanced, solved by Deutsch-Jozsa algorithm, can be solved by encoding classical queries in qubits before calling the oracle, — have extra checks to restrict the number of calls to the oracle to only one.
•  » » » 2 years ago, # ^ |   +23 Thanks!I wasn't sure if this is going to be algorithmic contest (i.e. get a nice complexity) or a quantum contest (i.e. solve a problem in non-familiar environment). I'd be personally happy with both.I'm really looking forward to the contest. This seems like a lot of fun. Thanks for preparing it!
 » 2 years ago, # |   -10 Did tourist forget to register or he just want to make a penalty of 38687?
 » 2 years ago, # | ← Rev. 2 →   +10 I have a dumb question: How do i declare an array of Bool in Q#? i tried mutable v = new Bool[4]; but i get either parsing error or symbol v is undefined. Also, what types can i send from c# to q# via arguments of an operation? Sending an array of bool from C# to Q# doesn't work... however Result exists both in C# and in Q# (this is in Microsoft's tutorial), are there more of these? If yes, which types?
•  » » 2 years ago, # ^ |   +8 Declaring mutable v = new Bool[4]; seemed to work just fine to me. Check for example my submission to problem F. I didn't remove the testing code before submitting, and it might contain what you need.I noticed that Q# has its own bool-like type, that is not the same as C# bool. Apparently, they can be casted to each other (meaning passing a bool is fine) but array doesn't work. For bool arrays, I just passed a bitmask and reconstructed the array. It even made my C# code easier (one random number instead of whole array).I found the samples from this repository pretty useful in terms of what can I do in Q#.
•  » » » 2 years ago, # ^ |   0 Thank you, i tested it and apparently it works, i don't know what i've messed up then, but thank you again!
•  » » 2 years ago, # ^ |   +8 mutable v = new Bool[4]; should be the right syntax, I definitely have code in which it works.You can send pretty much any type (except qubits, which are technically possible to pass but really should be allocated inside Q# code), but a C# array has to be cast to Microsoft.Quantum.Simulation.Core.QArray first. You can look up example of QArray of long in ReversibleLogicSynthesis/Driver.cs` in https://github.com/Microsoft/Quantum
 » 2 years ago, # |   -10 What does the "adjoint auto;" do, in solution of A4?
 » 2 years ago, # |   +10 I think Pcorrect in solution of C1 is:instead of because both two states have possibility to be given.
 » 5 months ago, # |   0 In problem D I tried something different from tutorial. I let another variable to store the state of our qubit. Then i applied X gate on our qubit knowing that X|+> = |+> and X|-> = -|-> then simply compared q and another variable where I stored q and returned 1,-1 accordingly. But it gives WA. Can anyone explain 83325355.
•  » » 5 months ago, # ^ |   0 It doesn't work like that... The qubits in Q# are not qubit states, they are objects that change the underlying state of the system when acted upon (you can read more about it in this blog post). When you compare qubits you're not comparing their states (that's not a physically realizable operation), you're comparing that the variables point to the same object. So what your code actually does is: define another variable name for the input qubit apply X gate to the qubit (has no effect on the solution) check whether variables p and q point to the same variable; they do (no wonder!), so you always return 1 regardless of the input. Approximately half of the inputs will be |-⟩ which will be misclassified.
•  » » » 5 months ago, # ^ |   0 Got it! thanks!