A collection of Golang implementations for programming drills from "Quantum Computing for Computer Scientists" by Mirco A. Mannucci and Noson S. Yanofsky.
Title: Quantum Computing for Computer Scientists
Authors: Mirco A. Mannucci and Noson S. Yanofsky
Focus: Bridging the gap between traditional computer science concepts and quantum computing fundamentals.
This repository contains my solutions to the programming exercises and drills from the book, implemented in Go (Golang).
quantum-computing-drills/
│
├── README.md # This file
├── go.mod # Go module file
├── LICENSE # MIT License
│
├── pkg/ # Core quantum computing packages
│ ├── complex/ # Complex number utilities
│ ├── matrix/ # Matrix operations for quantum states
│ ├── qubit/ # Qubit representation and operations
│ ├── gates/ # Quantum gate implementations
│ └── circuits/ # Quantum circuit simulation
│
├── chapters/ # Solutions organized by book chapters
│ ├── chapter01/ # Introduction & Mathematical Preliminaries
│ │ ├── main.go
│ │ ├── exercises.go
│ │ └── README.md
│ ├── chapter02/ # Quantum Mechanics Basics
│ ├── chapter03/ # Quantum Bits (Qubits)
│ ├── chapter04/ # Quantum Gates
│ ├── chapter05/ # Quantum Circuits
│ ├── chapter06/ # Quantum Algorithms
│ └── ...
│
├── examples/ # Complete working examples
│ ├── bell_state/ # Bell state creation
│ ├── deutsch_jozsa/ # Deutsch-Jozsa algorithm
│ ├── grovers_search/ # Grover's search algorithm
│ └── quantum_fourier/ # Quantum Fourier Transform
│
├── tests/ # Unit tests for all implementations
│ ├── complex_test.go
│ ├── matrix_test.go
│ ├── qubit_test.go
│ └── gates_test.go
│
└── docs/ # Documentation and notes
├── concepts.md
├── book_notes.md
└── algorithms.md- Complex Numbers (Chapter 1)
// Complex number representation
type Complex struct {
Real float64
Imag float64
}
// Operations: addition, multiplication, conjugation, norm- Qubit Representation (Chapter 3)
type Qubit struct {
Alpha complex128 // |0⟩ coefficient
Beta complex128 // |1⟩ coefficient
}
// Methods: measure, applyGate, tensorProduct- Quantum Gates (Chapter 4)
// Pauli gates, Hadamard, CNOT, etc.
type Gate interface {
Apply(Qubit) Qubit
Matrix() [][]complex128
}- Quantum Circuits (Chapter 5)
type Circuit struct { Qubits []Qubit Gates []Gate Steps int }
- Go 1.20+ installed
- Basic understanding of linear algebra
- Familiarity with complex numbers
# Clone the repository
git clone https://github.com/maziyar-redox/QuantumComputerForComputerScientists-Exercises.git
cd QuantumComputerForComputerScientists-Exercises
# Install dependencies
go mod download
# Run tests to verify installation
go test ./...# Run a specific chapter's solutions
cd chapters/chapter03
go run main.go
# Run a complete algorithm example
cd examples/bell_state
go run main.go- Complex number operations
- Linear algebra basics
- Matrix multiplication
- Inner products and norms
- State vectors
- Observables
- Measurement
- Tensor products
- Qubit representation
- Bloch sphere
- Single qubit operations
- Computational basis
- Pauli matrices
- Hadamard gate
- Phase gates
- Controlled gates
- Circuit diagrams
- Gate sequences
- Multiple qubit systems
- Circuit optimization
- Deutsch-Jozsa algorithm
- Bernstein-Vazirani
- Simon's algorithm
- Grover's search
(Additional chapters will be added as progress continues)
Run comprehensive tests to verify quantum operations:
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run specific package tests
go test ./pkg/qubit
# Run benchmark tests
go test -bench=. ./pkg/matrix| Chapter | Status | Exercises Completed |
|---|---|---|
| 1 | ✅ Complete | 15/15 |
| 2 | 🔄 In Progress | 15/15 |
| 3 | ⏳ Pending | 15/15 |
| 4 | ✅ Complete | 15/15 |
While this is primarily a personal learning repository, suggestions are welcome:
- Issues: Report bugs or suggest improvements
- Discussion: Share alternative approaches or optimizations
- Educational Value: Focus on clarity and learning resources
Note: Please don't submit direct solutions to book exercises.
MIT License - See LICENSE file for details.
All code implementations are original work by Mr_Red0x.
Book exercises copyright © by Mirco A. Mannucci and Noson S. Yanofsky.
Last Updated: 12/31/2025