示例#1
0
def init_panel():
    global panel_width, panel_height, bombs, martrix, mask
    martrix = [[0 for x in range(panel_width)][:] for y in range(panel_height)]
    mask = [['-' for x in range(panel_width)][:] for y in range(panel_height)]
    for i in zip(*(s(range(bombs),panel_width - 1),s(range(bombs),panel_height - 1))):
        martrix[i[0]][i[1]] = 'x'
    for r in range(len(martrix)):
        row = martrix[r]
        for c in range(len(row)):
            col = martrix[r][c]
            if col == 'x':
                for pt in pt_relations:
                    y = r + pt[0]
                    x = c + pt[1]
                    if area_check(x, y) and martrix[y][x] != 'x':
                        martrix[y][x] += 1
    draw(mask)
        np.array([15, 255, 255]), MIN_REC, 'Лежачий полицейский'
    ],
    'stopSign.png': [
        np.array([0, 110, 0]),
        np.array([15, 255, 255]), MIN_REC, 'Знак остановки'
    ],
}

while True:
    ret, frame = cap.read()
    hsv = cv.cvtColor(frame, cv.COLOR_BGR2HSV)

    hsv = cv.blur(hsv, (5, 5))
    list_IMAGE = list(images.keys())
    correct = []
    s(list_IMAGE)
    for name in list_IMAGE:
        lower, upper, stop, text = images[name]
        flag = percentage(name, lower, upper, stop, text)
        if flag:
            correct.append(name)
    if correct:
        cv.putText(frame, correct[-1], (20, 20), cv.FONT_HERSHEY_SIMPLEX, 1,
                   (0, 255, 255), 2)
    out.write(frame)

    if cv.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv.destroyAllWindows()
示例#3
0
from stinger import *
from os import system
from time import clock
from heapq import heappush, heappop
from random import randint as r, seed as s, random as P, sample

s(0xcafebabe)

rSeeds = (3, 20)
rTypes = (5, 100)
rValues = (100, 1000)
rBranchesMin = (1, 3)
rBranchesMax = (4, 5)
rDepth = (2, 8)
rExtraAncestors = (2, 15)
rJoinsPerTree = (10, 200)
pMoreAncestors = 0.09
rCycles = (128, 512)
pCloseCycle = 0.04
pJumpInCycle = 0.02

nSeeds = r(*rSeeds)
nTypes = r(*rTypes)
nValues = r(*rValues)
nBranches = [(r(*rBranchesMin), r(*rBranchesMax))
             for x in xrange(0, nTypes + 1)]
nJoins = r(*rJoinsPerTree) * nSeeds

graph = []
seeds = []
vID = 0
示例#4
0
 def shuffle(self):  # Method to put cards list in random order
     shuffled_deck = s(self.cards)
     self._is_sorted = False
     return shuffled_deck
from random import sample as s

v = list(map(int, input().split()))
l = len(v)
n = []
m = []
while (l != 0):
    temp = 0
    while (temp < 500):
        take = s(v, l)
        rem = v.copy()
        for i in take:
            rem.remove(i)
        a = sum(take)
        b = sum(rem)
        diff = abs(a - b)
        if (diff < 5):
            n.append(diff)
            m.append([max(a, b), min(a, b)])
        temp += 1
    l -= 1
new = n.index(min(n))
print(m[new][0])
示例#6
0
 def shuffle(self):
     s(self.list)
def binary_search(seq, item):
    """ This seaches an item in sequence of sorted list
    """
    left = 0
    right = len(seq) - 1

    while left <= right:
        mid = left + (left + right) // 2
        #       Because we need integer not a decimal
        mid_val = seq[mid]
        if mid_val == item:
            return mid
        elif item < mid_val:
            right = mid - 1
        else:
            left = mid + 1
    return None


""" problem with this algorithm is that the item number can be bigger than
len(sequence) otherwise it will throw an index out of range error as seen below """

sequence = (s(range(1, 100), 10))
print(sequence)
#item = r(1,100)
item = 99
print(item)

print(binary_search(sequence, item))
示例#8
0
 def shuffle(self) -> List[int]:
     """
     Returns a random shuffling of the array.
     """
     s(self.arr)
     return self.arr
示例#9
0
文件: hideme.py 项目: elmoiv/hideme
def su(cmd):
    """
    Execute Super User commands (without logging)
    """
    _ = popen(f'su -c "{cmd}"').read()
    
# Turn Off Wifi
print('\nTurning WiFi OFF...')
su('svc wifi disable')

# Change MAC Address
new_mac = "%x%x:%02x:%02x:%02x:%02x:%02x" \
        % (R(15), c(range(0, 16, 2)), R(), R(), R(), R(), R())

## Write new mac to the Xiaomi specific file
su(f'printf \\"{new_mac}\n\\" > {MAC_FILE}')

# Change Host Name
s(ALL)
new_host = ''.join(ALL[:r(10, 18)])
su(f'setprop net.hostname "{new_host}"')

# Result
print('\nNew Mac Address:', new_mac)
print('New Host Name:  ', new_host, '\n')

# Turn On WiFi
print('Turning WiFi ON...')
su('svc wifi enable')

print('\nDone')
N = input()
A = map(int, raw_input().split())

V = [i + 1 for i in xrange(N) if A[i] == 0]
f = [1] * (N + 1)
for i in A:
    f[i] = 0
F = [i for i in range(1, N + 1) if f[i]]

n = len(F)

from random import shuffle as s
while 1:
    s(F)
    t = [i for i in xrange(n) if F[i] == V[i]]
    if not t:
        break

for i in xrange(n):
    A[V[i] - 1] = F[i]
for i in A:
    print i,
示例#11
0
 def shuffle(self):
     if Deck.count(self) == 52:
         s(self.cards)
     else:
         raise ValueError("Only full decks can be shuffled")
     return self.cards
示例#12
0
from stinger import *
from os import system
from time import clock
from heapq import heappush, heappop
from random import randint as r, seed as s, random as P, sample

s(0xcafebabe)

rSeeds = (3,20)
rTypes = (5,100)
rValues = (100,1000)
rBranchesMin = (1,3)
rBranchesMax = (4,5)
rDepth = (2,8)
rExtraAncestors = (2,15)
rJoinsPerTree = (10,200)
pMoreAncestors = 0.09
rCycles = (128,512)
pCloseCycle = 0.04
pJumpInCycle = 0.02

nSeeds = r(*rSeeds)
nTypes = r(*rTypes)
nValues = r(*rValues)
nBranches = [(r(*rBranchesMin), r(*rBranchesMax)) for x in xrange(0,nTypes+1)]
nJoins = r(*rJoinsPerTree) * nSeeds

graph = []
seeds = []
vID = 0
eID = 0
# import random

# import random as r
# print(r.randint(0, 10))

# list1 = ["apple", "orange", "banana", "grapes"]
# r.shuffle(list1)
# print(r.choice(list1))

# from random import *

# from random import shuffle, choice, randint
# print(randint(0, 10))

# list1 = ["apple", "orange", "banana", "grapes"]
# shuffle(list1)
# print(choice(list1))

from random import choice as c, randint as r, shuffle as s
print(r(0, 10))

list1 = ["apple", "orange", "banana", "grapes"]
s(list1)
print(c(list1))
示例#14
0
def test_s_name_collision():
    S = SnakeSpace()
    from random import randint as s
    assert (S.a.s(s(0,0)) == "a.0")
示例#15
0
        i += 1
    else:
        print("""
            Number have to between 1 and 49.
            Numbers must not be repeated.
            """)

# sort selected numbers from lowest and show them
selected_numbers.sort()
print(selected_numbers)

# select six numbers between 1 and 49

# create a list of numbers between 1 and 49
all_numbers = [i for i in range(1, 49)]
# shuffle numbers
s(all_numbers)
# choice of the first six numbers
drawn_numbers = all_numbers[0:6]
# sort and display the drawn numbers
drawn_numbers.sort()
print(drawn_numbers)

# create a list of hit numbers
hit_numbers = [i for i in drawn_numbers if i in selected_numbers]

# show number of hits
print(f"""
            You hit {len(hit_numbers)} numbers !
""")
示例#16
0
    f'    {a} |  {b}  |  {c}\n'
    f'  ____|_____|____  \n'
    f'      |     |      \n'
    f'    {d} |  {e}  |  {f}\n'
    f'  ____|_____|____  \n'
    f'      |     |      \n'
    f'    {g} |  {h}  |  {i}\n'
    f'      |     |      \n' 
    )

    print(casas_livres)
    print(tabela2)
    print("agora a vez da maquina")

    while True:
        jogada_maquina = s(casas_livres)
        if jogada_maquina in letras:
            if jogada_maquina not in casas_cheias:
                break

    if jogada_maquina == "a":
        casas_livres[0] = "1"
        casas_cheias.insert(0,"a")
        a = escolha_maquina
    elif jogada_maquina == "b":
        casas_livres[1] = "2"
        casas_cheias.insert(1,"b")
        b = escolha_maquina
    elif jogada_maquina == "c":
        casas_livres[2] = "3"
        casas_cheias.insert(2,"c")