예제 #1
0
"""
Author: Jose L Balcazar, ORCID 0000-0003-4248-4528
Copyleft: MIT License (https://en.wikipedia.org/wiki/MIT_License)

Usage of Popeel: example (jul 2017).
"""

from popeel import Popeel

Popeel.set_task(8)  # set the task: please peel 8 potatoes

Popeel.peel_1_potato()  # main operation, peels one potato from the basket

Popeel.refill_basket(
)  # go to the main store and fetch some potatoes with the basket

Popeel.discard_basket()  # returns potatoes from the basket to the main store

Popeel.enough_potatoes()  # Boolean: task achieved?

Popeel.is_basket_empty()  # Boolean: is Popeel's basket out of potatoes?

Popeel.go_sleep()  # Popeel is asleep from that point on
예제 #2
0
from popeel import Popeel
popeeler = Popeel()
popeeler.refill_basket()
예제 #3
0
from popeel import Popeel
popeeler = Popeel()
popeeler.discard_basket()
popeeler.go_sleep()
예제 #4
0
from popeel import Popeel
popeeler = Popeel()
while not popeeler.is_basket_empty():
    popeeler.peel_1_potato()
예제 #5
0
from popeel import Popeel
popeeler = Popeel()
while popeeler.enough_potatoes():
    if popeeler.enough_potatoes():
        while not not popeeler.enough_potatoes():
            while not popeeler.enough_potatoes() or popeeler.enough_potatoes():
                popeeler.peel_1_potato()
        while popeeler.enough_potatoes():
            popeeler.refill_basket()
예제 #6
0
"""
Author: Jose L Balcazar, ORCID 0000-0003-4248-4528 (feb 2017)
Copyleft: MIT License (https://en.wikipedia.org/wiki/MIT_License)

Usage of Popeel with a variable: simple problem of peeling all potatoes in the basket.
"""

from popeel import Popeel

p = Popeel()  # will tell us how many potatoes are in the basket initially

while not p.is_basket_empty():
    p.peel_1_potato()

p.go_sleep()
예제 #7
0
"""
Author: Jose L Balcazar, ORCID 0000-0003-4248-4528 (feb 2017)
Copyleft: MIT License (https://en.wikipedia.org/wiki/MIT_License)

Ignore this file if you want to contribute to Suverat.

One correct usage of Popeel.

Spoiler. 

Don't read this code.

Hidden in a different project (Suverat) and in some Dropbox so as to
avoid its visibility from the standard Popeel users.
"""

from popeel import Popeel

p = Popeel()
p.set_task(12)
while not p.enough_potatoes():
    if p.basket_is_empty():
        p.refill_basket()
    p.peel_1_potato()
p.discard_basket()
p.go_sleep()
예제 #8
0
"""
Author: Jose L Balcazar, ORCID 0000-0003-4248-4528 
Copyleft: MIT License (https://en.wikipedia.org/wiki/MIT_License)

Usage of Popeel with a variable: example (feb, oct 2017).
"""

from popeel import Popeel

p = Popeel() # will tell us how many potatoes are in the basket initially

p.set_task(8) # set the task: please peel 8 potatoes

p.peel_1_potato() # main operation, peels one potato from the basket

print(p.enough_potatoes()) # Boolean: task achieved?

print(p.is_basket_empty()) # Boolean: is Popeel's basket out of potatoes?

print(not p.is_basket_empty()) # Boolean: does Popeel still have potatoes in the basket?

p.refill_basket() # go to the main store and fetch some potatoes with the basket

p.discard_basket() # returns potatoes from the basket to the main store

p.go_sleep() # Popeel is asleep from that point on

예제 #9
0
"""
Author: Jose L Balcazar, ORCID 0000-0003-4248-4528
Copyleft: MIT License (https://en.wikipedia.org/wiki/MIT_License)

Usage of Popeel with one variable: very simple (wrong) example (feb, oct 2017).
"""

from popeel import Popeel

p = Popeel()

p.peel_1_potato()

p.go_sleep()
예제 #10
0
"""
Author: Jose L Balcazar, ORCID 0000-0003-4248-4528 (feb 2017)
Copyleft: MIT License (https://en.wikipedia.org/wiki/MIT_License)

Usage of Popeel with no instances: very simple (and wrong) example (jul 2017).
"""

from popeel import Popeel

Popeel.peel_1_potato()

Popeel.go_sleep()

예제 #11
0
from popeel import Popeel
popeeler = Popeel()
while popeeler.is_basket_empty():
    if popeeler.is_basket_empty():
        popeeler.discard_basket()
예제 #12
0
"""
Author: Jose L Balcazar, ORCID 0000-0003-4248-4528 (feb 2017)
Copyleft: MIT License (https://en.wikipedia.org/wiki/MIT_License)

Usage of Popeel: simple problem of peeling two basketfulls of potatoes.
"""

from popeel import Popeel

while not Popeel.is_basket_empty():
    Popeel.peel_1_potato()

Popeel.refill_basket()

while not Popeel.is_basket_empty():
    Popeel.peel_1_potato()

Popeel.go_sleep()
예제 #13
0
from popeel import Popeel
popeeler = Popeel()
popeeler.discard_basket()
예제 #14
0
from popeel import Popeel

popeeler = Popeel()
popeeler.peel_1_potato()
예제 #15
0
from popeel import Popeel

popeeler = Popeel()
if popeeler.enough_potatoes():
    popeeler.refill_basket()
else:
    while popeeler.enough_potatoes() or popeeler.is_basket_empty(
    ) and popeeler.enough_potatoes() and not popeeler.enough_potatoes():
        popeeler.refill_basket()
    if popeeler.basket_is_empty():
        while popeeler.enough_potatoes():
            popeeler.peel_1_potato()
            popeeler.refill_basket()
            popeeler.go_sleep()
        popeeler.peel_1_potato()
예제 #16
0
from popeel import Popeel
popeeler = Popeel()
while popeeler.is_basket_empty():
    if not popeeler.is_basket_empty():
        popeeler.discard_basket()
    else:
        popeeler.refill_basket()