Versionsvergleich
Aus ProgrammingWiki
Vergleich: 2021-04-12T06:54:47+00:00 → 2021-04-12T06:55:22+00:00
<language>Python</language> | |
== Folie 9 == | |
'''Beispiel 1''' | |
<code id="606ef64b45bca"> | |
def chi_M(w): | |
return len(w) == 3 | |
</code> | |
<run id="606ef64b45ca4"> | |
print(chi_M("aaa")) | |
print(chi_M("ab")) | |
print(chi_M("aba")) | |
</run> | |
'''Beispiel 2''' | |
<code id="606ef64b45c38"> | |
def chi_M(w): | |
return w.startswith("a") | |
</code> | |
<run id="606ef64b45d03"> | |
print(chi_M("aaa")) | |
print(chi_M("babababaaab")) | |
print(chi_M("")) | |
</run> | |
== Folie 10 == | |
== Folie 15 == | |
'''ÜA 1''' | |
$G \subset \mathbb{N}$ | |
{| class="wikitable" | |
|Ordnungszahl | |
|0 | |
|1 | |
|2 | |
|3 | |
|4 | |
|5 | |
|6 | |
|... | |
|- | |
|$G$ | |
|0 | |
|2 | |
|4 | |
|6 | |
|8 | |
|10 | |
|12 | |
|... | |
|} | |
'''ÜA 2''' | |
$P \subset \mathbb{N}$ | |
{| class="wikitable" | |
|Ordnungszahl | |
|0 | |
|1 | |
|2 | |
|3 | |
|4 | |
|5 | |
|6 | |
|... | |
|- | |
| − | |$G$ |
| + | |$P$ |
|2 | |
|3 | |
|5 | |
|7 | |
|11 | |
|13 | |
|17 | |
|... | |
|} | |
'''ÜA 3''' | |
$\{a,b\}^*$ | |
Diese Menge lässt sich längenlexikografisch sortieren und auf diese Weise ebenfalls aufzählen. | |
== Folie 16 == | |
<code id="6073572223d8a"> | |
def get_g(n): | |
if n % 2 == 0: | |
return int(n / 2) | |
else: | |
return int((n + 1) / -2) | |
def diag(n): | |
x = 0 | |
y = 0 | |
d = 'r' | |
for i in range(n): | |
if d == 'r': | |
x = x + 1 | |
d = 'dd' | |
elif d == 'dd': | |
x = x - 1 | |
y = y + 1 | |
if x == 0: | |
d = 'd' | |
elif d == 'd': | |
y = y + 1 | |
d = 'du' | |
elif d == 'du': | |
x = x + 1 | |
y = y - 1 | |
if y == 0: | |
d = 'r' | |
return "( %s . %s )" % (get_g(x), get_g(y)) | |
</code> | |
<run id="6073572223e31"> | |
for i in range(13): | |
print("%s:: %s" % (i, diag(i))) | |
</run> | |
== Folie 20 == | |
== Folie 23 == |