aboutsummaryrefslogtreecommitdiffstats
path: root/evlilik_salonu.py
diff options
context:
space:
mode:
Diffstat (limited to 'evlilik_salonu.py')
-rw-r--r--evlilik_salonu.py104
1 files changed, 104 insertions, 0 deletions
diff --git a/evlilik_salonu.py b/evlilik_salonu.py
new file mode 100644
index 0000000..139450d
--- /dev/null
+++ b/evlilik_salonu.py
@@ -0,0 +1,104 @@
1women = list(range(1,27))
2men = [chr(x + 65) for x in range(26)]
3
4n = int(input("Give n "))
5
6men = men[:n]
7women = ["0"] + women[:n]
8
9men_pref = dict()
10women_pref = dict()
11
12for (cur, m) in enumerate(men, start=1):
13
14 # last man is the same as one before last man
15 if cur == n:
16 cur = cur - 1
17
18 # Mk = Wk Wk+1 ... Wn-1 W1 W2 ... Wn
19 prefs = list()
20 k = cur
21
22 # Wk ... Wn-1
23 while k < n:
24 prefs.append(women[k])
25 k += 1
26
27 # W1 .. Wn-1
28 k = 1
29 while k < cur:
30 prefs.append(women[k])
31 k += 1
32
33 # last woman is always last
34 prefs.append(women[n])
35 men_pref[m] = prefs
36
37# Wk = Wk+1 Wk
38
39for (cur, w) in enumerate(women, start=-1):
40
41 prefs = list()
42
43 if cur == -1:
44 continue
45
46 if cur == n-1:
47 print("This is useless")
48 k = 0
49 while k < n:
50 prefs.append(men[k])
51 k += 1
52 women_pref[w] = prefs
53 continue
54
55 if cur == n - 2:
56 print(f">>>{w}")
57 # W1 Wcur
58 print(f"appending {men[0]}")
59 prefs.append(men[0])
60 print(f"appending {men[n-1]}")
61 prefs.append(men[n-1])
62
63 print(">>>>>>>")
64 print(prefs)
65 print(">>>>>>>")
66
67 k = 0
68
69 while k < n:
70 if k == n-1:
71 k += 1
72 continue
73 if k == 0:
74 k += 1
75 continue
76 prefs.append(men[k])
77 k += 1
78
79 women_pref[w] = prefs
80 print(">>>>>>>")
81 print(women_pref[w])
82 print("<<<<<<<")
83 continue
84
85 prefs.append(men[cur+1])
86 prefs.append(men[cur])
87
88 # we need n - k more men
89 k = 0
90
91 while k < n:
92 if k == cur:
93 k += 1
94 continue
95 if k == cur + 1:
96 k += 1
97 continue
98 prefs.append(men[k])
99 k += 1
100
101 women_pref[w] = prefs
102
103print(women_pref)
104print(men_pref)