-
Notifications
You must be signed in to change notification settings - Fork 0
/
duties.py
141 lines (119 loc) · 5.11 KB
/
duties.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
## MIT License
## Copyright 2021 Krasen Kolev
#
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
## The above copyright notice and this permission notice shall be included in all
## copies or substantial portions of the Software.
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
#!/usr/bin/env python3
import random
from os import system
rules = """## ##
## RULES: ##
## Highest number is doing 1st thing ##
## Middle number is doing 2nd thing ##
## lowest number is doing 3rd thing ##
## positions are evaluated from left to right ##
## ##"""
system('clear')
print(50 * '#')
print(rules)
print(50 * '#')
user1 = input('Please provide position for user 1: \n')
user2 = input('Please provide position for user 2: \n')
user3 = input('Please provide position for user 3: \n')
UsersPositions = {}
rand_lst = []
def verifyInput():
if int(user1) not in range(1, 4):
print('\nincorrect position has been provided for user 1. Please run the script again! \n')
exit()
elif int(user2) not in range(1, 4):
print('\nincorrect position has been provided for user 2. Please run the script again! \n')
exit()
elif int(user3) not in range(1, 4):
print('\nincorrect position has been provided for user 3. Please run the script again! \n')
exit()
def user1Position():
if user1 == '1':
UsersPositions['1'] = 'user 1'
elif user1 == '2':
UsersPositions['2'] = 'user 1'
elif user1 == '3':
UsersPositions['3'] = 'user 1'
def user2Position():
if user2 == '1':
UsersPositions['1'] = 'user 2'
elif user2 == '2':
UsersPositions['2'] = 'user 2'
elif user2 == '3':
UsersPositions['3'] = 'user 2'
def user3Position():
if user3 == '1':
UsersPositions['1'] = 'user 3'
elif user3 == '2':
UsersPositions['2'] = 'user 3'
elif user3 == '3':
UsersPositions['3'] = 'user 3'
def rand_nums():
rand_lst.append(random.randint(1, 9))
rand_lst.append(random.randint(1, 9))
rand_lst.append(random.randint(1, 9))
def rand_nums_check():
while rand_lst[0] == rand_lst[1] or rand_lst[0] == rand_lst[2] or rand_lst[1] == rand_lst[2]:
rand_lst.clear()
rand_nums()
def SR():
if rand_lst[0] > rand_lst[1] and rand_lst[0] > rand_lst[2]:
print(50 * '=', '\n')
print('{user} will be doing 1st thing \n'.format(user = UsersPositions['1']))
elif rand_lst[1] > rand_lst[0] and rand_lst[1] > rand_lst[2]:
print(50 * '=', '\n')
print('{} will be doing 1st thing \n'.format(UsersPositions['2']))
elif rand_lst[2] > rand_lst[0] and rand_lst[2] > rand_lst[1]:
print(50 * '=', '\n')
print('{} will be doing 1st thing \n'.format(UsersPositions['3']))
def HO():
if rand_lst[0] < rand_lst[1] and rand_lst[0] < rand_lst[2]:
print('{user} will be doing 2nd thing \n'.format(user = UsersPositions['1']))
elif rand_lst[1] < rand_lst[0] and rand_lst[1] < rand_lst[2]:
print('{} will be doing 2nd thing \n'.format(UsersPositions['2']))
elif rand_lst[2] < rand_lst[0] and rand_lst[2] < rand_lst[1]:
print('{} will be doing 2nd thing \n'.format(UsersPositions['3']))
def eks():
if rand_lst[0] < rand_lst[1] and rand_lst[0] > rand_lst[2]:
print('{user} will be doing 3rd thing \n'.format(user = UsersPositions['1']))
elif rand_lst[1] < rand_lst[0] and rand_lst[1] > rand_lst[2]:
print('{} will be doing 3rd thing \n'.format(UsersPositions['2']))
elif rand_lst[2] < rand_lst[0] and rand_lst[2] > rand_lst[1]:
print('{} will be doing 3rd thing \n'.format(UsersPositions['3']))
if rand_lst[0] > rand_lst[1] and rand_lst[0] < rand_lst[2]:
print('{user} will be doing 3rd thing \n'.format(user = UsersPositions['1']))
elif rand_lst[1] > rand_lst[0] and rand_lst[1] < rand_lst[2]:
print('{} will be doing 3rd thing \n'.format(UsersPositions['2']))
elif rand_lst[2] > rand_lst[0] and rand_lst[2] < rand_lst[1]:
print('{} will be doing 3rd thing \n'.format(UsersPositions['3']))
def main():
verifyInput()
user1Position()
user2Position()
user3Position()
rand_nums()
rand_nums_check()
SR()
HO()
eks()
if __name__ == '__main__':
main()
print('\nRandomly generated numbers were: ', rand_lst, '\n')