-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.py
More file actions
53 lines (42 loc) · 2.02 KB
/
Test.py
File metadata and controls
53 lines (42 loc) · 2.02 KB
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
ListS = ["-->"]
ListIndexes = [100]
ListSize = 0
def StoreOnList(valueToStore, Pointer):
ListSize = len(ListS)
for x in range(ListSize):
if ListSize > 1 and (x + 1) < ListSize and Pointer > ListIndexes[x] and Pointer < ListIndexes[x + 1]:
# adds new value on middle of positions that arent bigger or smaller than the value itself
print(f"between: {ListIndexes[x]} and {ListIndexes[x + 1]}")
ListIndexes.insert((x + 1), Pointer)
ListS.insert((x + 1), valueToStore)
break
elif Pointer == ListIndexes[x]:
# if the value to store equals any already on the list then it's going to be saved behind it
print("equals to")
ListIndexes.insert(x, Pointer)
ListS.insert(x, valueToStore)
break
elif Pointer < ListIndexes[x] and (x + 1) == ListSize:
# if the new value is smaller than all others stored, then it's going to be saved at the beggining of the list
print("its less than")
ListIndexes.insert((x + 1), Pointer)
ListS.insert((x + 1), valueToStore)
elif Pointer > ListIndexes[x] and (x + 1) == ListSize:
# if the new value is greater than the ones already stored, then it's going to be stored at the end of the list
print("its more than")
ListIndexes.insert((x + 1), Pointer)
ListS.insert((x + 1), valueToStore)
print("\n\n\n")
StoreOnList("hi", 199)
print(f"Elements Stored on List: {ListS}, Indexes: {ListIndexes}")
StoreOnList("hey", 105)
print(f"Elements Stored on List: {ListS}, Indexes: {ListIndexes}")
StoreOnList("hiya", 133)
print(f"Elements Stored on List: {ListS}, Indexes: {ListIndexes}")
StoreOnList("hello", 150)
print(f"Elements Stored on List: {ListS}, Indexes: {ListIndexes}")
StoreOnList("another one", 101)
print(f"Elements Stored on List: {ListS}, Indexes: {ListIndexes}")
StoreOnList("Finals", 170)
print(f"Elements Stored on List: {ListS}, Indexes: {ListIndexes}")
print("\n\n\n")