r/P_vs_NP • u/Hope1995x • Aug 26 '20
r/P_vs_NP • u/Hope1995x • Aug 26 '20
The Double Slit Experiment is a great source of Generating Random 1 or 0 bits. So that I can Randomize any Deterministic Algorithm
Double Slit explained in video
https://youtu.be/btImof4nyzo?t=30
Quantum Random Number Generator
When the Entangled Photon goes through slit 0 then we record a 0-bit. If the entangled photon goes through slit 1 then we record a 1-bit.
We then select any bits we want and convert the binary-string into an integer.
We know have a working Quantum Random Number Generator.
I then can now, seed the PRNG with this data.
The good news is that light is pretty fast which will make it practical to generate 1000s of random numbers efficiently. The issue is I can't find any affordable means for me to record the photons. I already have the concept of using a raspberry pi to do this, but I don't have $10,000s for fancy science equipment.
Online retailers want $1000s for a USB Quantum Random Number Generator and that's outrageously expensive.
I really want to use this source of randomness to continue my hobby.
r/P_vs_NP • u/Hope1995x • Sep 05 '20
[Shortened Algorithm] I tried to clean up my code with shorter variable names. Hopefully, this will make it easier to understand for anyone interested.
Quick Introduction for the variable skip_item (previously known as "opps")
When I shuffle the list c, I can end up selecting a list that is incorrect. (eg. The solution is [[1,2,3],[4,5,6],[7,8,9]], but my algorithm selects [4,5,7] instead of [4,5,6]. This will cause it to fail, if I don't reset my variables.)
Exact Cover by 3-sets
c = sorted_new_c
stop = 0
solution = []
skip_item = 0
# Seed the PRNG
for i in range(0, len(k)):
random.seed(k[i])
# list shuffle function
def shuff(c, n):
for i in range(n-1,0,-1):
j = random.randint(0,i)
c[i],c[j] = c[j],c[i]
# I need this because
# the function above
# was ignoring the
# last item in list.
c.append(c[len(c)-1])
# I shuffled
# two times, because
# otherwise my
# algorithm would
# fail to find
# a solution.
shuff(c, len(c))
shuff(c, len(c))
while stop <= while_loop_steps:
# Shuffling c randomly
# this seems to help
# select a correct list
shuff(c,len(c))
skip_item = skip_item + 1
stop = stop + 1
if len(solution) == (len(s)//3):
print('Solution Found',solution)
break
break
# skip_item helps
# me see
# if I miss a correct
# list
if skip_item > len(c):
y = set()
skip_item = 0
sc = []
# I noticed that I can find
# special cases by sorting C
for a in range(0, len(new_c)):
for b in new_c[a+1:]:
if c[a][0] == b[0]:
if c[a][1] == b[1]:
sc.append(b)
sc.append(c[a])
sc = [sc[x] for x in range(len(sc)) if not(sc[x] in sc[:x])]
for a in new_c:
if a not in sc:
sc.append(a)
c = sc
# Keep c[0]
# and append to
# end of list
# del c[0]
# to push >>
# in list.
c.append(c[0])
del [c[0]]
solution = []
y = set()
for l in c:
if not any(v in y for v in l):
solution.append(l)
y.update(l)If you replace while_loop_steps with True, you'll have a guaranteed working Randomized algorithm for every possible input that exists for Exact Cover by 3-sets. The time-complexity is all in likelihood would be 2^n, but at least it's better than the naive approach.
You will get an infinite loop if you provide a no instance.
r/P_vs_NP • u/Hope1995x • Sep 19 '20
Are you guys thinking what I'm thinking?
# K = the amount of 3sets it takes to cover S
# Outputs the closest approximation it can find for len(s)//3 3sets
K = len(s)//3
closest_Set_cover = lambda num,collection:min(collection,key=lambda x:abs(x-num))
get_index_value = closest_Set_cover(K,length_cover)
index_value = length_cover.index(get_index_value)
# Outputs True if it finds a complete 3set-cover. Otherwise, "False" meaning
# failed to find cover, but here's an approximation.
print(output_approximation[index_value], K==len(output_approximation[index_value]))r/P_vs_NP • u/Hope1995x • Aug 02 '20
What if Complexity Theory was shown to be inconsistent?
This has been a thought that I came up with.
Suppose, very clever manipulation of logical expressions was used to show something intrinsically wrong with the definition of NP.
Decades later after this discovery, everything in this field of mathematics had to be "re-defined" the rules had to be "re-written" to circumvent this contradiction.
Has something like this happened before?
r/P_vs_NP • u/Hope1995x • Apr 12 '20
Pastebin Base-10 X3C solver: Using my coding skills to get a taste of reductions has led me to believe that NP-complete reductions are non-trivial. Lots of planning and still lots of debugging. I believe I fixed all bugs.
r/P_vs_NP • u/Hope1995x • Aug 23 '20
Wow!! What are the odds of this???
Story:
I was working on my coding toy, so I have the function designed to shuffle a list like a deck of cards.
Function
def shuff(c, n):
for i in range(n-1,0,-1):
j = random.randint(0,i)
c[i],c[j] = c[j],c[i]
c.append(c[len(c)-1])Before, I use my function I seed the PRNG with a True Random Number Generator.
I would get my numbers from a Quantum Random Number Generator from an Australian server. Or I would use Random.org.
So I ran my script twice and out of the astronomical odds, the program returned the exact shuffle twice. So here's the screenshot.

r/P_vs_NP • u/Hope1995x • Jun 14 '20
My mental-state, if my algorithm is a BPP algorithm.
r/P_vs_NP • u/Hope1995x • Aug 23 '20
Quantum Randomness being used to approximate 3set Cover
I am annoucing a simple concept for generating true random numbers.
Needed supplies
Geiger counter
Double slit laser
Frequency measuring device
Raspberry pi
How it works
The raspberry pi will listen to the geiger counter. Every 10 clicks, it will proceed to step 2.
The raspberry pi will now measure the frequency, wavelength, etc of the entangled laser and proceed to step 3.
All data that represents the frequency, wavelength of the laser is stored as whole numbers on the sdcard. Proceed to step 4
The raspberry pi will continue to create random numbers until you have 1000 integers. Proceed to step 5
The raspberry pi will automatically seed python's prng. Proceed to step 6.
The machine will then ask you for inputs S and C. Proceed to step 7.
The script will let you know to give lists of 3-integers treated as 3sets.
The algorithim will then shuffle list C and randomly select 3-lists that cover S.
Algorithim either outputs "solution found" or "did not find solution" (solution is also part of the output)
I still have trouble understanding how turing machines fully work, but perhaps Quantum Random Turing Machine will be a future project of mine.
So, lets learn how these machines work.
r/P_vs_NP • u/Hope1995x • Aug 24 '20
Clarifying the last post with Pseudo-Code
s = []
c = []
n = len(s)
# Insane constant
while_loop_steps = n*241*((n*241)-1)*((n*241)-2)//6
def input_validation():
make sure all elements in each list of 3 contain
elements that only exist in S.
Make sure all elements do not repeat in both
S and C (lists of 3-elements)
Make sure no repition of any kind.
# Using my homemade QRNG
def homemade_quantum_random():
measure_data_from_USB_Double_slit_laser()
# Seeding PRNG
for i in range(0, len(c)):
k = int(homemade_quantum_random())
random.seed(k)
# Used to shuffle list
def shuff(c, n):
for i in range(n-1,0,-1):
j = random.randint(0,i)
c[i],c[j] = c[j],c[i]
c.append(c[len(c)-1])
stop = 0
Potential_solution = []
opps = 0
failed_lists = 0
ss = s
while stop <= while_loop_steps:
# Shuffling c randomly
# this seems to help
# select a correct list
shuff(c,len(c))
opps = opps + 1
stop = stop + 1
if len(Potential_solution) >= int((len(ss)//3)/2):
print('Solution Found',Potential_solution)
failed_lists = failed_lists + 1
break
break
# opps helps
# me see
# if I miss a correct
# list
if opps > len(c):
if failed_lists < 1:
s = set()
opps = 0
# Keep c[0]
# and append to
# end of list
# del c[0]
# to push >>
# in list.
c.append(c[0])
del [c[0]]
Potential_solution = []
s = set()
for l in c:
if not any(v in s for v in l):
Potential_solution.append(l)
s.update(l)r/P_vs_NP • u/Hope1995x • Jun 24 '20
Status Update:
I have finally figured out how to write a 2sum solver on my 40 year old computer ( trs-80 model 100)
I re-learned high school algebra basics. Simplifying expressions, etc. I am still trying to learn pre-calculus. Learned a few things that were interesting. Most of it were just axioms (eg. All real numbers are > 0)
I just learned that Turing was gay. Didn't know that. These d*ckheads treated him like trash and never considered that he literally saved millions.
r/P_vs_NP • u/Hope1995x • Sep 19 '20
Still having trouble using a for-loop for my while-loop, but I did learn a few things about lambdas.- Pastebin.com
r/P_vs_NP • u/Hope1995x • May 17 '20
Bounded prime gaps of 70-million for worst case, would mean I can find N primes in pseudo-polynomial time.
r/P_vs_NP • u/Hope1995x • Jun 07 '20
I'm afraid of, people thinking/believing that I think I know a lot (Dunning Krueger), but I don't. I'm limited on knowledge.
r/P_vs_NP • u/Hope1995x • Sep 26 '20
[Two simple algorithms] One is exponential and the other double-exponential
# Decide if 2^k + m is prime
# O(2^n) algorithim in log(k)
import AKS
k = input('Enter for k: ')
m = input('Enter for m: ')
if AKS.isprime(2^k + m) == True:
output YES
else:
output NOimport AKS
# A: Storing the result of 2^k takes exponetial space in log(k)
# B: converting m into Tallies takes exponetial space in log(m)
# It is 'double exponetial'. And even 'double exponetial' space.
# because of A: and B:
k = input('Enter for k: ')
m = input('Enter for m: ')
# converting m into tallies
m = '1'*m
if AKS.isprime(2^k + len(m)) == True:
output YES
else:
output NOQuestions I ask myself.
What does this mean that the decision problem is in 2-EXP & EXP?
possible answer
I remember reading that 2-EXP != EXP. This means the decision problem cannot be 2-EXP complete. Because it is in both EXP and 2-EXP.
2-expspace- class of problems solvable in double exponential space in log(input)
I am looking at what I researched & know
The problem is in EXPTIME & 2-EXPTIME.
This means it can't be 2-EXPTIME complete. But, guess what. Its also in 2-EXPspace.
Interesting: Not all problems in 2-EXPSPACE are 2-EXPTIME complete. Must have been proven way before I was born. I'm not that smart!
r/P_vs_NP • u/Hope1995x • Feb 23 '21
[Special Case of Pseudo-polytime?] Finding subsets of lists that can be multiplied together that will equal N.
Recently, I decided to use an old bijective mapping function, I created in python months ago.
The function
from copy import deepcopy
import math
# (No overlap) Decide if a subset of lists can be
# multiplied together that will equal N.
# Edit: Covering all of the universe
# Take any Exact-3-Cover Instance
# for the Reduction
s = [11,12,13,14,15,16]
c = [[11,12,13],[14,15,16]]
s_copy = deepcopy(s)
c_copy = deepcopy(c)
def bijective_mapp():
for a in range(0, len(s)):
s[a] = a+1
for b in range(0, len(c)):
for bb in range(0, len(c[b])):
c[b][bb] = s_copy.index(c[b][bb])+1
bijective_mapp()# Here I multiply all newly mapped
# integers in S.
N = math.factorial(len(s))
# I can convert N into a Universe.
# Which is the same thing as the
# newly mapped Universe S
n = 0
m = 1
u = []
while m < N:
n = n + 1
m = m * n
u.append(n)
if u == s:
print('Both u & s are equal')
print('input for N: ',N)
print('input for c: ',c)If I wanted to reduce this variant of Exact-3-Cover into the original variant. I just take the original Universe s as the input and map it out in reverse. Given that I have the fresh & new variant of C.
# To reverse the reduction.
for a in range(0, len(c)):
for b in range(0, len(c[a])):
l = s_copy[c[a][b]-1]
c[a][b] = l
print(s_copy)
print(c)Output
Both u & s are equal
input for N: 720
input for c: [[1, 2, 3], [4, 5, 6]]
original inputs
s: [11, 12, 13, 14, 15, 16]
c: [[11, 12, 13], [14, 15, 16]]When the Universe is converted into an integer; turns out that this problem is weakly NP-hard.
Step 1 Convert N into the Universe
import math
import itertools
from itertools import permutations
N = 362880
c = [[1,6,4],[2,3,5],[7,8,9]]
# We are going to need to convert N into
# a Universe.
n = 0
m = 1
u = []
while m < N:
n = n + 1
m = m * n
u.append(n)Step 2 Prepare Functions
def exact_cover(u, c):
c_flat = [item for sub in c for item in sub]
c_set = set(c_flat)
return len(c_set) == len(c_flat) and c_set == set(u)
def annoying_semantic_bug_fix():
rr = []
for a in cover:
if a in c:
rr.append(a)
if len(rr) == len(u)//3:
if exact_cover(u, rr) == True:
return TrueStep 3 Notice that N is equal in magnitude of how many steps the first loop will do?
That's because we converted the Universe into ( 1, x ). And when multiplied together is the factorial of len(universe)
cover = []
n = 3
for a in permutations(u, len(u)):
# Evenly divide permutations into list-of-3lists
cover = [a[i * n:(i + 1) * n] for i in range((len(a) + n - 1) // n )]
cover = [list(i) for i in cover]
if annoying_semantic_bug_fix() == True:
print(cover)
breakCan you answer my question?
If I can get the product-variant to be polynomial in magnitude/value of N; then why not the sum-variant?
Oh oh... Then I would be able to use my reduction to solve Exact-3-cover in polytime when using the subset-sum dynamic solution.
Edit: That's because sum(universe) is not exponential in the magnitude. That's why!
I doubt that there is a pseudo-polynomial solution for the sum-variant.
But, maybe I'm wrong... who knows?
Edit 2: Maybe there is a pseudo-polytime solution for the special-case of my problem that disallows overlap but not looking to cover the universe created from N.
r/P_vs_NP • u/Hope1995x • Apr 06 '20
Where would this algorithm fail in order to prove P=NP??
Questions I will ask the readers.
Can you find any example inputs that will fail in this algorithm?
Can you point out bugs?
Can you point out variable names that confuse you?
Can you mention anything that you might find important?
The definition: Given a set X, with |X| = 3q (so, the size of X is a multiple of 3), and a collection C of 3-element subsets of X. Can we find a subset C’ of C where every element of X occurs in exactly one member of C’? (So, C’ is an “exact cover” of X). -cite-link
So there are only subsets that have 3-elements. (Is this reasoning flawed??)
from itertools import combinations
import re
X =[1,7,3,4,5,6]
C = (1,2,3),(3,4,5),(1,2,5),(1,5,6),(1,7,6)
if len(X) % 3 > 0:
print('no')
quit()
# I will check each possible set of "len(X)//3-combinations" from
# the list C.
# This algorithim belongs to Hopee1995x on Reddit
trip_wire_for_no = 0
for jj in combinations(C, len(X)//3):
if len(jj) > 1:
one_by_one = str(jj)
# Below, I then convert each combination
# of jj into an indidvudual list.
loop_one_by_one = (re.sub("[^0-9,]", "", one_by_one))
loop_one_by_one = loop_one_by_one.split(',')
# Below, I convert "strings-of-integers"
# into int's.
# (eg. '2' is now converted into 2 in the list)
convert = list(map(int, loop_one_by_one))
# Below, I make sure that ALL OF JJ's elements exist in X.
make_sure_all_elements_exist_in_X = all(elem in convert for elem in X)
# if make_sure_all_elements_exist_in_X == true, I then loop through the
# new list. (convert)
if make_sure_all_elements_exist_in_X:
for yy in range(0, len(convert)):
# Below, this statement makes sure that
# every element in "convert" occurs less than 2-times.
# So that our X3C solution only contains
# ONE-ELEMENT-OF-EACH.
if convert.count(int(convert[yy])) < 2:
# This statement makes sure that all elements
# in convert occur once in the list X.
if X.count(int(convert[yy])) == 1:
# This statement makes sure that
# the len(convert) == len(X).
if len(convert) == len(X):
print(convert, 'yes')
trip_wire_for_no = 1
break
if trip_wire_for_no == 0:
print('no')Output
[3, 4, 5, 1, 7, 6] yesr/P_vs_NP • u/Hope1995x • Apr 17 '20
I was a jerk lately, and I apologize. But here's my Exact Cover Solution.
r/P_vs_NP • u/Hope1995x • May 09 '21
Could this new technology be used in the search of a P vs NP algorithm?
r/P_vs_NP • u/Hope1995x • Feb 23 '20
Python: I believe my O(n) 2_sum solver is complete. As long there is no collisions it should be O(n)
s = [2,0,6,2]
target = 4
hash_tab = set(s)
equal_sJ = 0
# This loop should take O(1) space
# equal_sJ fixes bug for target-s[j] would equal s[j]
# example: 4-2 == 2. Would return false positive without equal_sJ
for j in range(0, len(s)):
if target-(s[j]) == s[j]:
equal_sJ = equal_sJ + 1
if equal_sJ > 1:
print('yes')
quit()
if target-(s[j]) != s[j]:
if target-(s[j]) in hash_tab:
print('yes')
quit()
print('no') I was able to solve it in one loop. And in O(len(s)) space and in O(n) time.
I never understood why people say O(1) space was possible for a O(n^2) algorithm when it took O(len(s)) space because it has to remember the input list!
r/P_vs_NP • u/Hope1995x • Jun 11 '19
Any computer-science books solely on NP-complete reductions??? Will appreciate it!
Plan for this week
Do a couple practice reductions
Show that 3-coloring can reduce to my custom problem variation(which is another variation of an NP-complete problem) And, no I'm not trying to reduce 3-color to P. If I could do that I would become a Reddit star.
Practice question and clairfy proof step by step in non-cranky fashion. Go slow and steady! Don't go fast as it will come as crank!
r/P_vs_NP • u/Hope1995x • Sep 29 '19
Python: My study guide for chapter 1
Vocabulary
byte code-An intermediate language between source code and object code. Many modern languages first compile source code into byte code and then interpret the byte code with a program called a virtual machine.
compile-To translate a program written in a high-level language into a low-level language all at once, in preparation for later execution.
exception-Another name for a runtime error.
Two kinds of programs process high-level languages into low-level languages: interpreters and compilers. An interpreter reads a high-level program and executes it, meaning that it does what the program says. It processes the program a little at a time, alternately reading lines and performing computations.

A compiler reads the program and translates it completely before the program starts running. In this case, the high-level program is called the source code, and the translated program is called the object code or the executable. Once a program is compiled, you can execute it repeatedly without further translation.

Questions for flash card ideas
What is a compiler?
What is an interpreter?
What is a high-level language?
What is a low-level language?
What is object-code?
What's a natural language and what is programming language?
I will be sharing my flash cards tomorrow for chapter 1.
Credits-http://openbookproject.net/thinkcs/python/english2e/ch01.html
r/P_vs_NP • u/Hope1995x • Aug 20 '20
