Wir sind die Flo: Unterschied zwischen den Versionen

aus dem Wiki des Entropia e.V., CCC Karlsruhe
(→‎Bewertung: wartungsfreundlich!)
(mein Beitrag zu Wir Sind Die Flo)
Zeile 121: Zeile 121:


* Summe: '''30'''
* Summe: '''30'''
== ARM-Assembler ==
Folgendes Binary läuft auf Vaporlight-Modulen und ist unter 0.4K (genau: 408 Byte) groß. OK, das entspricht jetzt nicht ganz den Regeln, aber...
<pre>
$ hexdump -C dieflo.bin
00000000  00 10 00 20 09 00 00 08  40 48 3d 21 51 f4 80 41  |... ....@H=!Q..A|
00000010  01 60 5f f4 00 60 c4 f2  01 00 5f f4 09 61 41 60  |.`_..`...._..aA`|
00000020  5f f4 60 50 c4 f2 01 00  42 f2 0c 01 c1 60 45 21  |_.`P....B....`E!|
00000030  81 60 20 26 00 25 0f f2  df 03 00 f0 53 f8 00 f0  |.` &.%......S...|
00000040  5f f8 6a 29 06 d0 6b 29  0b d0 20 29 10 d0 0d 29  |_.j)..k).. )...)|
00000050  17 d0 f4 e7 20 2e f2 da  76 00 4d a3 00 f0 42 f8  |.... ...v.M...B.|
00000060  ed e7 01 2e eb dd 76 08  4a a3 00 f0 3b f8 e6 e7  |......v.J...;...|
00000070  75 40 35 42 41 a3 01 d1  0f f2 fb 03 00 f0 32 f8  |u@5BA.........2.|
00000080  dd e7 0f f2 fd 03 00 f0  2d f8 33 a3 00 f0 2a f8  |........-.3...*.|
00000090  ff 1b 0a 2d 09 db 0a 21  b5 fb f1 f4 04 fb 01 f6  |...-...!........|
000000a0  ae 1b 40 b4 02 37 25 46  f3 e7 0f f2 b7 06 76 5d  |..@..7%F......v]|
000000b0  0f f2 b9 03 5b 5d 9e 42  09 da 0f f2 cd 01 89 5d  |....[].B.......]|
000000c0  c9 19 26 a4 61 5c 00 f0  15 f8 01 36 f3 e7 02 3f  |..&.a\.....6...?|
000000d0  01 d4 20 bc e9 e7 0f f2  38 03 00 f0 03 f8 00 f0  |.. .....8.......|
000000e0  0f f8 a6 e7 74 46 13 f8  01 1b 11 b1 00 f0 02 f8  |....tF..........|
000000f0  f9 e7 20 47 02 68 12 f0  80 0f fb d0 01 71 70 47  |.. G.h.......qpG|
00000100  01 68 11 f0 20 0f fb d0  01 79 70 47 18 10 02 40  |.h.. ....ypG...@|
00000110  0d 0a 5b 4f 4b 5d 00 1b  5b 32 4a 1b 5b 48 20 64  |..[OK]..[2J.[H d|
00000120  69 76 69 64 75 75 6d 0d  0a 20 73 79 62 0d 0a 20  |ividuum.. syb.. |
00000130  66 69 6a 69 0d 0a 20 66  6c 6f 77 68 61 73 65 0d  |fiji.. flowhase.|
00000140  0a 20 66 6c 6f 72 6f 6c  66 0d 0a 20 70 69 72 61  |. florolf.. pira|
00000150  74 65 6e 66 6c 6f 0d 00  46 4c 4f 00 49 56 58 4c  |tenflo..FLO.IVXL|
00000160  43 44 4d 00 02 02 02 00  01 01 01 01 04 00 03 04  |CDM.............|
00000170  05 02 02 03 04 05 06 20  1b 5b 44 00 2a 1b 5b 44  |....... .[D.*.[D|
00000180  00 1b 5b 32 4a 1b 5b 48  00 00 01 00 00 00 02 00  |..[2J.[H........|
00000190  1b 5b 42 00 1b 5b 41 00                          |.[B..[A.|
00000198
</pre>
([[Medium:Dieflo-arm.s.txt|Sourcecode]] gibt's auch)

Version vom 16. Juli 2012, 18:11 Uhr

Specs 0.1

Wir-sind-die-flo.png
  • Flos auswählen => Flozählung berechnen, z.B. Dividuum(Flo0) + Flowhase(Flo3) = 2^0 + 2^3 = 9
  • Flozählung korrekt anzeigen in einer Dialogbox mit OK-Button, in römischen Zahlen (Namespace!), also FLOIX.
  • Codegflo nach Neingeists Bewertungsskala

Referenzimplementierung 0.1 in Python

#!/usr/bin/python

import pygtk
pygtk.require('2.0')
import gtk

flos = [
        "dividuum", 
        "syb", 
        "fiji", 
        "flowhase", 
        "florolf", 
        "piratenflo"
       ]

class WirSindDieFlo:

  flobutts = []

  def format_roman(self, case, counter):
    ones = ['i', 'x', 'c', 'm']
    fives = ['v', 'l', 'd']
    label, index = '', 0
    # This will die of IndexError when counter is too big
    while counter > 0:
        counter, x = divmod(counter, 10)
        if x == 9:
            label = ones[index] + ones[index+1] + label
        elif x == 4:
            label = ones[index] + fives[index] + label
        else:
            if x >= 5:
                s = fives[index]
                x = x-5
            else:
                s = ''
            s = s + ones[index]*x
            label = s + label
        index = index + 1
    if case == 'I':
        return label.upper()
    return label

  def floberechnungscallback(self, widget, data=None):
    i = 0
    flozaehlung = 0

    for flobutt in self.flobutts:
      if flobutt.get_active():
        flozaehlung += pow(2, i)
      i += 1

    diaflog = gtk.Dialog("Wir sind die Flo!",
                         None,
                         gtk.DIALOG_DESTROY_WITH_PARENT,
                         (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
    flolabel = gtk.Label("Wir sind die FLO" 
                         + self.format_roman("I", flozaehlung)
                         + ".")
    flolabel.show()
    diaflog.vbox.pack_start(flolabel)
    diaflog.show()
    diaflog.run()
    diaflog.destroy()

  def delete_event(self, widget, data=None):
    gtk.main_quit()
    return False

  def __init__(self):
    self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    self.window.set_title("Wir sind die Flo?")
    self.window.set_border_width(20)
    self.window.connect("delete_event", self.delete_event)

    vbox = gtk.VBox(True, 2)
    self.window.add(vbox)

    for flo in flos:
      cbut = gtk.CheckButton(flo)
      vbox.pack_start(cbut)
      cbut.show()

      self.flobutts.append(cbut)

    but = gtk.Button("Wir sind die Flo?")
    but.connect("clicked", self.floberechnungscallback,)
    vbox.pack_start(but)
    but.show()

    vbox.show()
    self.window.show()

def main():
  gtk.main()
  return 0

if __name__ == "__main__":
  WirSindDieFlo()
  main()

Bewertung

Bewertungsrichtlinien 0.2

  • Zeilenzahl (100-x) relativ Referenzimplementierung: 100-100 = 0
  • Bonus (10) kein Overflo: 10
  • Bonus (100) Foto/Icon-Auswahl der Flos : 0
  • Bonus (100) Feature Rückberechnung (aus römischer Notierung): 0
  • Bonus (20) Wartungsfreundlichkeit: 20
  • Faktor Anzahl Programmiersprachen: *1 = 30
  • Summe: 30

ARM-Assembler

Folgendes Binary läuft auf Vaporlight-Modulen und ist unter 0.4K (genau: 408 Byte) groß. OK, das entspricht jetzt nicht ganz den Regeln, aber...

$ hexdump -C dieflo.bin
00000000  00 10 00 20 09 00 00 08  40 48 3d 21 51 f4 80 41  |... ....@H=!Q..A|
00000010  01 60 5f f4 00 60 c4 f2  01 00 5f f4 09 61 41 60  |.`_..`...._..aA`|
00000020  5f f4 60 50 c4 f2 01 00  42 f2 0c 01 c1 60 45 21  |_.`P....B....`E!|
00000030  81 60 20 26 00 25 0f f2  df 03 00 f0 53 f8 00 f0  |.` &.%......S...|
00000040  5f f8 6a 29 06 d0 6b 29  0b d0 20 29 10 d0 0d 29  |_.j)..k).. )...)|
00000050  17 d0 f4 e7 20 2e f2 da  76 00 4d a3 00 f0 42 f8  |.... ...v.M...B.|
00000060  ed e7 01 2e eb dd 76 08  4a a3 00 f0 3b f8 e6 e7  |......v.J...;...|
00000070  75 40 35 42 41 a3 01 d1  0f f2 fb 03 00 f0 32 f8  |u@5BA.........2.|
00000080  dd e7 0f f2 fd 03 00 f0  2d f8 33 a3 00 f0 2a f8  |........-.3...*.|
00000090  ff 1b 0a 2d 09 db 0a 21  b5 fb f1 f4 04 fb 01 f6  |...-...!........|
000000a0  ae 1b 40 b4 02 37 25 46  f3 e7 0f f2 b7 06 76 5d  |..@..7%F......v]|
000000b0  0f f2 b9 03 5b 5d 9e 42  09 da 0f f2 cd 01 89 5d  |....[].B.......]|
000000c0  c9 19 26 a4 61 5c 00 f0  15 f8 01 36 f3 e7 02 3f  |..&.a\.....6...?|
000000d0  01 d4 20 bc e9 e7 0f f2  38 03 00 f0 03 f8 00 f0  |.. .....8.......|
000000e0  0f f8 a6 e7 74 46 13 f8  01 1b 11 b1 00 f0 02 f8  |....tF..........|
000000f0  f9 e7 20 47 02 68 12 f0  80 0f fb d0 01 71 70 47  |.. G.h.......qpG|
00000100  01 68 11 f0 20 0f fb d0  01 79 70 47 18 10 02 40  |.h.. ....ypG...@|
00000110  0d 0a 5b 4f 4b 5d 00 1b  5b 32 4a 1b 5b 48 20 64  |..[OK]..[2J.[H d|
00000120  69 76 69 64 75 75 6d 0d  0a 20 73 79 62 0d 0a 20  |ividuum.. syb.. |
00000130  66 69 6a 69 0d 0a 20 66  6c 6f 77 68 61 73 65 0d  |fiji.. flowhase.|
00000140  0a 20 66 6c 6f 72 6f 6c  66 0d 0a 20 70 69 72 61  |. florolf.. pira|
00000150  74 65 6e 66 6c 6f 0d 00  46 4c 4f 00 49 56 58 4c  |tenflo..FLO.IVXL|
00000160  43 44 4d 00 02 02 02 00  01 01 01 01 04 00 03 04  |CDM.............|
00000170  05 02 02 03 04 05 06 20  1b 5b 44 00 2a 1b 5b 44  |....... .[D.*.[D|
00000180  00 1b 5b 32 4a 1b 5b 48  00 00 01 00 00 00 02 00  |..[2J.[H........|
00000190  1b 5b 42 00 1b 5b 41 00                           |.[B..[A.|
00000198

(Sourcecode gibt's auch)