Zum Hauptinhalt springen
Version: LPs

Programmieren

Grüfnisch

Grüfnisch ist in der Schweiz unter Jugendlichen und Kindern eine verbreitete Spielsprache. Diese Sprache wird von vielen Kindern und Jugendlichen auch als Geheimsprache benutzt. Bei „Grüfnisch“ werden alle Vokale wie folgt ersetzt:[^1]

a
anafa
e
enefe
i
inifi
o
onofo
u
unufu
ä
änäfä
ö
önöfö
ü
ünüfü

Beispiele

Hallo
Hanafallonofo
Fachschaftstag Informatik
Fanafachenefeschaftstanag Infanoforninifatik
1. Grüfnisch

Wie lautet der Satz Hallo, es ist Winter auf Grüfnisch?

  • Löse die Aufgabe von Hand, ohne Programmieren...
  • Prüfe, ob deine Antwort stimmt. (Auf das klicken)
  • Markiere die Aufgabe als gelöst. (oben in der Aufgabe auf das Kästchen klicken...)
Laden...
2. Programmiere es...
    text = 'Hallo, es ist Winter!'
    print(text)
    Laden...
    Flussdiagramm

    Zeichne ein Flussdiagramm, welches den Entscheidungsprozess darstellt, ob man nach dem FATA noch zum Sternenmarkt kommt.

    Laden...
    Laden...

    Weiterführende Programmier-Möglichkeiten

    Turtles

    from turtle import *
    color('red', 'yellow')
    begin_fill()
    while True:
    forward(200)
    left(170)
    p = pos()
    if abs(p[0]) < 1 and abs(p[1]) < 1:
    break
    end_fill()

    Fraktale

    from turtle import *

    speed(0)
    penup()
    goto(0, -200)
    pendown()
    left(90)
    def tree(size):
    if size < 5:
    forward(size)
    else:
    forward(size)
    left(35)
    tree(size / 1.5)
    backward(size / 1.5)
    right(100)
    tree(size / 1.5)
    backward(size / 1.5)
    left(65)
    tree(120)

    Conway's Game of Life

    Mehrheitlich undokumentiertes Beispielprogramm - alle Skripts, die im Repository unter 👉 /static/bry-libs abgelegt sind, können importiert und ausgeführt werden...

    from grid import Grid
    from game import gameloop, sleep

    # initial state
    grid = Grid.from_text('''











    xx xx
    xx x
    x x
    x x
    x xx
    xx xx








    ''')

    def neighbours(grid, x, y):
    nb = []
    dim_x = len(grid[0])
    dim_y = len(grid)
    for i in range(-1, 2):
    for j in range(-1, 2):
    if not (i == 0 and j == 0):
    ny = (y + i) % dim_y
    nx = (x + j) % dim_x
    nb.append(grid[ny][nx])
    return nb

    def live_neighbours(grid, x, y):
    s = 0
    for cell in neighbours(grid, x, y):
    if cell == 'black':
    s += 1
    return s

    @gameloop
    def evolution(dt):
    current = grid.color_grid
    for x in range(grid.size[1]):
    for y in range(grid.size[0]):
    alive = live_neighbours(current, x, y)
    if current[y][x] == 'black' and 2 <= alive <= 3:
    grid[y][x].color = 'black'
    elif current[y][x] != 'black' and alive == 3:
    grid[y][x].color = 'black'
    else:
    grid[y][x].color = 'white'
    sleep(5)

    evolution()

    Interaktives Flood-Fill

    from grid import Grid
    from browser import aio

    board = Grid.from_text('''
    xxxxxxxx
    xxxx x
    xx x x
    x xxxx
    x x x x
    x xxxx x
    x x x
    xxxxxxxx
    ''')

    white = 'rgba(0,0,0,0)'
    async def flood_fill(x, y):
    if x < 0 or x >= len(board[0]) or y < 0 or y >= len(board):
    return
    if board[y][x].color == white:
    board[y][x].color = 'red'
    await aio.sleep(0.3)
    await flood_fill(x-1, y)
    await flood_fill(x+1, y)
    await flood_fill(x, y-1)
    await flood_fill(x, y+1)

    aio.run(flood_fill(2, 2))