Last active
August 15, 2020 17:16
-
-
Save akshika47/852ecf8c5c64889c2d44c6d5cb3076fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
from enum import Enum | |
import csv | |
class Scenario_Object: | |
def __init__(self,id,name,type_id): | |
self.id = id | |
self.name = name | |
self.type = type_id | |
def __repr__(self): | |
return str(self.id) + " "+ self.name | |
list_dist = [] | |
list_info = [] | |
cnt = Counter() | |
class Scenario(Enum): | |
MEDITATION = "1 Meditation" | |
SLIDE = "3 Slide" | |
FRIEND = "7 Skype Friend" | |
FOOTBALL = "9 Football" | |
HEALTH = "2 Health" | |
NETFLIX = "4 Netflix" | |
OPEN = "5 Open Sesame" | |
SAFE = "8 Skype Safe" | |
BANK = "10 Bank" | |
scenario_dict = { | |
"d1": Scenario.MEDITATION, | |
"d2": Scenario.SLIDE, | |
"d3": Scenario.FRIEND, | |
"d4": Scenario.FOOTBALL, | |
"i1": Scenario.HEALTH, | |
"i2": Scenario.NETFLIX, | |
"i3": Scenario.OPEN, | |
"i4": Scenario.SAFE, | |
"i5": Scenario.BANK | |
} | |
list_dist.append(Scenario_Object(1, "Meditation", "d1")) | |
list_dist.append(Scenario_Object(3, "Slide", "d2")) | |
list_dist.append(Scenario_Object(7, "Skype Friend", "d3")) | |
list_dist.append(Scenario_Object(9, "Football", "d4")) | |
list_info.append(Scenario_Object(2, "Health", "i1")) | |
list_info.append(Scenario_Object(4, "Netflix", "i2")) | |
list_info.append(Scenario_Object(5, "Open Sesame", "i3")) | |
list_info.append(Scenario_Object(8, "Skype Safe", "i4")) | |
list_info.append(Scenario_Object(10, "Bank", "i5")) | |
def decode_set(final_set): | |
with open('study_order_file.csv', mode='w') as study_order_file: | |
employee_writer = csv.writer(study_order_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) | |
for x in final_set: | |
employee_writer.writerow([scenario_dict[x[0:2]], scenario_dict[x[2:4]], scenario_dict[x[4:6]], scenario_dict[x[6:8]]]) | |
print(scenario_dict[x[0:2]], scenario_dict[x[2:4]], scenario_dict[x[4:6]], scenario_dict[x[6:8]]) | |
cnt[scenario_dict[x[0:2]]] += 1 | |
cnt[scenario_dict[x[2:4]]] += 1 | |
cnt[scenario_dict[x[4:6]]] += 1 | |
cnt[scenario_dict[x[6:8]]] += 1 | |
count = 0 | |
result_set = set() | |
for pos_1 in list_dist: | |
for pos_2 in list_info: | |
for pos_3 in list_dist: | |
for pos_4 in list_info: | |
if (pos_1.id == 7 and pos_2.id == 8) or (pos_3.id == 7 and pos_4.id == 8) or (pos_1.id == 7 and pos_4.id == 8) or (pos_3.id == 7 and pos_2.id == 8): | |
continue | |
elif pos_1!=pos_3 and pos_2!=pos_4: | |
count +=1 | |
results = [str(pos_1.type), str(pos_3.type), str(pos_2.type), str(pos_4.type)] | |
results.sort() | |
result_set.add(''.join(results)) | |
decode_set(result_set) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment