Re: [Ql-Users] A small machine code program...

2010-11-28 Thread Norman Dunbar
On 27/11/10 17:53, Tobias Fröschle wrote: >> Puts() needs #include or at least defining correctly! > It should, for the sake of art, but doesn't need to. Hmm. Not declaring a function, even one returning int (the default return type) is listed in my book of common C mistakes. >> Main() always re

Re: [Ql-Users] A small machine code program...

2010-11-28 Thread Tony Firshman
Marcel Kilgus wrote, on 28/Nov/10 16:02 | Nov28: Laurence Reeves wrote: 1PRINT CHR$(RND(TO 255)):GO TO 1 Great thought in the spirit of Tony's cheating :-) But there's always room for optimizations: 1REP:BPUT RND(90) Will probably also need a few thousand years less! :-) He he - infinite

Re: [Ql-Users] A small machine code program...

2010-11-28 Thread Marcel Kilgus
Laurence Reeves wrote: > 1PRINT CHR$(RND(TO 255)):GO TO 1 Great thought in the spirit of Tony's cheating :-) But there's always room for optimizations: 1REP:BPUT RND(90) Will probably also need a few thousand years less! :-) Marcel ___ QL-Users Mail

Re: [Ql-Users] A small machine code program...

2010-11-28 Thread gdgqler
On 28 Nov 2010, at 14:51, Laurence Reeves wrote: > Tony Firshman wrote: >> Marcel Kilgus wrote, on 26/Nov/10 17:02 | Nov26: >>> Marcel Kilgus wrote: 1for i=1to 100 2a$="":if i mod 3=0:a$="FIZZ" 3if i mod 5=0:a$=a$&"BUZZ" 4print i,a$:next i (91 bytes including 4 LF)

Re: [Ql-Users] A small machine code program...

2010-11-28 Thread Laurence Reeves
Tony Firshman wrote: Marcel Kilgus wrote, on 26/Nov/10 17:02 | Nov26: Marcel Kilgus wrote: 1for i=1to 100 2a$="":if i mod 3=0:a$="FIZZ" 3if i mod 5=0:a$=a$&"BUZZ" 4print i,a$:next i (91 bytes including 4 LF) Damn, missed something: 1for i=1to 100 2a$="":if i mod 3=0:a$="FIZZ" 3if i mod 5=0:

Re: [Ql-Users] A small machine code program...

2010-11-28 Thread Marcel Kilgus
gdgqler wrote: > Another 1988 winning entry was as follows according to Peter van der Linden. Though one must say that these programs are usually not written this way, they're written more readable and obfuscated afterwards, sometimes even using specialized obfuscation programs. In any case, here

Re: [Ql-Users] A small machine code program...

2010-11-28 Thread gdgqler
On 27 Nov 2010, at 18:16, Marcel Kilgus wrote: > Norman Dunbar wrote: >> Main() always returns int. > > True. > >> Main always takes two parameters int and char **. > > Not true, "int main(void)" is valid according to C99 spec (see chapter > 5.1.2.2.1 ;-) ) > > But in context of the IOCC con

Re: [Ql-Users] A small machine code program...

2010-11-27 Thread Tony Firshman
Marcel Kilgus wrote, on 27/Nov/10 18:16 | Nov27: Norman Dunbar wrote: Main() always returns int. True. Main always takes two parameters int and char **. Not true, "int main(void)" is valid according to C99 spec (see chapter 5.1.2.2.1 ;-) ) But in context of the IOCC contest Tobias referr

Re: [Ql-Users] A small machine code program...

2010-11-27 Thread Marcel Kilgus
Norman Dunbar wrote: > Main() always returns int. True. > Main always takes two parameters int and char **. Not true, "int main(void)" is valid according to C99 spec (see chapter 5.1.2.2.1 ;-) ) But in context of the IOCC contest Tobias referred to, basically everything that compiles is valid

Re: [Ql-Users] A small machine code program...

2010-11-27 Thread Tobias Fröschle
Am 27.11.2010 15:48, schrieb Norman Dunbar: On 26/11/10 21:48, Tobias Fröschle wrote: main(){for(;;i++){puts(!i%3)?"FIZZ":(!(i%5)?"BUZZ":""));}} Error! Warning! Puts() needs #include or at least defining correctly! It should, for the sake of art, but doesn't need to. Main() always returns

Re: [Ql-Users] A small machine code program...

2010-11-27 Thread gdgqler
On 27 Nov 2010, at 13:25, Norman Dunbar wrote: >> This meets all Rich's requirements: >> -- >> The rules are simple - >> write out the values 1 to 100 on screen >> If the value is divisible by 3 write 'FIZZ' after the number >> If the value is divisible by 5 write 'BUZZ' after the number

Re: [Ql-Users] A small machine code program...

2010-11-27 Thread Norman Dunbar
On 26/11/10 21:48, Tobias Fröschle wrote: > main(){for(;;i++){puts(!i%3)?"FIZZ":(!(i%5)?"BUZZ":""));}} Error! Puts() needs #include or at least defining correctly! Main() always returns int. Main always takes two parameters int and char **. Your main() function doesn't return a value. The corre

Re: [Ql-Users] A small machine code program...

2010-11-27 Thread Norman Dunbar
> This meets all Rich's requirements: > -- > The rules are simple - > write out the values 1 to 100 on screen > If the value is divisible by 3 write 'FIZZ' after the number > If the value is divisible by 5 write 'BUZZ' after the number > If the value is divisible by 3 and 5 write 'FIZZBUZZ'

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Marcos Cruz
En/Je/On 2010-11-27 02:32, Marcel Kilgus escribió / skribis / wrote : > > 1for i=1to 100:print i!"FIZZ"(to 4*not i mod 3);"BUZZ"(to 4*not i mod 5) > This is pure awesomeness, I wish I had thought of that! It's "Forthness" :-) I'm used to "think in Forth" in any other programming language. > But

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Marcel Kilgus
Marcos Cruz wrote: > 1for i=1to 100:print i!"FIZZ"(to 4*not i mod 3);"BUZZ"(to 4*not i mod 5) > > (73 bytes including LF). This is pure awesomeness, I wish I had thought of that! But now that I've seen this trick, I hereby steal it and improve it to 1FOR i=1TO 100:PRINT i!"FIZZBUZZ"(1+4*(i MOD 3

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread P Witte
Marcos Cruz wrote: En/Je/On 2010-11-26 17:17, P Witte escribió / skribis / wrote : The rules are simple - write out the values 1 to 100 on screen If the value is divisble by 3 write 'FIZZ' after the number If the value is divisble by 5 write 'BUZZ' after the number If the value is divisble by 3

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Marcos Cruz
En/Je/On 2010-11-26 17:17, P Witte escribió / skribis / wrote : >> The rules are simple - >> write out the values 1 to 100 on screen >> If the value is divisble by 3 write 'FIZZ' after the number >> If the value is divisble by 5 write 'BUZZ' after the number >> If the value is divisble by 3 and 5

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Tobias Fröschle
Am 26.11.2010 20:41, schrieb Tony Firshman: P Witte wrote, on 26/Nov/10 19:34 | Nov26: Marcel Kilgus wrote: Tony Firshman wrote: I obeyed the rules (8-)# Maybe, but that is more creativity in applying the rules than creativity in programming. You clearly have chosen the wrong career, you sho

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Tony Firshman
P Witte wrote, on 26/Nov/10 19:34 | Nov26: Marcel Kilgus wrote: Tony Firshman wrote: I obeyed the rules (8-)# Maybe, but that is more creativity in applying the rules than creativity in programming. You clearly have chosen the wrong career, you should have been a lawyer ;) ... and there is

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread P Witte
Marcel Kilgus wrote: Tony Firshman wrote: I obeyed the rules (8-)# Maybe, but that is more creativity in applying the rules than creativity in programming. You clearly have chosen the wrong career, you should have been a lawyer ;) ... and there is nothing to say the program has to

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Dilwyn Jones
Cheater! ;-) Also, one can only run your program once. This meets all Rich's requirements: -- The rules are simple - write out the values 1 to 100 on screen If the value is divisible by 3 write 'FIZZ' after the number If the value is divisible by 5 write 'BUZZ' after the number If the va

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Tony Firshman
Marcel Kilgus wrote, on 26/Nov/10 18:48 | Nov26: Tony Firshman wrote: I obeyed the rules (8-)# Maybe, but that is more creativity in applying the rules than creativity in programming. You clearly have chosen the wrong career, you should have been a lawyer ;) ... and there is nothing to say t

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Marcel Kilgus
Tony Firshman wrote: > I obeyed the rules (8-)# Maybe, but that is more creativity in applying the rules than creativity in programming. You clearly have chosen the wrong career, you should have been a lawyer ;) > ... and there is nothing to say the program has to be run more than once. > I did c

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Tony Firshman
Marcel Kilgus wrote, on 26/Nov/10 18:09 | Nov26: Tony Firshman wrote: and CTRL SPACE after 100. Cheater! ;-) Also, one can only run your program once. This meets all Rich's requirements: -- The rules are simple - write out the values 1 to 100 on screen If the value is divisible by 3

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Marcel Kilgus
Tony Firshman wrote: > and CTRL SPACE after 100. Cheater! ;-) Also, one can only run your program once. > This meets all Rich's requirements: > -- > The rules are simple - > write out the values 1 to 100 on screen > If the value is divisible by 3 write 'FIZZ' after the number > If the val

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Tony Firshman
Marcel Kilgus wrote, on 26/Nov/10 17:02 | Nov26: Marcel Kilgus wrote: 1for i=1to 100 2a$="":if i mod 3=0:a$="FIZZ" 3if i mod 5=0:a$=a$&"BUZZ" 4print i,a$:next i (91 bytes including 4 LF) Damn, missed something: 1for i=1to 100 2a$="":if i mod 3=0:a$="FIZZ" 3if i mod 5=0:a$=a$&"BUZZ" 4print i,

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Marcel Kilgus
Marcel Kilgus wrote: > 1for i=1to 100 > 2a$="":if i mod 3=0:a$="FIZZ" > 3if i mod 5=0:a$=a$&"BUZZ" > 4print i,a$:next i > > (91 bytes including 4 LF) Damn, missed something: 1for i=1to 100 2a$="":if i mod 3=0:a$="FIZZ" 3if i mod 5=0:a$=a$&"BUZZ" 4print i,a$:next (89 bytes including 4 LF) Marcel

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread Marcel Kilgus
P Witte wrote: > Just had another look: Is this the shortest possible version? > > 1defproc z:if i mod 3=0:print'FIZZ';:endif:if i mod > 5=0:print'BUZZ';:endif:print:enddef:for i=1to 100:print i,:z:endfor i > > Thats all one line. It should result in a file of 122b including eol. > Once LOADed it

Re: [Ql-Users] A small machine code program...

2010-11-26 Thread P Witte
Rich Mellor wrote: I was just reading that 99/100 job applicants for programming jobs apparently cannot write a short "fizzbuzz" program when given 10 minutes to do so in an interview. The rules are simple - write out the values 1 to 100 on screen If the value is divisble by 3 write 'FIZZ' a

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread P Witte
gdgqler wrote: On 4 Nov 2010, at 12:20, Dilwyn Jones wrote: Norman Dunbar Does It In Assembler George Gwilt Does It Turbo-Charged Tony Firshman Does It In Pearl(s) Now all I need is one for Rich Mellor, which I failed to provide, possibly something like Rich Mellor Does It With Second User H

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread P Witte
Dilwyn Jones wrote: <> Now, if you want something to puzzle with, try my little pointer driven puzzle program at http://www.dilwyn.me.uk/games/djpuzzle.zip Nice one, Dilwyn ;o) Per ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread gdgqler
On 4 Nov 2010, at 13:42, Dilwyn Jones wrote: >>> Norman Dunbar Does It In Assembler >>> George Gwilt Does It Turbo-Charged >>> Tony Firshman Does It In Pearl(s) >>> >>> Now all I need is one for Rich Mellor, which I failed to provide, possibly >>> something like Rich Mellor Does It With Second

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread Dilwyn Jones
Norman Dunbar Does It In Assembler George Gwilt Does It Turbo-Charged Tony Firshman Does It In Pearl(s) Now all I need is one for Rich Mellor, which I failed to provide, possibly something like Rich Mellor Does It With Second User Hardware, but I thought that was too rude ;-) Now, if you want

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread gdgqler
On 4 Nov 2010, at 12:20, Dilwyn Jones wrote: > > Norman Dunbar Does It In Assembler > George Gwilt Does It Turbo-Charged > Tony Firshman Does It In Pearl(s) > > Now all I need is one for Rich Mellor, which I failed to provide, possibly > something like Rich Mellor Does It With Second User Hard

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread Dilwyn Jones
My S*BASIC program is: 10 CLS:FOR x=1 to 100:PRINT x&isit$(3,"FIZZ")&isit$(5,"BUZZ"):PAUSE 5 20 DEFine FuNction isit$(m%,a$) 30 IF (x MOD m%):RETRurn "":ELSE:RETurn a$ 40 END vDEFine This will work better if you replace RETRurn by RETurn (which is what I had in the QPC2 program). (8-)# V

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread gdgqler
On 4 Nov 2010, at 11:05, Tony Firshman wrote: > gdgqler wrote, on 04/11/2010 10:52: >> >> On 4 Nov 2010, at 10:44, gdgqler wrote: >> >>> My S*BASIC program is: >>> >>> 10 CLS:FOR x=1 to 100:PRINT x&isit$(3,"FIZZ")&isit$(5,"BUZZ"):PAUSE 5 >>> 20 DEFine FuNction isit$(m%,a$) >>> 30 IF (x MOD m%

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread Tony Firshman
gdgqler wrote, on 04/11/2010 10:52: On 4 Nov 2010, at 10:44, gdgqler wrote: My S*BASIC program is: 10 CLS:FOR x=1 to 100:PRINT x&isit$(3,"FIZZ")&isit$(5,"BUZZ"):PAUSE 5 20 DEFine FuNction isit$(m%,a$) 30 IF (x MOD m%):RETRurn "":ELSE:RETurn a$ 40 END vDEFine This will work better if you r

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread gdgqler
On 4 Nov 2010, at 10:44, gdgqler wrote: > My S*BASIC program is: > > 10 CLS:FOR x=1 to 100:PRINT x&isit$(3,"FIZZ")&isit$(5,"BUZZ"):PAUSE 5 > 20 DEFine FuNction isit$(m%,a$) > 30 IF (x MOD m%):RETRurn "":ELSE:RETurn a$ > 40 END vDEFine > This will work better if you replace RETRurn by RETurn (

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread gdgqler
On 2 Nov 2010, at 11:23, Tony Firshman wrote: > > sB is my limit (8-)# I would love to see Laurence Reeves' version. He was > always looking for how to reduce code. He, for instance, did a *very* tiny > Forth for the QL. > There were loads of examples in Hermes and (especially) superHermes

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread gdgqler
On 3 Nov 2010, at 17:06, gdgqler wrote: > > This would take, I suppose, 3 minutes in S*BASIC. > My S*BASIC program is: 10 CLS:FOR x=1 to 100:PRINT x&isit$(3,"FIZZ")&isit$(5,"BUZZ"):PAUSE 5 20 DEFine FuNction isit$(m%,a$) 30 IF (x MOD m%):RETRurn "":ELSE:RETurn a$ 40 END vDEFine This must t

Re: [Ql-Users] A small machine code program...

2010-11-04 Thread Tony Firshman
Rich Mellor wrote, on 03/11/2010 20:47: By the way Tony, Have you built a time machine in one of your sheds? Just your messages seem to be sent a whole day before the message they are responding to! I am using a spare laptop that has a dead bios battery! Tony -- QBBS (QL fido BBS 2:25

Re: [Ql-Users] A small machine code program...

2010-11-03 Thread Rich Mellor
On 02/11/2010 18:22, Tony Firshman wrote: Rich Mellor wrote, on 03/11/2010 17:49: On 02/11/2010 17:34, Tony Firshman wrote: 10 FOR j = 1 TO 100 15 sp$ = " "; 20 PRINT j; 20 if j/3 == int(j/3) 25 sp$=""; 30 PRINT " FIZZ"; 40 END IF 30 IF j/5 == int(j/5) 40 PRINT sp$&"BUZZ"; 50 END IF 60 PRINT 7

Re: [Ql-Users] A small machine code program...

2010-11-03 Thread Tony Firshman
Rich Mellor wrote, on 03/11/2010 17:49: On 02/11/2010 17:34, Tony Firshman wrote: 10 FOR j = 1 TO 100 15 sp$ = " "; 20 PRINT j; 20 if j/3 == int(j/3) 25 sp$=""; 30 PRINT " FIZZ"; 40 END IF 30 IF j/5 == int(j/5) 40 PRINT sp$&"BUZZ"; 50 END IF 60 PRINT 70 END FOR Hi Tony, Yes, you are going t

Re: [Ql-Users] A small machine code program...

2010-11-03 Thread Rich Mellor
On 02/11/2010 17:34, Tony Firshman wrote: 10 FOR j = 1 TO 100 15 sp$ = " "; 20 PRINT j; 20 if j/3 == int(j/3) 25 sp$=""; 30 PRINT " FIZZ"; 40 END IF 30 IF j/5 == int(j/5) 40 PRINT sp$&"BUZZ"; 50 END IF 60 PRINT 70 END FOR Hi Tony, Yes, you are going to confuse SB programmers with that one -

Re: [Ql-Users] A small machine code program...

2010-11-03 Thread Tony Firshman
Rich Mellor wrote, on 02/11/2010 19:53: I was just reading that 99/100 job applicants for programming jobs apparently cannot write a short "fizzbuzz" program when given 10 minutes to do so in an interview. The rules are simple - write out the values 1 to 100 on screen If the value is divisble

Re: [Ql-Users] A small machine code program...

2010-11-03 Thread gdgqler
On 2 Nov 2010, at 19:53, Rich Mellor wrote: > I was just reading that 99/100 job applicants for programming jobs apparently > cannot write a short "fizzbuzz" program when given 10 minutes to do so in an > interview. > > The rules are simple - > write out the values 1 to 100 on screen > If the

Re: [Ql-Users] A small machine code program...

2010-11-03 Thread Tony Firshman
Rich Mellor wrote, on 02/11/2010 19:53: I was just reading that 99/100 job applicants for programming jobs apparently cannot write a short "fizzbuzz" program when given 10 minutes to do so in an interview. The rules are simple - write out the values 1 to 100 on screen If the value is divisble

Re: [Ql-Users] A small machine code program...

2010-11-02 Thread Norman Dunbar
Evening Rich, I would do something like the following, equally untested - assumes the channel to the screen is open, etc. Is it elegant? I don't know, probably not. Is it simple, yes. And no messing with the arithmetic stack etc either, all done in integers. begin equ 1 exitequ 101 io_sbyt

Re: [Ql-Users] A small machine code program...

2010-11-02 Thread Rich Mellor
On 02/11/2010 20:45, P Witte wrote: Rich Mellor wrote: I was just reading that 99/100 job applicants for programming jobs apparently cannot write a short "fizzbuzz" program when given 10 minutes to do so in an interview. The rules are simple - write out the values 1 to 100 on screen If the

Re: [Ql-Users] A small machine code program...

2010-11-02 Thread P Witte
Rich Mellor wrote: I was just reading that 99/100 job applicants for programming jobs apparently cannot write a short "fizzbuzz" program when given 10 minutes to do so in an interview. The rules are simple - write out the values 1 to 100 on screen If the value is divisble by 3 write 'FIZZ' a

[Ql-Users] A small machine code program...

2010-11-02 Thread Rich Mellor
I was just reading that 99/100 job applicants for programming jobs apparently cannot write a short "fizzbuzz" program when given 10 minutes to do so in an interview. The rules are simple - write out the values 1 to 100 on screen If the value is divisble by 3 write 'FIZZ' after the number If the