Comments (4)
Thank you Manvi!
from quantumkatas.
@abrassel , seems there are three things at play here: efficiency of current algorithm, correctness of existing solution and passing of your solution with and without +1.
- Efficiency: I agree that your solution is slightly more efficient. I think it would be a good idea to have it as an alternative solution in workbook
- Correctness of existing solution: The existing solution is correct because BitSizeI function returns the minimum number of bits required to represent a number. BitSizeI function reference. To validate this, you can create an operation Demo_BitSizeI() operation in the jupyter notebook as follows:
open Microsoft.Quantum.Math;
operation Demo_BitSizeI() : Unit {
let nBits = BitSizeI(8);
Message($"Bits required to represent 8 {nBits}");
}
And you can run above operation in jupyter notebook by executing the following code in a separate code cell. This gives 4 as the result
%simulate Demo_BitSizeI
- Solution passing with/without +1: As explained in second point, BitSizeI function returns the minimum bits required to represent a number. In your case, you are generating random numbers in range [0, max-min+1] both inclusive and then filtering out extra number max-min+1 in until condition by specifying result<=max-min. Hence the test is passing.
For alternative solution, I have a minor suggestion to use let N= BitSizeI(range).
I hope this answers your query. @tcNickolas thoughts?
from quantumkatas.
I'm sorry for not answering this back in summer! I'm not sure how I've missed it, possibly I've read it and nodded along but got distracted before I actually commented?
I agree that it makes sense to use the more efficient approach you're describing, both as the main reference solution in the ReferenceImplementation.qs
and in the workbook. Would you be interested in sending the pull request with the change? (I understand if you're not, it's been a couple months, which I'm terribly sorry about...)
from quantumkatas.
Hi Nickolas! I don't have the time at the moment to submit the PR, but you are welcome to copy and paste this solution yourself!
from quantumkatas.
Related Issues (20)
- Mistake in multi-qubit measurement tutorial exercise 2 calculations. HOT 1
- Enable tests that are currently excluded with multicell solution tag HOT 2
- [MultiQubitSystemMeasurements] Add code to Exercise 2 solution to show state in Pauli X basis HOT 2
- Fix math mode rendering in browser HOT 5
- Task 1.15 in Measurements Kata says two states are orthogonal. HOT 2
- QFT Question HOT 9
- Late introduction of `ControlledOnInt` operation HOT 4
- Disable cell id generation while working on jupyter notebooks locally HOT 2
- Validate only changed katas…
- %kata magic doesn't work with lambda expressions HOT 1
- O(1) time complexity solution to Oracles tutorial, task 4.2 HOT 9
- Add error-free arbitrary state transmission demo to QEC_BitFlipCode kata HOT 7
- docker image creation is stuck HOT 1
- Add Memory Management Tutorials and Concepts HOT 1
- Systems of Equations not properly explained HOT 1
- BasicGates kata task 1.6 PhaseChange fails
- Docker Build Failing HOT 1
- getting issue in exit command HOT 1
- katakurva.html
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quantumkatas.