Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from collections import namedtuple
- DA='DA'
- NU='NU'
- Stare=namedtuple('stare',['camera','lumini', 'cutii','pe_cutie'])
- si=Stare(2,[NU, DA, NU],[None, DA, NU],NU)
- sf=Stare(None,[DA, DA, DA],[DA, DA, DA],DA)
- #sf=Stare(None,[DA, DA, DA],[DA, DA, DA],None) #stare modificata
- #print(si)
- #print(sf)
- #print(sf.pe_cutie)
- def op_deplasare(stare):
- if stare.pe_cutie==DA:
- return []
- camere=[1,2,3]
- if stare.camera != None:
- del camere[stare.camera-1]
- stari_pred=[]
- for c in camere:
- stare_pred = Stare(c, stare.lumini[:], stare.cutii[:], NU)
- stari_pred.append((stare_pred, f'deplasare din {c} in {stare.camera} '))
- return stari_pred
- # sol=op_deplasare(sf)
- # for s in sol:
- # print(s)
- def op_lumini(stare):
- if stare.pe_cutie == DA:
- return []
- camere=[1,2,3]
- if stare.lumini != DA:
- camere=[1,2,3]
- for c in camere:
- if c == 1 :
- stare.lumini=
- stare_pred = Stare(c, , stare.cutii[:], DA)
- stari_pred.append((stare_pred, f'aprindere bec in camera {c} '))
- return []
- stari.lumini=[]
- def op_mtarecutie(stare):
- if stare.pe_cutie == DA:
- return []
- camere=[1,2,3]
- if stare.camera != None:
- camere=[stare.camera]
- stari_pred=[]
- for c in camere:
- if stare.cutii[c-1] ==NU:
- continue
- #cutie langa intrerupator/ none
- cutii = stare.cutii[:]
- cutii[c-1] = NU
- #pe_cutie nu
- stare_pred = Stare(c, stare.lumini[:], cutii, NU)
- stari_pred.append((stare_pred, f'Mutare cutie in {c} '))
- return stari_pred
- sol=op_mtarecutie(sf)
- for s in sol:
- print(s)
- #print ("intra", camere) #print("intra", stare)
- #print(op_deplasare(sf))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement