Übersicht > Türme von Hanoi > Beatnik

Beatnik ist eine nicht Turing-vollständige, stackbasierte Sprache.


Die Türme von Hanoi in Beatnik

/* 66-88-6-22-33-777--666-333--3-444-7777-55-7777 */
put vi
dupdup dupdup subsub swapit

/* 6-88-555-8-444-7-555-999--22-99--^6^ */
dupdup addit dupdup dupdup addit addit

/* 6-2-444-66--555-666-666-7 */
{
    dupdup bnz +ii {
        ignor
        terminatenow
    }

    dupdup
    /* 7777-666-6-33-8-44-444-66-4--8-666--3-666? */
    {
    
        /* 3-444-888--^3^ */
        {
            put whatever dupdup subsub swapit
            dupdup bz +xxx put i subsub
            dupdup bz +xxii put i subsub
            dupdup bz +xv put i subsub
            swapit put i addit swapit
            put notzero bnzre -xxxiii
            ignor
        }

        /* 66-666-8--4-777-33-2-8-33-7777--8-44-2-66--^4^? */
        {
            put i swapit
            dupdup bz +xxxii put i subsub
            dupdup bz +xxv put i subsub
            dupdup bz +xvii put i subsub
            dupdup bz +x put i subsub
            swapit put i subsub swapit
            ignor
        }
    }

    /* 4-666-8-666--7-777-444-66-8 */
    bnz +xxxxxxxxxxxiii

        
    /* 7-88-7777-44--8-44-33--9-2-999--22-2-222-55 */
    {
        dupdup

        /* 3-444-888-6-666-3--^3^ */
        {
            put whatever dupdup subsub swapit
            dupdup bz +xxxvii put i subsub
            dupdup bz +xxvi put i subsub
            dupdup bz +xv put i subsub
            swapit put i addit swapit
            put notzero bnzre -xxxiii
            put i addit
            put i addit
        }
                                     
        swapit

        /* 9-666-777--^1^ */
        {
            put whatever dupdup subsub swapit
            dupdup bz +xxvi put i subsub
            dupdup bz +xv put i subsub
            swapit put ii addit swapit
            put notzero bnzre -xxvi
            put i addit
            put i swapit subsub addit
        }

        dupdup dupdup addit addit addit
        put vii subsub swapit
    }
    
/* 44-2-888-33--2--777-33-7777-8 */
{
    put notzero bnz +x
    put notzero bnzre -xxxxxxxxxxxxxxxxxxxxvi
    put notzero bnz +xxxxxxxxxxxxvi
}

    /* 7-88-7777-44--8-44-33--7777-444-66-4-555-33--6-666-888-33 */
    {
        dupdup
        
        /* 6-666-3--^6^ */
        {
            dupdup bz xxxxxxiiii put i subsub
            dupdup bz xxxxxiii put i subsub
            dupdup bz xxxxii put i subsub
            dupdup bz xxxi put i subsub
            dupdup bz xx put i subsub
            dupdup bz viii put i subsub
            put xxi bnzre xxxxx
            put i addit
            put i addit
            put i addit
            put i addit
            put i addit
        }
        
        put vii addit
        swapit
    }
    
    /* 7-88-7777-44--8-44-33--9-2-999--444-66 */
    {
        /* 9-666-777--^1^ */
        {
            put whatever dupdup subsub swapit
            dupdup bz +xxvi put i subsub
            dupdup bz +xv put i subsub
            swapit put ii addit swapit
            put notzero bnzre -xxvi
            put i addit
         
            put i swapit subsub addit
        }
        
        put vii subsub
    }
    
    /* 22-2-222-55--8-666--8-44-33--6-2-444-66--555-666-666-7 */
    put notzero bnzre -xxxxxxxxxxxxxvi

    /* 7-777-444-66-8--666-66-33--555-444-66-33 */
    put xxxx dupdup
        dupdup addit put xv addit dupdup oputc
        put xxxi addit dupdup oputc
        dupdup put ii addit oputc
        dupdup oputc
        swapit dupdup oputc swapit

        put i subsub dupdup oputc
        put vi addit dupdup oputc
        put v subsub dupdup oputc
        swapit dupdup oputc swapit

        dupdup
            dupdup put xii addit
                dupdup oputc swapit
                dupdup put iii subsub oputc
                dupdup oputc swapit
                dupdup put iii addit oputc
                dupdup put v addit oputc
            put vi addit oputc
        oputc
        swapit dupdup oputc swapit

        dupdup put xxii subsub oputc
        dupdup put ii subsub oputc
        dupdup put iii addit oputc
        dupdup oputc
        dupdup put v addit oputc
        dupdup put iii subsub oputc
        dupdup oputc
        swapit dupdup oputc swapit

        dupdup put xxi addit dupdup oputc
            dupdup put viii subsub oputc
        put x subsub oputc
        swapit dupdup oputc swapit
    
        dupdup put xxi subsub oputc
        put xx addit dupdup oputc
        dupdup put iii subsub oputc
        put x subsub oputc
    oputc

/* 44-2-888-33--2--777-33-7777-8 */
{
    put notzero bnz +v
    put notzero bnzre -xxxxxxxxxxxxxxxxxxxxv
}

    /* 7777-666-88-777-222-33--7-444-555-33 */
    dupdup
    {
        /* 3-444-888--^2^ */
        {
            put whatever dupdup subsub swapit
            dupdup bz +xxii put i subsub
            dupdup bz +xv put i subsub
            swapit put i addit swapit
            put notzero bnzre -xxvi
            ignor
        }

        /* 6-666-3--^3^ */
        {
            dupdup bz xxxi put i subsub
            dupdup bz xx put i subsub
            dupdup bz viii put i subsub
            put xxi bnzre xxvii
            put i addit
            put i addit
        }
        put xxxx
        dupdup dupdup addit addit
        put i addit
        addit
        oputc
    }

    put xxxx dupdup
        dupdup oputc
        dupdup dupdup addit addit
        dupdup put i addit oputc
        put xxvi addit dupdup oputc
        dupdup put xviii subsub oputc
        swapit dupdup oputc swapit

        dupdup put xxxxi subsub oputc
        dupdup oputc
        dupdup put iii subsub oputc
        put x subsub oputc
    oputc
    
    /* 6-666-3--^3^ */
    {
        dupdup bz xxxi put i subsub
        dupdup bz xx put i subsub
        dupdup bz viii put i subsub
        put notzero bnzre xxvii
        put i addit
        put i addit
    }
    put xxxxi
    dupdup dupdup addit addit
    swapit subsub oputc
    
    put xii
    dupdup put xxxxv addit oputc
    oputc
    put notzero bnzre -xxxxxxxxxxxxxxxxxxxxvi
}

Download: Interpreter, Wörterbuch und Beispiele (bni.zip).