Qbasicnews.com
September 21, 2019, 10:46:11 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: optimization challenge  (Read 2755 times)
yetifoot
Ancient Guru
****
Posts: 575



« on: December 13, 2005, 10:14:58 PM »

i've been making a brainf*ck like thing for FB,  theres loads of room for creative thinking and crazy optimizations in this type of language, and i have two pieces of code to set as a challenge.  i've done a little optimization but im sure theres room for more.

heres the interpreter

http://www.streetcds.co.uk/cw_0_1.bas

here are the challenges, choose at your leisure.

you can copy and paste these into the interpreter.  least number of symbols is the challenge.

Code:
   ' Emulate Shell "PAUSE"
    '  This is the equivalent code
    '    Print "Press any key to continue . . . ";
    '    GetKey
    '    Print chr(10);
    '    End
    '  For the challenge, machine must be returned to
    '  pre-existing state, and must include @ to end.
   
    strcpy(@code, "abcd0+++D++llll")
    strcat(@code, ".0+llll-lll------.A-")
    strcat(@code, "---C---------.a+..0l")
    strcat(@code, "llll.Bdlllll+.c.a++")
    strcat(@code, "+++++.b.c---.------")
    strcat(@code, ".$.b.$.-----.b.dlll")
    strcat(@code, "+ll-.c+.-.a++.----")
    strcat(@code, "-------.$-.+++++++.$")
    strcat(@code, "+.b.$-l.b.$.b.$.b.")
    strcat(@code, ",0+lll++.$D$C$B$A$@ ")  ' 199 Instructions


Code:
   ' Get users name and say hello
    ' machine must be returned to
    ' pre-existing state, except reg c (should contain string len)
    ' and reg d that you can use any way you like
    ' string should still exist in memory and be null terminated
    ' program must include @ to end.

    strcpy(@code, "abcd0+lll-llll-")
    strcat(@code, "--A0+ll+llll---B0b++")
    strcat(@code, "+.a-.-------.C----.a")  
    strcat(@code, "++++++.c.-rr+++++++.")
    strcat(@code, "Ba+++++++.+++++.Da++")    
    strcat(@code, "+.c.b.d.c++++++++++.")  
    strcat(@code, "d----.---.b.a+.c----")
    strcat(@code, ".a.c.br------.bl--.0")
    strcat(@code, "C+[,.D----------:c+C")
    strcat(@code, "d>+]cB$0A$Db[0+A$")
    strcat(@code, "d<Db-B:$]Ba[$D0]bd")
    strcat(@code, "0+lll+lll.0+++lllll+")
    strcat(@code, "++++.+++++++..+++.0+")
    strcat(@code, "lllll.cB$$Dc[d.>Dc")
    strcat(@code, "-C]d$d0+lll++.$bC$")
    strcat(@code, "Db[-Bd<Db]d$$$B$A$d@") ' 320 Instructions
Logged

EVEN MEN OF STEEL RUST.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!