@anonymous/

GregariousFilthyDogwoodclubgall

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9945729985937632","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"ZnJvbSBpdGVydG9vbHMgaW1wb3J0IGFjY3VtdWxhdGUKCiMgc3RvcG1pbiBjYWxjdWxhdGVzIHRoZSBncmVhdGVzdCBsb3dlciBib3VuZCAoaW5maW11bSkuIAojIGh0dHBzOi8vdXBsb2FkLndpa2ltZWRpYS5vcmcvd2lraXBlZGlhL2NvbW1vbnMvMC8wYS9JbmZpbXVtX2lsbHVzdHJhdGlvbi5zdmcgCgpkZWYgdGFrZXVudGlsKHByZWQsIHNlcSk6CiAgZm9yIGl0ZW0gaW4gc2VxOgogICAgeWllbGQgaXRlbQogICAgaWYgbm90IHByZWQoaXRlbSk6CiAgICAgIGJyZWFrCgpkZWYgc3RvcG1pbihzZXEsIHN0b3A9MCk6CiAgZHJvcF9sdHN0b3AgPSAoaXRlbSBmb3IgaXRlbSBpbiBzZXEgaWYgaXRlbSA+PSBzdG9wKQogIG1pbl9nZW4gPSAobWluXyBmb3IgbWluXyBpbiBhY2N1bXVsYXRlKGRyb3BfbHRzdG9wLCBmdW5jPW1pbikpCiAgcmV0dXJuIGxpc3QodGFrZXVudGlsKGxhbWJkYSB4OiB4IT0gc3RvcCwgbWluX2dlbikpWy0xXQoKc2VxID0gWzEsIDQsIDcsIC04LCAwLCA3LCAtOCwgOV0gIyAwIGp1c3QgdW50aWwgemVybyBpcyBnZW5lcmF0ZWQKc2VxID0gWzEsIDQsIDcsIC04LCA3LCAtOCwgOV0gIyAxIHRoZSBlbnRpcmUgc2VxdWVuY2UgaXMgZ2VuZXJhdGVkCgpwcmludChzdG9wbWluKHNlcSwgc3RvcD0wKSk="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from itertools import accumulate

# stopmin calculates the greatest lower bound (infimum). 
# https://upload.wikimedia.org/wikipedia/commons/0/0a/Infimum_illustration.svg 

def takeuntil(pred, seq):
  for item in seq:
    yield item
    if not pred(item):
      break

def stopmin(seq, stop=0):
  drop_ltstop = (item for item in seq if item >= stop)
  min_gen = (min_ for min_ in accumulate(drop_ltstop, func=min))
  return list(takeuntil(lambda x: x!= stop, min_gen))[-1]

seq = [1, 4, 7, -8, 0, 7, -8, 9] # 0 just until zero is generated
seq = [1, 4, 7, -8, 7, -8, 9] # 1 the entire sequence is generated

print(stopmin(seq, stop=0))