-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also adds task 1.5 to Superposition kata and updates docs on `@[exercise]` macro
- Loading branch information
1 parent
7b56bdf
commit 8369a7d
Showing
32 changed files
with
191 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
namespace Kata { | ||
open Microsoft.Quantum.Measurement; | ||
operation RandomNBits(N : Int) : Int { | ||
// Implement your solution here... | ||
|
||
return -1; | ||
} | ||
|
||
// You can use this operation to implement your solution. | ||
// You can use the operation defined in the first exercise to implement your solution. | ||
operation RandomBit() : Int { | ||
// Allocate single qubit. | ||
use q = Qubit(); | ||
|
||
// Set qubit in superposition state. | ||
H(q); | ||
|
||
// Measuring the qubit and reset. | ||
let result = M(q); | ||
Reset(q); | ||
|
||
// Return integer value of result. | ||
if result == One { | ||
return 1; | ||
} | ||
return 0; | ||
return MResetZ(q) == Zero ? 0 | 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,17 @@ | ||
namespace Kata { | ||
open Microsoft.Quantum.Measurement; | ||
operation RandomNBits(N : Int) : Int { | ||
mutable result = 0; | ||
for i in 0..(N - 1) { | ||
for i in 0 .. N - 1 { | ||
set result = result * 2 + RandomBit(); | ||
} | ||
return result; | ||
} | ||
|
||
// You can use the operation defined in the first exercise to implement your solution. | ||
operation RandomBit() : Int { | ||
// Allocate single qubit. | ||
use q = Qubit(); | ||
|
||
// Set qubit in superposition state. | ||
H(q); | ||
|
||
// Measuring the qubit and reset. | ||
let result = M(q); | ||
Reset(q); | ||
|
||
// Return integer value of result. | ||
if result == One { | ||
return 1; | ||
} | ||
return 0; | ||
return MResetZ(q) == Zero ? 0 | 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 10 additions & 12 deletions
22
katas/content/random_numbers/random_number/Placeholder.qs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
namespace Kata { | ||
open Microsoft.Quantum.Measurement; | ||
|
||
operation RandomNumberInRange(min : Int, max : Int) : Int { | ||
// Implement your solution here... | ||
|
||
return -1; | ||
} | ||
|
||
// You can use this operation to implement your solution. | ||
// You can use the operations defined in the earlier exercises to implement your solution. | ||
operation RandomBit() : Int { | ||
// Allocate single qubit. | ||
use q = Qubit(); | ||
|
||
// Set qubit in superposition state. | ||
H(q); | ||
return MResetZ(q) == Zero ? 0 | 1; | ||
} | ||
|
||
// Measuring the qubit and reset. | ||
let result = M(q); | ||
Reset(q); | ||
|
||
// Return integer value of result. | ||
if result == One { | ||
return 1; | ||
operation RandomNBits(N : Int) : Int { | ||
mutable result = 0; | ||
for i in 0 .. N - 1 { | ||
set result = result * 2 + RandomBit(); | ||
} | ||
return 0; | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 3 additions & 14 deletions
17
katas/content/random_numbers/random_two_bits/Placeholder.qs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
namespace Kata { | ||
open Microsoft.Quantum.Measurement; | ||
operation RandomTwoBits() : Int { | ||
// Implement your solution here... | ||
|
||
return -1; | ||
} | ||
|
||
// You can use this operation to implement your solution. | ||
// You can use the operation defined in the previous exercise to implement your solution. | ||
operation RandomBit() : Int { | ||
// Allocate single qubit. | ||
use q = Qubit(); | ||
|
||
// Set qubit in superposition state. | ||
H(q); | ||
|
||
// Measuring the qubit and reset. | ||
let result = M(q); | ||
Reset(q); | ||
|
||
// Return integer value of result. | ||
if result == One { | ||
return 1; | ||
} | ||
return 0; | ||
return MResetZ(q) == Zero ? 0 | 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
namespace Kata { | ||
open Microsoft.Quantum.Measurement; | ||
operation RandomTwoBits() : Int { | ||
return 2 * RandomBit() + RandomBit(); | ||
} | ||
|
||
operation RandomBit() : Int { | ||
// Allocate single qubit. | ||
use q = Qubit(); | ||
|
||
// Set qubit in superposition state. | ||
H(q); | ||
|
||
// Measuring the qubit and reset. | ||
let result = M(q); | ||
Reset(q); | ||
|
||
// Return integer value of result. | ||
if result == One { | ||
return 1; | ||
} | ||
return 0; | ||
return MResetZ(q) == Zero ? 0 | 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,4 @@ namespace Kata { | |
|
||
return -1; | ||
} | ||
|
||
} |
Oops, something went wrong.