|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +class Ctnr: |
| 3 | + def __init__(self):self.dict = dict();self.length = 0;self.it = -1; |
| 4 | + def push(self,*args): |
| 5 | + for arg in args: |
| 6 | + self.dict[str(self.length)]=arg; self.length+=1 |
| 7 | + def __getitem__(self,i): |
| 8 | + try: return self.dict[str(i)] |
| 9 | + except: return None |
| 10 | + def __setitem__(self,i,x): |
| 11 | + self.dict[str(i)]=x |
| 12 | + inti = None |
| 13 | + try: |
| 14 | + inti = int(i) |
| 15 | + if (abs(inti - float(i))>0.0001): inti=None |
| 16 | + except: pass |
| 17 | + if (inti != None): |
| 18 | + self.length=inti+1 |
| 19 | + for j in range(0,self.length): |
| 20 | + try: self.dict[str(j)] |
| 21 | + except: self.dict[str(j)]=None |
| 22 | + def slice(self,i): |
| 23 | + ret = Ctnr(); |
| 24 | + for i in range(i,self.length): ret.push(self[i]) |
| 25 | + return ret |
| 26 | + def concat(self,other): |
| 27 | + ret = Ctnr(); |
| 28 | + for i in range(0,self.length): ret.push(self[i]) |
| 29 | + for i in range(0,other.length): ret.push(other[i]) |
| 30 | + return ret |
| 31 | + def __str__(self): |
| 32 | + if (len(self.dict.keys())==self.length): |
| 33 | + ret = "[" |
| 34 | + for k in range(0,self.length): |
| 35 | + v = self[k] |
| 36 | + if (isinstance(v,Ctnr)): ret += v.__str__() |
| 37 | + else: ret += str(v) |
| 38 | + ret+="," |
| 39 | + ret += "]" |
| 40 | + return ret; |
| 41 | + else: |
| 42 | + ret = "{" |
| 43 | + for k in self.dict.keys(): |
| 44 | + ret += str(k)+":" |
| 45 | + v = self.dict[k] |
| 46 | + if (isinstance(v,Ctnr)): ret += v.__str__() |
| 47 | + else: ret += str(v) |
| 48 | + ret+="," |
| 49 | + ret += "}" |
| 50 | + return ret; |
| 51 | + def __repr__(self): |
| 52 | + return self.__str__() |
| 53 | + def __iter__(self): |
| 54 | + self.it = -1; |
| 55 | + return self |
| 56 | + def __next__(self): |
| 57 | + self.it += 1 |
| 58 | + if (self.it >= self.length): raise StopIteration() |
| 59 | + return self[self.it] |
| 60 | +globals()['Ctnr']=Ctnr; |
| 61 | +class JSON: |
| 62 | + @staticmethod |
| 63 | + def stringify(x): |
| 64 | + return x; |
| 65 | +##### |
| 66 | +圖靈機=lambda _:0 |
| 67 | +def 圖靈機 (諸律): |
| 68 | + def _rand1(始態): |
| 69 | + def _rand2(終態): |
| 70 | + nonlocal 諸律; |
| 71 | + nonlocal 始態; |
| 72 | + global 圖靈機; |
| 73 | + 帶=Ctnr() |
| 74 | + 帶.push("白") |
| 75 | + 針=1 |
| 76 | + 左疆=1 |
| 77 | + 右疆=1 |
| 78 | + 態=始態 |
| 79 | + 圖靈機畫法=lambda _:0 |
| 80 | + def 圖靈機畫法(): |
| 81 | + global 圖靈機; |
| 82 | + nonlocal 帶; |
| 83 | + nonlocal 針; |
| 84 | + nonlocal 左疆; |
| 85 | + nonlocal 右疆; |
| 86 | + nonlocal 態; |
| 87 | + nonlocal 圖靈機畫法; |
| 88 | + 畫帶="" |
| 89 | + 筆=左疆 |
| 90 | + while (True): |
| 91 | + |
| 92 | + if 筆>右疆: |
| 93 | + break |
| 94 | + |
| 95 | + _ans1=帶[筆-1]; |
| 96 | + |
| 97 | + 符=_ans1; |
| 98 | + |
| 99 | + if 針==筆: |
| 100 | + _ans2="〔"+符; |
| 101 | + _ans3=_ans2+"〕"; |
| 102 | + |
| 103 | + 符=_ans3; |
| 104 | + |
| 105 | + else: |
| 106 | + _ans4="、"+符; |
| 107 | + _ans5=_ans4+"、"; |
| 108 | + |
| 109 | + 符=_ans5; |
| 110 | + |
| 111 | + _ans6=畫帶+符; |
| 112 | + |
| 113 | + 畫帶=_ans6; |
| 114 | + _ans7=1+筆; |
| 115 | + |
| 116 | + 筆=_ans7; |
| 117 | + |
| 118 | + _ans8=態 |
| 119 | + _ans9="《" |
| 120 | + _ans10=畫帶 |
| 121 | + _ans11="》" |
| 122 | + print(_ans8,_ans9,_ans10,_ans11); |
| 123 | + |
| 124 | + _ans12=圖靈機畫法(); |
| 125 | + while (True): |
| 126 | + for 律 in 諸律: |
| 127 | + _ans13=律[1-1]; |
| 128 | + |
| 129 | + 甲態=_ans13; |
| 130 | + _ans14=律[2-1]; |
| 131 | + |
| 132 | + 讀符=_ans14; |
| 133 | + _ans15=律[3-1]; |
| 134 | + |
| 135 | + 乙態=_ans15; |
| 136 | + _ans16=律[4-1]; |
| 137 | + |
| 138 | + 畫符=_ans16; |
| 139 | + _ans17=律[5-1]; |
| 140 | + |
| 141 | + 移=_ans17; |
| 142 | + |
| 143 | + if 態==甲態: |
| 144 | + |
| 145 | + if 帶[針-1]==讀符: |
| 146 | + |
| 147 | + 帶[針-1]=畫符; |
| 148 | + |
| 149 | + 態=乙態; |
| 150 | + |
| 151 | + if 移=="左": |
| 152 | + _ans18=針-1; |
| 153 | + |
| 154 | + 針=_ans18; |
| 155 | + |
| 156 | + |
| 157 | + if 移=="右": |
| 158 | + _ans19=針+1; |
| 159 | + |
| 160 | + 針=_ans19; |
| 161 | + |
| 162 | + break |
| 163 | + |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | + if 針<左疆: |
| 168 | + |
| 169 | + 帶[針-1]="白"; |
| 170 | + |
| 171 | + 左疆=針; |
| 172 | + |
| 173 | + |
| 174 | + if 針>右疆: |
| 175 | + |
| 176 | + 帶[針-1]="白"; |
| 177 | + |
| 178 | + 右疆=針; |
| 179 | + |
| 180 | + _ans20=圖靈機畫法(); |
| 181 | + |
| 182 | + if 態==終態: |
| 183 | + break |
| 184 | + |
| 185 | + |
| 186 | + return _rand2; |
| 187 | + return _rand1; |
| 188 | + |
| 189 | +製律=lambda _:0 |
| 190 | +def 製律 (諸律): |
| 191 | + def _rand3(甲態): |
| 192 | + def _rand4(讀符): |
| 193 | + def _rand5(乙態): |
| 194 | + def _rand6(畫符): |
| 195 | + def _rand7(移): |
| 196 | + nonlocal 諸律; |
| 197 | + nonlocal 甲態; |
| 198 | + nonlocal 讀符; |
| 199 | + nonlocal 乙態; |
| 200 | + nonlocal 畫符; |
| 201 | + global 圖靈機; |
| 202 | + global 製律; |
| 203 | + 律=Ctnr() |
| 204 | + 律.push(甲態,讀符,乙態,畫符,移) |
| 205 | + 諸律.push(律) |
| 206 | + return _rand7; |
| 207 | + return _rand6; |
| 208 | + return _rand5; |
| 209 | + return _rand4; |
| 210 | + return _rand3; |
| 211 | + |
| 212 | +_ans21="營營河狸。止于樊。" |
| 213 | +print(_ans21); |
| 214 | +諸律=Ctnr() |
| 215 | +陽符="墨" |
| 216 | +陰符="白" |
| 217 | +_ans22=製律(諸律)("甲")(陰符)("乙")(陽符)("右"); |
| 218 | +_ans23=製律(諸律)("甲")(陽符)("丙")(陽符)("左"); |
| 219 | +_ans24=製律(諸律)("乙")(陰符)("甲")(陽符)("左"); |
| 220 | +_ans25=製律(諸律)("乙")(陽符)("乙")(陽符)("右"); |
| 221 | +_ans26=製律(諸律)("丙")(陰符)("乙")(陽符)("左"); |
| 222 | +_ans27=製律(諸律)("丙")(陽符)("樊")(陽符)("中"); |
| 223 | +_ans28=圖靈機(諸律)("甲")("樊"); |
0 commit comments