using System; using Microsoft.Quantum.Simulation.Core; using Microsoft.Quantum.Simulation.Simulators; using System.Collections.Generic; using System.Linq; using System.Text; using Kadet.Quantum.Tests; namespace Kadet.Quantum { class Driver { delegate T QuantumTest(IOperationFactory simulator); static string Ket(string thing) { return $"|{thing}⟩"; } static void Main(string[] args) { var results = new Dictionary<(bool, bool), long>(); var rand = new Random(); var rsim = new ResourcesEstimator(); using (var qsim = new QuantumSimulator()) { Console.Write("Search QuantumDB: "); long index = int.Parse(Console.ReadLine()); long[] database = { 7, 44, 24, 2, 55, 35, 53, 4, 17, 3, 58, 21, 15, 28, 50, 19 }; QuantumTest solve = sim => TestDatabaseSearch.Run(sim, new QArray(database), index).Result; var result = Enumerable .Range(1, 100) .Select(x => solve(qsim)) .OrderBy(x => x) .GroupBy(x => $"{x}"); foreach (var group in result) { Console.WriteLine($"{Ket(group.Key.ToString())} ({group.Count()})"); } solve(rsim); Console.WriteLine(); Console.WriteLine("Resources usage:"); Console.WriteLine(rsim.ToTSV()); } } } }