Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.464469093122299","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"IyBhIGxpc3Qgb2YgbnVtYmVycyB0byBzZWFyY2ggdGhyb3VnaDoKbnVtYmVyX2xpc3QgPSBbMV0KIyB0aGUgbnVtYmVyIHdlIHdhbnQgdG8gc2VhcmNoIGZvcjoKdGFyZ2V0X251bWJlciA9IDEKIyB0aGUgImluZGV4IiAocG9zaXRpb24gbnVtYmVyKSBvZiB0aGUgZmlyc3QgZWxlbWVudCBpbiB0aGUgbGlzdAojIGNvdW50aW5nIHN0YXJ0cyBhdCB6ZXJvIGluc3RlYWQgb2YgMToKc3RhcnQgPSAwCiMgdGhlIGluZGV4IG9mIHRoZSBsYXN0IGVsZW1lbnQgaW4gdGhlIGxpc3Q6CmVuZCA9IGxlbihudW1iZXJfbGlzdCkgLSAxCiMgYSB3YXkgb2YgdHJhY2tpbmcgaWYgd2UgZm91bmQgdGhlIG51bWJlciBvciBub3Q6CmZvdW5kX251bWJlciA9IEZhbHNlCgpwcmludCgnaGloJykKCiMgImJpbmFyeSBzZWFyY2giIG9mIHRoZSBsaXN0IGZvciB0aGUgbnVtYmVyOgp3aGlsZSBzdGFydCA8PSBlbmQ6CiAgICBtaWQgPSBpbnQoKHN0YXJ0ICsgZW5kKSAvIDIpCiAgICBwcmludChtaWQpCiAgICBpZiB0YXJnZXRfbnVtYmVyIDwgbnVtYmVyX2xpc3RbbWlkXToKICAgICAgICBlbmQgPSBtaWQgLTEKICAgIGVsaWYgdGFyZ2V0X251bWJlciA+IG51bWJlcl9saXN0W21pZF06CiAgICAgICAgc3RhcnQgPSBtaWQgKyAxCiAgICBlbHNlOgogICAgICAgIGZvdW5kX251bWJlciA9IFRydWUKICAgICAgICBicmVhawoKIyBwcmludCB0byB0aGUgc2hlbGwgd2hldGhlciB3ZSBmb3VuZCB0aGUgbnVtYmVyCmlmIGZvdW5kX251bWJlciA9PSBUcnVlOgogICAgcHJpbnQoIkZvdW5kIHRoZSBudW1iZXIhIikKZWxzZToKICAgIHByaW50KCJOdW1iZXIgbm90IGZvdW5kLiIp"},"asBuffer":null},"loaded":true}}
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
# a list of numbers to search through:
number_list = [1]
# the number we want to search for:
target_number = 1
# the "index" (position number) of the first element in the list
# counting starts at zero instead of 1:
start = 0
# the index of the last element in the list:
end = len(number_list) - 1
# a way of tracking if we found the number or not:
found_number = False

print('hih')

# "binary search" of the list for the number:
while start <= end:
    mid = int((start + end) / 2)
    print(mid)
    if target_number < number_list[mid]:
        end = mid -1
    elif target_number > number_list[mid]:
        start = mid + 1
    else:
        found_number = True
        break

# print to the shell whether we found the number
if found_number == True:
    print("Found the number!")
else:
    print("Number not found.")