Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DeutschJozsaClassicalSolver : ISolver<DEUTSCHJOZSA> {

// --- Fields ---
public string solverName {get;} = "Deutsch Jozsa Problem - Classical Solver";
public string solverDefinition {get;} = "This is a classical solver for the Deutsch Jozsa Problem";
public string solverDefinition { get; } = "This solver classically solves the Deutsch-Jozsa problem by querying the oracle up to (n/2) + 1 times to determine if the function is constant or balanced.";
public string source { get; } = "Deutsch, David and Jozsa, Richard. 1992. Rapid solution of problems by quantum computation. Proc. R. Soc. Lond. A439553-558";
public string[] contributors {get;} = { "George Lake", "Eric Hill", "Paul Gilbreath", "Max Gruenwoldt", "Alex Svancara" };

Expand All @@ -26,7 +26,7 @@ public string solve(DEUTSCHJOZSA problem){
// ("Balanced" or "Constant")
//
// NOTE: This solver returns "Breaks DJ Promise" in the event that the input does.
// Technically this breaks the idea of the input being a black box.
// Technically this breaks the idea of the input being a black box.
// I kept the idea for education purposes

List<int> oracle = problem.w;
Expand All @@ -39,8 +39,8 @@ public string solve(DEUTSCHJOZSA problem){
int queries_to_be_certain = (total_inputs / 2) + 1;

// Check DJ promise
if (!(oracle.All(v => v == 0) || oracle.All(v => v == 1) || oracle.Count(v => v == 0) * 2 == oracle.Count))
return "{Breaks DJ Promise}";
if (!(oracle.All(v => v == 0) || oracle.All(v => v == 1) || oracle.Count(v => v == 0) * 2 == oracle.Count))
return "Breaks DJ Promise";

// check the inputs
for (int i = 1; i <queries_to_be_certain; i++)
Expand All @@ -51,11 +51,11 @@ public string solve(DEUTSCHJOZSA problem){
// check if different than first
if (current_value != first_value)
{
return "{Balanced}";
return "balanced";
}
}

// if we reach this point, all the inputs were the same
return "{Constant}";
return "constant";
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using API.Interfaces;
using API.Problems.NPComplete.NPC_DEUTSCHJOZSA.Solvers;

namespace API.Problems.NPComplete.NPC_DEUTSCHJOZSA.Verifiers;

class DeutschJozsaVerifier : IVerifier<DEUTSCHJOZSA> {

// --- Fields ---
public string verifierName {get;} = "ProblemVerifier";
public string verifierDefinition {get;} = "TODO";
public string source {get;} = " ";
public string[] contributors {get;} = { "Eric Hill", "Paul Gilbreath", "Max Gruenwoldt", "Alex Svancara" };
public string verifierName { get; } = "Deutsch Jozsa Verifier";
public string verifierDefinition { get; } = "This verifier uses the classical solver to verify the solution to the Deutsch-Jozsa problem.";
public string source { get; } = "Deutsch, David and Jozsa, Richard. 1992. Rapid solution of problems by quantum computation. Proc. R. Soc. Lond. A439553-558";
public string[] contributors { get; } = { "Jason L. Wright", "Eric Hill", "Paul Gilbreath", "Max Gruenwoldt", "Alex Svancara" };
private string _certificate = "";

public string certificate {
Expand All @@ -18,12 +19,12 @@ public string certificate {
}

// --- Methods Including Constructors ---
public DeutschJozsaVerifier() {
public DeutschJozsaVerifier()
{
}

public bool verify(DEUTSCHJOZSA problem, string certificate){
// TODO: implement {VERIFIER} for {PROBLEM}
return true;
var solver = new DeutschJozsaClassicalSolver();
return solver.solve(problem) == certificate && (certificate is "constant" or "balanced");
}
}