From eea912b9c327d397197212e326b7f2728d59a306 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Mon, 9 Nov 2020 03:11:55 +0300 Subject: Add used python scripts --- evlilik_salonu.py | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 evlilik_salonu.py (limited to 'evlilik_salonu.py') 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 @@ +women = list(range(1,27)) +men = [chr(x + 65) for x in range(26)] + +n = int(input("Give n ")) + +men = men[:n] +women = ["0"] + women[:n] + +men_pref = dict() +women_pref = dict() + +for (cur, m) in enumerate(men, start=1): + + # last man is the same as one before last man + if cur == n: + cur = cur - 1 + + # Mk = Wk Wk+1 ... Wn-1 W1 W2 ... Wn + prefs = list() + k = cur + + # Wk ... Wn-1 + while k < n: + prefs.append(women[k]) + k += 1 + + # W1 .. Wn-1 + k = 1 + while k < cur: + prefs.append(women[k]) + k += 1 + + # last woman is always last + prefs.append(women[n]) + men_pref[m] = prefs + +# Wk = Wk+1 Wk + +for (cur, w) in enumerate(women, start=-1): + + prefs = list() + + if cur == -1: + continue + + if cur == n-1: + print("This is useless") + k = 0 + while k < n: + prefs.append(men[k]) + k += 1 + women_pref[w] = prefs + continue + + if cur == n - 2: + print(f">>>{w}") + # W1 Wcur + print(f"appending {men[0]}") + prefs.append(men[0]) + print(f"appending {men[n-1]}") + prefs.append(men[n-1]) + + print(">>>>>>>") + print(prefs) + print(">>>>>>>") + + k = 0 + + while k < n: + if k == n-1: + k += 1 + continue + if k == 0: + k += 1 + continue + prefs.append(men[k]) + k += 1 + + women_pref[w] = prefs + print(">>>>>>>") + print(women_pref[w]) + print("<<<<<<<") + continue + + prefs.append(men[cur+1]) + prefs.append(men[cur]) + + # we need n - k more men + k = 0 + + while k < n: + if k == cur: + k += 1 + continue + if k == cur + 1: + k += 1 + continue + prefs.append(men[k]) + k += 1 + + women_pref[w] = prefs + +print(women_pref) +print(men_pref) -- cgit v1.2.3-70-g09d2