• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Apr 18th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1.
2. import sys
3. from collections import namedtuple
4.
5.
6. DA='DA'
7. NU='NU'
8.
9. Stare=namedtuple('stare',['camera','lumini', 'cutii','pe_cutie'])
10.
11. si=Stare(2,[NU, DA, NU],[None, DA, NU],NU)
12. sf=Stare(None,[DA, DA, DA],[DA, DA, DA],DA)
13. #sf=Stare(None,[DA, DA, DA],[DA, DA, DA],None)   #stare modificata
14.
15. #print(si)
16. #print(sf)
17. #print(sf.pe_cutie)
18.
19. def op_deplasare(stare):
20.     if stare.pe_cutie==DA:
21.         return []
22.     camere=[1,2,3]
23.     if stare.camera != None:
24.         del camere[stare.camera-1]
25.
26.
27.     stari_pred=[]
28.     for c in camere:
29.         stare_pred = Stare(c, stare.lumini[:], stare.cutii[:], NU)
30.         stari_pred.append((stare_pred, f'deplasare din {c} in {stare.camera} '))
31.
32.
33.     return stari_pred
34.
35.
36. # sol=op_deplasare(sf)
37. # for s in sol:
38.     # print(s)
39.
40.
41. def op_lumini(stare):
42.
43.     if stare.pe_cutie == DA:
44.         return []
45.
46.     camere=[1,2,3]
47.     if stare.lumini != DA:
48.             camere=[1,2,3]
49.             for c in camere:
50.                 if c == 1 :
51.                     stare.lumini=
52.                 stare_pred = Stare(c, , stare.cutii[:], DA)
53.                 stari_pred.append((stare_pred, f'aprindere bec in camera {c} '))
54.
55.         return []
56.
57.     stari.lumini=[]
58.
59. def op_mtarecutie(stare):
60.     if stare.pe_cutie == DA:
61.         return []
62.
63.     camere=[1,2,3]
64.     if stare.camera != None:
65.         camere=[stare.camera]
66.     stari_pred=[]
67.     for c in camere:
68.         if stare.cutii[c-1] ==NU:
69.             continue
70.         #cutie langa intrerupator/ none
71.         cutii = stare.cutii[:]
72.         cutii[c-1] = NU
73.         #pe_cutie nu
74.
75.         stare_pred = Stare(c, stare.lumini[:], cutii, NU)
76.         stari_pred.append((stare_pred, f'Mutare cutie in {c} '))
77.     return stari_pred
78. sol=op_mtarecutie(sf)
79. for s in sol:
80.     print(s)
81. #print ("intra", camere)    #print("intra", stare)
82. #print(op_deplasare(sf))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top