<filename>ex_study_nonces2.py
from params import *
from utils import *
from shared_pow import *
from compress import *

import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

sns.set_theme(color_codes=True)
tips = sns.load_dataset("tips")

print(tips.to_dict())

"""
x = {
	"col_name": {
		"row index": value,
		"row index + 1": value
	}
}


"""

exit()


freq_table_a = {}
freq_table_b = {}
cpow = CPoW()
for n in range(0, 1):
	nonce_info = []
	cpow.fingerprint = None

	for i in range(n, SET_NO - 1): #  SET_NO - 1 Skip last for now
		print("----------------------")
		print("Set n %d" % i)

		hash_list = compute_edge_hash_list(TEST_NODE_LIST, i, b"x")[i * POW_SET_LEN:(i + 1) * POW_SET_LEN]
		with open(os.path.join(NONCE_PATH, str(i) + ".txt"), "r") as text_file:
			content = text_file.read()
			nonce_info = eval(content)[::-1]
			for x in range(0, len(nonce_info)):
				remaining_hashes = []
				for i in range(0, len(hash_list)):
					remaining_hashes.append(hash_list[i:])

				if not len(nonce_info[x]):
					continue

				if(type(nonce_info[x][0]) == list):
					nonce_info[x] = nonce_info[x][0]

				results = cpow.all(b"", nonce_info[x][0], remaining_hashes, [])
				result = results[0]
				n_bytes, p_info, out_val = result
				if out_val > 4096:
					continue
				

				q1 = p_info[0][0]
				q2 = p_info[0][1]
				q3 = p_info[1][0]
				q4 = p_info[1][1]
				pair = [q1, q2, q3, q4]

				if repr(pair) in freq_table_a:
					freq_table_a[repr(pair)] += 1
				else:
					freq_table_a[repr(pair)] = 1

				q1 = p_info[2][0]
				q2 = p_info[2][1]
				q3 = p_info[3][0]
				q4 = p_info[3][2]
				pair = [q1, q2, q3, q4]

				if repr(pair) in freq_table_b:
					freq_table_b[repr(pair)] += 1
				else:
					freq_table_b[repr(pair)] = 1


# Sort 
freq_lists_a = list(freq_table_a.items())
freq_lists_a = sorted(freq_lists_a, key=lambda k: k[1], reverse=True)
freq_lists_b = list(freq_table_b.items())
freq_lists_b = sorted(freq_lists_b, key=lambda k: k[1], reverse=True)


"""
for i in range(0, 32):
	freq_list = freq_lists_a[i]
	print(freq_list[0] + ",")


print("------------------------")
"""


for i in range(0, 32):
	freq_list = freq_lists_b[i]
	print(freq_list[0] + ",")
	print(freq_list[1])







