import os
basepath = '/home/archit/scratch/cartpoles/data/hyperparam/cartpole/offline_learning/esarsa-adam/'
dirs = os.listdir(basepath)
string = ''''''
for dir in dirs:
	print(dir)
	subbasepath = basepath + dir + '/'
	subdirs = os.listdir(subbasepath)
	for subdir in subdirs:
		print(subdir)
		subsubbasepath = subbasepath + subdir + '/'
		subsubdirs = os.listdir(subsubbasepath)
		string += subsubbasepath + '\n'
		content = []
		for i in range(0,len(subsubdirs)-1):
			for j in range(i+1, len(subsubdirs)):
				a = os.system('diff ' + subsubbasepath + subsubdirs[i] + '/log_json.txt ' + subsubbasepath + subsubdirs[j] + '/log_json.txt')
				content.append([a, subsubdirs[i], subsubdirs[j]])
		filteredcontent = [i for i in content if i[0] == 0]
		for i in range(len(filteredcontent)):
			string += ' and '.join(filteredcontent[i][1:])
			if i != len(filteredcontent) - 1:
				string += ', '
		string += '\n\n'

f = open('offlinelearningerrors.txt','w')
f.write(string)
f.close()

[((3, 7, 3, 27), 'os.listdir', 'os.listdir', ({(3, 18, 3, 26): 'basepath'}, {}), '(basepath)', False, 'import os\n'), ((8, 11, 8, 34), 'os.listdir', 'os.listdir', ({(8, 22, 8, 33): 'subbasepath'}, {}), '(subbasepath)', False, 'import os\n'), ((12, 15, 12, 41), 'os.listdir', 'os.listdir', ({(12, 26, 12, 40): 'subsubbasepath'}, {}), '(subsubbasepath)', False, 'import os\n'), ((17, 8, 17, 129), 'os.system', 'os.system', ({(17, 18, 17, 128): "'diff ' + subsubbasepath + subsubdirs[i\n    ] + '/log_json.txt ' + subsubbasepath + subsubdirs[j] + '/log_json.txt'"}, {}), "('diff ' + subsubbasepath + subsubdirs[i] + '/log_json.txt ' +\n    subsubbasepath + subsubdirs[j] + '/log_json.txt')", False, 'import os\n')]