WolframAlpha.com
WolframCloud.com
All Sites & Public Resources...
Products & Services
Wolfram|One
Mathematica
Wolfram|Alpha Notebook Edition
Finance Platform
System Modeler
Wolfram Player
Wolfram Engine
WolframScript
Enterprise Private Cloud
Application Server
Enterprise Mathematica
Wolfram|Alpha Appliance
Enterprise Solutions
Corporate Consulting
Technical Consulting
Wolfram|Alpha Business Solutions
Resource System
Data Repository
Neural Net Repository
Function Repository
Wolfram|Alpha
Wolfram|Alpha Pro
Problem Generator
API
Data Drop
Products for Education
Mobile Apps
Wolfram Player
Wolfram Cloud App
Wolfram|Alpha for Mobile
Wolfram|Alpha-Powered Apps
Services
Paid Project Support
Wolfram U
Summer Programs
All Products & Services »
Technologies
Wolfram Language
Revolutionary knowledge-based programming language.
Wolfram Cloud
Central infrastructure for Wolfram's cloud products & services.
Wolfram Science
Technology-enabling science of the computational universe.
Wolfram Notebooks
The preeminent environment for any technical workflows.
Wolfram Engine
Software engine implementing the Wolfram Language.
Wolfram Natural Language Understanding System
Knowledge-based broadly deployed natural language.
Wolfram Data Framework
Semantic framework for real-world data.
Wolfram Universal Deployment System
Instant deployment across cloud, desktop, mobile, and more.
Wolfram Knowledgebase
Curated computable knowledge powering Wolfram|Alpha.
All Technologies »
Solutions
Engineering, R&D
Aerospace & Defense
Chemical Engineering
Control Systems
Electrical Engineering
Image Processing
Industrial Engineering
Mechanical Engineering
Operations Research
More...
Finance, Statistics & Business Analysis
Actuarial Sciences
Bioinformatics
Data Science
Econometrics
Financial Risk Management
Statistics
More...
Education
All Solutions for Education
Trends
Machine Learning
Multiparadigm Data Science
Internet of Things
High-Performance Computing
Hackathons
Software & Web
Software Development
Authoring & Publishing
Interface Development
Web Development
Sciences
Astronomy
Biology
Chemistry
More...
All Solutions »
Learning & Support
Learning
Wolfram Language Documentation
Fast Introduction for Programmers
Wolfram U
Videos & Screencasts
Wolfram Language Introductory Book
Webinars & Training
Summer Programs
Books
Need Help?
Support FAQ
Wolfram Community
Contact Support
Premium Support
Paid Project Support
Technical Consulting
All Learning & Support »
Company
About
Company Background
Wolfram Blog
Events
Contact Us
Work with Us
Careers at Wolfram
Internships
Other Wolfram Language Jobs
Initiatives
Wolfram Foundation
MathWorld
Computer-Based Math
A New Kind of Science
Wolfram Technology for Hackathons
Student Ambassador Program
Wolfram for Startups
Demonstrations Project
Wolfram Innovator Awards
Wolfram + Raspberry Pi
Summer Programs
More...
All Company »
Search
WOLFRAM COMMUNITY
Connect with users of Wolfram technologies to learn, solve problems and share ideas
Join
Sign In
Dashboard
Groups
People
Message Boards
Answer
(
Unmark
)
Mark as an Answer
GROUPS:
Staff Picks
Computer Science
Mathematica Add-Ons
External Programs and Systems
Graphics and Visualization
Wolfram Language
Packages
Challenges
Events & Media
Quantum Computing
14
Nikolay Murzin
Solving Classiq Coding Competition with the Wolfram Quantum Framework
Nikolay Murzin
Posted
13 days ago
834 Views
|
4 Replies
|
17 Total Likes
Follow this post
|
Solving Classiq Coding Competition with the Wolfram Quantum Framework
by
Nikolay Murzin
Recently tried myself at my first
quantum competition
and ended up winning one of the Innovative Solution prizes. Here is a slightly messy notebook in a form of a Computational Essay that formed my final submission:
Intro
The problem:
https://www.classiq.io/competition/kakuro
Kakuro is a logic puzzle, often referred to as a mathematical transliteration of the crossword. The puzzle is played on a grid of filled and empty cells. The filled cells contain the required sum for the matching empty cells.
The objective of the puzzle is to fill the empty spaces under two constraints:
- Two cells on the same row/column cannot have the same number.
- The sum of the cells on each row/column should equal the matching filled cell.
Using the QuantumFramework paclet, which is very much in early stages of development. Some features were written specifically to help solve this problem, like boolean oracles and improved Qiskit integration.
https://www.wolframcloud.com/obj/wolframquantumframework/DeployedResources/Paclet/Wolfram/QuantumFramework/
I
n
[
]
:
=
P
a
c
l
e
t
I
n
s
t
a
l
l
[
"
h
t
t
p
s
:
/
/
w
o
l
f
r
.
a
m
/
D
e
v
W
Q
C
F
"
,
F
o
r
c
e
V
e
r
s
i
o
n
I
n
s
t
a
l
l
-
>
T
r
u
e
]
<
<
W
o
l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d
@
@
b
o
o
l
C
o
n
s
t
r
a
i
n
t
s
/
.
T
h
r
e
a
d
[
v
a
r
s
-
>
#
]
,
T
h
r
e
a
d
[
v
a
r
s
-
>
B
o
o
l
e
@
#
]
,
N
o
t
h
i
n
g
]
&
/
@
T
u
p
l
e
s
[
{
F
a
l
s
e
,
T
r
u
e
}
,
L
e
n
g
t
h
[
v
a
r
s
]
]
O
u
t
[
]
=
{
{
x
0
0
,
x
1
1
,
x
2
1
,
x
3
[
1
]
0
,
x
3
[
2
]
1
,
x
4
0
,
x
5
0
,
x
6
1
}
}
Classical solver:
I
n
[
]
:
=
S
a
t
i
s
f
i
a
b
i
l
i
t
y
I
n
s
t
a
n
c
e
s
[
A
n
d
@
@
b
o
o
l
C
o
n
s
t
r
a
i
n
t
s
,
v
a
r
s
,
A
l
l
]
O
u
t
[
]
=
{
{
F
a
l
s
e
,
T
r
u
e
,
T
r
u
e
,
F
a
l
s
e
,
T
r
u
e
,
F
a
l
s
e
,
F
a
l
s
e
,
T
r
u
e
}
}
Circuit construction
Construct BooleanOracles for each individual constraint, putting each result on a separate ancilla:
I
n
[
]
:
=
o
r
a
c
l
e
0
=
Q
u
a
n
t
u
m
C
i
r
c
u
i
t
O
p
e
r
a
t
o
r
[
M
a
p
I
n
d
e
x
e
d
[
Q
u
a
n
t
u
m
C
i
r
c
u
i
t
O
p
e
r
a
t
o
r
[
{
"
B
o
o
l
e
a
n
O
r
a
c
l
e
"
,
#
,
v
a
r
s
,
L
e
n
g
t
h
[
v
a
r
s
]
+
F
i
r
s
t
[
#
2
]
}
,
c
o
n
s
t
r
a
i
n
t
L
a
b
e
l
s
[
[
F
i
r
s
t
@
#
2
]
]
]
&
,
b
o
o
l
C
o
n
s
t
r
a
i
n
t
s
]
]
;
I
n
[
]
:
=
o
r
a
c
l
e
0
[
"
F
l
a
t
t
e
n
"
]
[
"
D
i
a
g
r
a
m
"
]
O
u
t
[
]
=
BooleanOracleR decomposes RZ(
π
) or RY(
π
) in place of an X with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T
a
r
g
e
t
O
r
d
e
r
"
]
,
x
s
=
T
a
b
l
e
[
Q
u
a
n
t
u
m
O
p
e
r
a
t
o
r
[
"
X
"
,
{
i
}
]
,
{
i
,
q
o
[
"
L
a
b
e
l
"
]
[
[
3
]
]
}
]
,
m
c
x
,
C
o
n
f
i
r
m
A
s
s
e
r
t
[
L
e
n
g
t
h
[
t
a
r
g
e
t
]
=
=
1
]
;
m
c
x
=
M
C
X
C
i
r
c
u
i
t
[
J
o
i
n
[
c
o
n
t
r
o
l
s
,
t
a
r
g
e
t
]
]
;
I
f
[
L
e
n
g
t
h
[
x
s
]
>
0
,
Q
u
a
n
t
u
m
C
i
r
c
u
i
t
O
p
e
r
a
t
o
r
[
x
s
]
@
*
m
c
x
@
*
Q
u
a
n
t
u
m
C
i
r
c
u
i
t
O
p
e
r
a
t
o
r
[
x
s
]
,
m
c
x
]
]
D
e
c
o
m
p
o
s
e
M
C
X
[
q
o
_
Q
u
a
n
t
u
m
O
p
e
r
a
t
o
r
]
:
=
q
o
D
e
c
o
m
p
o
s
e
M
C
X
[
q
c
o
_
Q
u
a
n
t
u
m
C
i
r
c
u
i
t
O
p
e
r
a
t
o
r
]
:
=
Q
u
a
n
t
u
m
C
i
r
c
u
i
t
O
p
e
r
a
t
o
r
[
D
e
c
o
m
p
o
s
e
M
C
X
/
@
q
c
o
[
"
O
p
e
r
a
t
o
r
s
"
]
]
Try decomposing every MCX gate into a V-chain for comparison:
I
n
[
]
:
=
o
r
a
c
l
e
V
C
h
a
i
n
=
D
e
c
o
m
p
o
s
e
M
C
X
@
o
r
a
c
l
e
0
;
I
n
[
]
:
=
C
o
u
n
t
s
[
#
[
"
A
r
i
t
y
"
]
&
/
@
o
r
a
c
l
e
V
C
h
a
i
n
[
"
F
l
a
t
t
e
n
"
]
[
"
O
p
e
r
a
t
o
r
s
"
]
]
O
u
t
[
]
=
1
3
5
4
,
2
2
2
5
The BooleanOracleR is much better...
84
is the final CNOT count without MCX
Going to use V-chain for the final MC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1
0
1
0
0
0
.
0
0
3
8
2
4
8
8
The solution has the highest probability as expected.
Decomposed oracle with BooleanOracleR.
I
n
[
]
:
=
o
r
a
c
l
e
=
Q
u
a
n
t
u
m
C
i
r
c
u
i
t
O
p
e
r
a
t
o
r
[
M
a
p
I
n
d
e
x
e
d
[
Q
u
a
n
t
u
m
C
i
r
c
u
i
t
O
p
e
r
a
t
o
r
[
{
"
B
o
o
l
e
a
n
O
r
a
c
l
e
R
"
,
#
,
v
a
r
s
,
n
+
F
i
r
s
t
[
#
2
]
,
{
"
Y
R
o
t
a
t
i
o
n
"
,
P
i
}
}
,
c
o
n
s
t
r
a
i
n
t
L
a
b
e
l
s
[
[
F
i
r
s
t
@
#
2
]
]
]
&
,
b
o
o
l
C
o
n
s
t
r
a
i
n
t
s
]
]
/
*
Q
u
a
n
t
u
m
C
i
r
c
u
i
t
O
p
e
r
a
t
o
r
[
{
S
p
l
i
c
e
@
T
a
b
l
e
[
Q
u
a
n
t
u
m
O
p
e
r
a
t
o
r
[
"
H
"
,
{
i
}
]
,
{
i
,
n
+
1
,
n
+
m
}
]
,
Q
u
a
n
t
u
m
O
p
e
r
a
t
o
r
[
{
"
C
o
n
t
r
o
l
l
e
d
"
,
"
N
O
T
"
,
R
a
n
g
e
[
n
+
1
,
n
+
m
]
}
,
{
n
+
m
+
1
}
]
}
]
/
/
N
;
Not running it on any state, just confirming gate equality to the undecomposed version:
I
n
[
]
:
=
T
h
r
e
a
d
[
o
r
a
c
l
e
0
[
"
O
p
e
r
a
t
o
r
s
"
]
=
=
o
r
a
c
l
e
[
"
O
p
e
r
a
t
o
r
s
"
]
]
O
u
t
[
]
=
{
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r
u
e
,
T
r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