Computer Science Canada

Best "Anything" in 20 Lines (Choose Your Language)

Author:  Clayton [ Wed Sep 13, 2006 6:19 pm ]
Post subject:  Best "Anything" in 20 Lines (Choose Your Language)

Okay, there was a contest like this some time ago, which turned into a best game in 20 lines.. but whatever. Here you can program whatever you want, just keep it *around* (preferrably under) 20 lines.

So the contest!

It will be open to any language (note ill need help with marking etc..), and will be marked on the following:


1. Intuitiveness - How interesting did you code your program to fit the restriction?
2. Performance - I don't want to have to wait forever for the program to execute
3. Attractiveness - It doesnt have to be perfect, but i dont want to see something utterly horrible (minor marks here)
4. Length - Marks will be taken off for going in excess of 20 lines


Anyone wishing to submit a submission PM the source to me and i will share it with no one but mods who wish to help with the marking. Please do not post your source here, but if you wish to post an executable, thats fine.

PRIZES
Prizes will be awarded to the top place program for each language, and in each category (if enough submissions are submitted per language). Prizes will be as follows (for each group):

1st: 200 bits
2nd: 100 bits
3rd: 50 bits
4th: 25 bits
5th: 10 bits

There will also be prizes for each language for other things:

Most Graphically Appealing: 100 bits
Best Effect: 100 bits
Most Complex: 50 bits
First Submission: 100 bits

It should be noted that the First Submission prize still has to be quality work, not just some hodgepodge of code you threw together just to get some easy bits. I would still like to see some decent work from everyone Very Happy

NOTE: Any mods willing to help out with bits would be much appreciated, i can give out some, I don't mind, but i don't know if I'll have enough Confused

Once again, this will be open to any language, and depending on the number of submissions will be split into two groups on the request of the submitter (when submitting your code to me via a PM, tell me if you want into the first category [less experience] or the second category [more experience], if the judges deem a submission to be good enough we may request that we can move it up a category)

Have fun with this and i hope to see some good submissions Very Happy

[edit]Deadline is one month from this post (ie. October 13 2006 at midnight)[/edit]

Author:  [Gandalf] [ Wed Sep 13, 2006 7:12 pm ]
Post subject: 

The problem with allowing any language is that most languages are a lot more flexible in what you can fit on one line than Turing. Oh well, I guess we'll see how it goes...

Author:  Clayton [ Wed Sep 13, 2006 7:26 pm ]
Post subject: 

thats why i have it separated into a category for each language submitted Very Happy, in the 20 line count i will exclude whitespace (for those of you who like to use it) and in the cases of languages like C++, i will exclude lines consisting of just { or } and the newline at the end of the file (which some compilers require)

Author:  md [ Wed Sep 13, 2006 8:52 pm ]
Post subject: 

what about something like
c++:
#include <iostream>
#include <string>
int main(int argc, char** argv) { std::string name; std::out << "What is your name? "; std::cin >> name; std::cout << "Hello " << name << " welcome to the world!"; return 0; }


That's only one line; but more then one statment of code. And do the includes count? I'm seeing many a problem here... Razz

Author:  NikG [ Wed Sep 13, 2006 9:30 pm ]
Post subject: 

Plus what about something like visual basic...
seems like it could win the "graphically appealing" category with the fewest lines...

Author:  Clayton [ Thu Sep 14, 2006 10:29 am ]
Post subject: 

okay guys, read it over againg, there are prizes for each language submitted, including the special prizes, Cornflake, i dont know, if there tends are enough people that want the include line exluced then no they wont be counted
[edit]code will be required to be in good form ie, none of what md did Wink[/edit]

Author:  richcash [ Thu Sep 14, 2006 6:04 pm ]
Post subject: 

Good idea, this might be fun, but marking will be tough.

My main question is can we submit more than one program from the same language and our best program qualifies, or is it just one per language?

Also some advice, make it more like 10 bits for the first one submitted, unless there have already been submissions. Also, make the rewards for the best 4 or 5 programs from non-mods (but mods should still be able to participate), because mods can't even use the bits!

And one more thing, in Turing when code is indented, super-long lines are broken up, but technically it could be thought of as one line. Will you count these super-long lines as one line?

Author:  bugzpodder [ Thu Sep 14, 2006 6:12 pm ]
Post subject: 

does bits really matter? you can make bits for just spamming like this.

Author:  [Gandalf] [ Thu Sep 14, 2006 6:21 pm ]
Post subject: 

So says the one with almost 7000 of 'em. Wink

Anyway, just in case no one enters, here's my win by default submission:
code:
loop
    Draw.FillOval(Rand.Int (1, maxx), Rand.Int (1, maxy), 4, 4, Rand.Int (1, 15))
end loop

Fun stuff.

Author:  richcash [ Thu Sep 14, 2006 7:10 pm ]
Post subject: 

Quote:
does bits really matter? you can make bits for just spamming like this.


Bits don't really matter to me, but there will definetely be more people entering the contest if there are bits to be handed out. I can't guarantee I'll enter something, but if I do I don't want to be the first out of five people, I want to be first out of 20+ (especially if any good programmers enter).

@Gandalf : Well, at least he can't penalize you in the length column. Wink

Author:  NikG [ Thu Sep 14, 2006 7:46 pm ]
Post subject: 

[Gandalf] wrote:
Anyway, just in case no one enters, here's my win by default submission:
code:
loop
    Draw.FillOval(Rand.Int (1, maxx), Rand.Int (1, maxy), 4, 4, Rand.Int (1, 15))
end loop
Isn't this program included as a sample with Turing? haha.

Author:  Clayton [ Fri Sep 15, 2006 7:45 am ]
Post subject: 

super-long lines will be counted as one, however, it must be in some sort of proper indenting (ie none of this:

Turing:

var a : string := "Turing!";put skip;put a


it must look the way it would with proper formatting.)

richcash, i will allow only two submissions from one person for any one language (ie you can submit two in turing two in c++ etc etc), however only the one of yours that scores best will count.

[Gandalf]: hmmm, 10 bits for that "excellent" entry?

Author:  richcash [ Fri Sep 15, 2006 3:59 pm ]
Post subject: 

Quote:
super-long lines will be counted as one

That's good.

Quote:
none of this

code:
var a : string := "Turing!";put skip;put a

lol, well obviously not, then any program (no matter how sophisticated) could be made in one line (and you don't even need those semi-colons!).

Author:  wtd [ Fri Sep 15, 2006 4:32 pm ]
Post subject: 

How about a traditional 80 column limit? That is, you can put multiple statements/expressions on a single line, but no line may exceed 80 columns.

Author:  richcash [ Fri Sep 15, 2006 4:44 pm ]
Post subject: 

I don't mind a column limit, but 80 is really low. Especially when you space it out and indent. For example, [Gandalf]'s middle line (for a lack of a better example) is 83 columns (including indenting and spaces). So I think maybe the 80 could be increased by a little (I mean a lot).

[edit] oh, now that I've read it closer, I see what wtd means. You can put anything you want on a line (improper indentation) as long as it's less than 80 columns.

That's a good idea, then you could have var, get, and put all on the same line and it still wouldn't take up much space on the line. So, everyone's program would be the same length : 20 lines x 80 columns.

That would make this a completely different contest, though, so I wonder if Freakman would want that [/edit]

Author:  [Gandalf] [ Fri Sep 15, 2006 5:47 pm ]
Post subject: 

Heh, glad my program is getting all this attention. Although I most certainly didn't plagiarize it from those trusty Turing help files... It's purely original coding.

The problem I see with the 80 column limit is that the code will become even more obfusciated than it would with just a line limit.
code:
fcn f(n:int):int if n<=1then result 1 else result n*f(n-1)end if end f put f(4)

Code like that (and worse) is not good for the eyes...

Does 80 columns seem like too few now?

Author:  Clayton [ Fri Sep 15, 2006 5:54 pm ]
Post subject: 

an 80 column limit sounds good, if you have only one statement on the line however (eg for an if statement) i think it should be allowed to break the 80 column limit, i have already recieved a perfectly viable entry from Wolf_Destiny which is in actuality 18 lines

Author:  richcash [ Fri Sep 15, 2006 6:15 pm ]
Post subject: 

Yeah, so since there is already a submission, let's keep the limit off. However, this seems like an ok idea for a future contest. I can imagine how bad it would get, especially in the above line from [Gandalf] with no spaces (to save even more room). But then I guess the marker of the program could first check if it meets the requirements (20 x 80) and indent it afterwards to actually read it!

regarding [Gandalf] : I agree that that's not plagiarism. That's like saying put "a" is plagiarism because someone has done it before. If it's from your own head it's not plagiarism as far as I can see (even if the Turing help files do have the same one, not sure!). Although this random colour circle program is silly to argue over [and NikG was joking!], it could be an issue for other complicated programs.

Author:  [Gandalf] [ Fri Sep 15, 2006 6:25 pm ]
Post subject: 

Yeah. Since you didn't seem to notice, I was being a little sarcastic. Surprised

Author:  richcash [ Fri Sep 15, 2006 6:53 pm ]
Post subject: 

Yeah, lol Laughing , I know nothing about that was serious if I failed to express this (that's what I get for trying to over-explain things over the internet!)
I am no longer referring to [Gandalf]'s program.
What I was trying to say was that if you learn something from someone else and use it in a different context, that's not plagiarism. For example, I'm sure there will be people using the famous method that involves this function (something like this) :
code:
fcn equalize (cond : boolean, var a : int, b : int) : boolean
     if cond then
          a := b
     end if
     result false
end equalize

because the function can be used for almost anything simple and you can call it as many times as you want with exit when on the same line (and it will never exit because it's always false!).

I believe this was first introduced by Catalyst, in the old contest : http://www.compsci.ca/v2/viewtopic.php?t=5539&start=0. In my opinion it's ok to use this if you understand what it means and you don't make a pong game with it. I'm not sure if you give credit in a situation like this, because it can easily be seen how it works and you can make it yourself in a different context. That was the point I was trying to bring up.

Author:  Clayton [ Sun Sep 17, 2006 8:13 pm ]
Post subject: 

alright guys, screenshots will be posted of submitted entries, so here you go:

By: Wolf_Destiny

Posted Image, might have been reduced in size. Click Image to view fullscreen.

now get to coding Very Happy

Author:  zylum [ Sun Sep 17, 2006 11:54 pm ]
Post subject: 

why dont people just post their code here like in the last one? that made it funner and more competative.. for me atleast Wink

Author:  Clayton [ Mon Sep 18, 2006 12:51 pm ]
Post subject: 

if you wish to post your source thats fine, if not just PM it Surprised

Author:  Clayton [ Wed Sep 20, 2006 4:58 pm ]
Post subject: 

alright guys, lets get some more entries, i now have 3 turing entries and one VB entry, keep em coming, post your source up here if you feel like it Razz

Author:  [Gandalf] [ Wed Sep 20, 2006 6:21 pm ]
Post subject: 

Fine, I present Gandalf's Attempt at Trippy Graphics in 17 Lines in Turing:
code:
/* Gandalf's Attempt at Trippy Graphics in 17 Lines in Turing */
var a, b1x, b1y : array 1 .. 10 of int := init (36, 36 * 2, 36 * 3, 36 * 4, 36 * 5, 36 * 6, 36 * 7, 36 * 8, 36 * 9, 36 * 10)
var h, mh, od, ib, acc : int := 300
fcn cc (c : boolean, var b : int, a : int) : boolean
    if c then
        b := a
    end if
    result false
end cc
setscreen ("graphics:550;550,nobuttonbar")
loop
    exit when cc (od = 300, od, -1) | cc (acc = 300, acc, 0) | cc (ib = 300, ib, 10)| cc (h > mh| h < -mh, od, -od) | cc (h > mh| h < -mh, acc, acc + 1) | cc ((h > mh| h < -mh) & acc > 8, ib, -ib)
    for i : 1 .. upper (a)
        exit when cc (true, b1x (i), round (cosd (a (i)) * h))| cc (true, b1y (i), round (sind (a (i)) * h))| cc (true, a (i), a (i) + ib) | cc (true, h, h + od)| cc (a (i) = 360, a (i), 72 * i)
        Draw.FillOval (b1x (i) + maxx div 2, b1y (i) + maxy div 2, 10, 10, round (Math.Distance (b1x (i), b1y (i), maxx div 2, maxy div 2) / 10) + 16)
    end for
    Time.DelaySinceLast (18)
end loop

Razz

Author:  Clayton [ Wed Sep 20, 2006 6:44 pm ]
Post subject: 

very nice [Gandalf] Razz

i have to ask, what is the purpose of the parameter 'c' in the cc function? if it is always true, why not just have a:=b no matter what?

Author:  [Gandalf] [ Wed Sep 20, 2006 6:49 pm ]
Post subject: 

It's not always true. Smile

Author:  zylum [ Wed Sep 20, 2006 9:32 pm ]
Post subject: 

3d with shading and z-sorting in 18 (somewhat long) lines...

[edit] 16 lines now and some of the longer lines have been reduced a bit [/edit]

code:
setscreen ("offscreenonly,graphics:400;400,nobuttonbar,title:zylum3Dv3")
var x, y : array 1 .. 4 of int
var c : array 1 .. 78 of real := init (-1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, - 1, -1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0)
for a : 0 .. maxint
    for i : 0 .. 60 by 12
        for j : 0 .. 9 by 3
            c (74 + j div 3) := ((cosd (a / 9) * sind (a / 8) * cosd (a / 7) + sind (a / 9) * sind (a / 7)) * c (i + j + 1) - c (i + j + 2) * sind (a / 9) * cosd (a / 7) + c (i + j + 3) * cosd (a / 9) * cosd (a / 8) + c (i + j + 2) * cosd (a / 9) * sind (a / 8) * sind (a / 7))
            x (j div 3 + 1) := round ((cosd (a / 8) * cosd (a / 7) * c (i + j + 1) + c (i + j + 2) * sind (a / 7) * cosd (a / 8) - c (i + j + 3) * sind (a / 8)) * 100 / (c (74 + j div 3) + 3) + maxx div 2)
            y (j div 3 + 1) := round (((sind (a / 9) * sind (a / 8) * cosd (a / 7) - cosd (a / 9) * sind (a / 7)) * c (i + j + 1) + c (i + j + 2) * cosd (a / 9) * cosd (a / 7) + c (i + j + 3) * sind (a / 9) * cosd (a / 8) + c (i + j + 2) * sind (a / 9) * sind (a / 8) * sind (a / 7)) * 100 / (c (74 + j div 3) + 3) + maxy div 2)
        end for
        c (78) := ((x (4) - x (3)) * (y (2) - y (3)) - (y (4) - y (3)) * (x (2) - x (3))) / (2 * 10186) + 1e-3
        drawfillpolygon (x, y, (c (78) + abs(c (78))) div c (78) * 2, RGB.AddColor (c (78) + 0.25, c (78) + 0.25, c (78) + 0.25))
    end for
    View.Update
    drawfillbox(0, 0, maxx, maxy, 43)
end for

Author:  NikG [ Thu Sep 21, 2006 12:55 am ]
Post subject: 

zylum, that is just plain crazy! AMAZING JOB! +bits

Gandalf, nice effect, but I personally like it better after adding a cls after your Time.DelaySinceLast (18).

Author:  Clayton [ Thu Sep 21, 2006 7:35 am ]
Post subject: 

NikG, zylum's a mod Laughing

zylum, very, very nice, 3d in 18 lines

me likey very much

Author:  md [ Thu Sep 21, 2006 9:57 am ]
Post subject: 

Someone wanna post a screenie of zylum's running program? Those of us lacking turing might be curious too...

Author:  zylum [ Thu Sep 21, 2006 10:55 am ]
Post subject: 

its just a rotating cube Laughing

although you can make it render more complex models, i didnt feel like initializing that array Wink

Author:  War_Caymore [ Thu Sep 21, 2006 1:04 pm ]
Post subject:  my entry to the 20 anything competition

this is going to be noobish, but i'm a noob programmer so i'll give this a shot...

code:
% Anything in 20 lines. By War_Caymore
View.Set ("graphics")
var font : int
var x, y : int := 0
font := Font.New ("sans serif:18:bold")
assert font > 0
Font.Draw ("Whats that?", 240, 200, font, black)
delay (3000)
cls
Font.Draw ("omigod!", 260, 200, font, black)
delay (3000)
loop
    Draw.FillOval (300, 200, x, y, red)
    x := x + 1
    y := y + 1
    exit when x = 600
    delay (10)
end loop


don't blam it too badly... i want to continue programming.

Author:  ZeroPaladn [ Thu Sep 21, 2006 1:24 pm ]
Post subject: 

time for me to step up, brother. hers my lines in 12 lines.

note that the lines are not completely random, nor are they in a set order. it is both. figure it out WarCaymore.

code:
View.Set ("graphics:400;30,nobuttonbar,position:center;center")
var lines : array 1 .. 15 of int := init (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
loop
    lines (1) := Rand.Int (0, 255)
    for o : 2 .. 30 by 2
        Draw.ThickLine (0, o, 400, o, 5, lines (o div 2))
    end for
    for decreasing i : 30 .. 4 by 2
        lines (i div 2) := lines ((i div 2) - 1)
    end for
    delay (50)
end loop

Author:  NikG [ Thu Sep 21, 2006 3:50 pm ]
Post subject: 

Ahh crap, I gave my bits to a mod Embarassed

Well, the contest is getting interesting, so I thought I'd put up something.
Some of you may remember I put up a SMS messenger in the visual basic section. Well it doesn't work anymore, so I'm remaking it.

There's a trick to how it works, Wink it should be obvious to figure out. Here is the 20-line "Lite" version (the actual version needs more than 20 lines).

Couple of things to remember:
  • There's no error trapping in this "lite" version, so plz dont try and mess it up intentionally
  • Once you've sent a message, you have to close and re-open the program to send another one
  • People may get charged when receiving messages. AFAIK, only rogers allows free incoming text messages.

Author:  Clayton [ Thu Sep 21, 2006 3:52 pm ]
Post subject: 

source? heh ill give you the bits you gave him lol

Author:  neufelni [ Fri Sep 22, 2006 4:42 pm ]
Post subject: 

Here is my submission for the contest in exactly 20 lines. It is a a Sierpinski's triangle program also knows as the chaos game program. Enjoy.
code:
View.Set("graphics: max; max, title: Nick's 20 Line Sierpinski's triangle Program")
colorback(7)
cls
var x, y : array 1 .. 4 of int
var num, count, col : int := 0
loop
    if count mod 100000 = 0 or count = 0 then
        for i : 1 .. 4
            x (i) := Rand.Int (1, maxx)
            y (i) := Rand.Int (1, maxy)
        end for
        col := Rand.Int (1, 100)
        cls
    end if
    num := Rand.Int (1, 3)
    x (4) := round ((x (num) + x (4)) / 2)
    y (4) := round ((y (num) + y (4)) / 2)
    Draw.Dot (x (4), y (4), col)
    count += 1
end loop

Author:  NikG [ Fri Sep 22, 2006 11:30 pm ]
Post subject: 

Nick, you're not a mod right?
Good job. +bits

Author:  NikG [ Sat Sep 23, 2006 2:01 am ]
Post subject: 

Here's my turing submission, a casino-style slot machine:
code:
var Slots : array 1 .. 9 of int := init (35, 64, 37, 42, 36, 1, 2, 3, 25) %array 1-5: slot pics (#@%*$), 6-8: pic location on reel, 9: start money
loop
    Slots (9) -= 1 %insert money
    for i : 1 .. 3 %have to press a key to stop each reel
        loop
            exit when hasch %"pull lever" on slot machine
            for j : i .. 3
                Slots (5 + j) += 1 + 5 * min (0, 4 - Slots (5 + j)) %formula: repeating 1..5
            end for
            put chr (Slots (Slots (6))) : 3, chr (Slots (Slots (7))) : 3, chr (Slots (Slots (8))) : 3, " " : 3, "Money: ", Slots (9)
            delay (150)
            cls
        end loop
        Input.Flush
    end for
    if Slots (6) = Slots (7) and Slots (6) = Slots (8) then %all 3 reels the same
        Slots (9) += 10 * Slots (6) %###=10, @@@=20... $$$=50
    end if
    exit when Slots (9) = 0 %money done :(
end loop
Press any key to stop each reel.

I hate using one array for all the variables, but it was the only was to get down to 20 lines. If anyone wants to see a "clean" version, let me know.

Author:  Silent Avenger [ Sat Sep 23, 2006 7:21 pm ]
Post subject: 

I've made another VB program for the contest (too bad you can only enter 2 per language). It's a Picture Viewer and yes I know it has the same name as the Quicktime program but I'm not very creative with words. This will let you view thumbnails of just about any picture. Oh and Freakman I've sent you the source code in a pm.

Author:  apomb [ Mon Sep 25, 2006 12:13 am ]
Post subject: 

NickG: That is one addicting game you got there! Razz the stars are the funnest to try and get... +bits for sure ... its entertaining.

Author:  NikG [ Mon Sep 25, 2006 1:09 pm ]
Post subject: 

CompWiz333 wrote:
NickG: That is one addicting game you got there! Razz the stars are the funnest to try and get... +bits for sure ... its entertaining.
Thanks CompWiz333.
Addicting? uh-oh... I hope my game doesn't lead you to real gambling... hahaha

Also, sure the stars are fun, but the "$" is where the real money is at!

Author:  ZeroPaladn [ Mon Sep 25, 2006 1:15 pm ]
Post subject: 

lol, CompWiz333 is right. It is addicting. Too bad it is hard as hell.

Author:  War_Caymore [ Mon Sep 25, 2006 1:22 pm ]
Post subject: 

here is my second try at this. i hope this is looking like a little less noobish. i ahve to thank the Turing refrence book that one of my teachers have.

code:
% The Line Noise Maker
% War_Caymore
View.Set ("graphics:225;532,title:Line Noise Maker,position:center;center,nobuttonbar")
var x, y : int := 0
var dx, dy : int := 1
loop
    if View.WhatDotColor (x, y) not= 0 then
        Music.Sound (400, 50)
    end if
    Draw.Dot (x, y, 1)
    x := x + dx
    y := y + dy
    if x = 0 or x = maxx then
        dx := -dx
    end if
    if y = 0 or y = maxy then
        dy := -dy
    end if
    Time.Delay (2)
end loop


I hope you like it. BTW, don't turn up your volume to much, it's really annoying after about half a minute or so.

Author:  ZeroPaladn [ Mon Sep 25, 2006 1:40 pm ]
Post subject: 

lol, bro, i think thre is a rule against something that annoying. a rule of thumb for posting a program like that.

run it
listen or watch it for 2 mins
if you still think its cool, then post it.

either way, bravo bro!

Author:  Artimes [ Thu Sep 28, 2006 10:17 pm ]
Post subject: 

Well seeing as I don't expect mine to win over the 3D renderer... I'll post mine for kicks. Click and hold the mouse, watch the balls accelerate towards the pointer!!

Velocty 19
code:
View.Set ("graphics:500;500,offscreenonly,nobuttonbar")
var x, y, vx, vy : array 1 .. 15 of real := init (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
var mx, my, mb : int
loop
    Mouse.Where (mx, my, mb)
    Draw.FillBox (0, 0, maxx, maxy, 7)
    for i : 1 .. 15
        if (mb = 1) then
            vx (i) += (mx - x (i)) / abs (mx - x (i)) * (16 - i) * 0.005
            vy (i) += (my - y (i)) / abs (my - y (i)) * (16 - i) * 0.005
        end if
        x (i) += vx (i)
        y (i) += vy (i)
        Draw.FillOval (round (x (i)), round (y (i)), (i + 5) div 2, (i + 5) div 2, i + 60)
    end for
    Time.Delay (10)
    View.Update
end loop

Author:  BenLi [ Fri Sep 29, 2006 7:58 am ]
Post subject: 

two lines worth adding to this program

code:

assert abs (mx - x (i)) * (16 - i) * 0.005 not= 0
assert abs (my - y (i)) * (16 - i) * 0.005 not= 0

Author:  md [ Fri Sep 29, 2006 10:33 am ]
Post subject: 

BenLi wrote:
two lines worth adding to this program

code:

assert abs (mx - x (i)) * (16 - i) * 0.005 not= 0
assert abs (my - y (i)) * (16 - i) * 0.005 not= 0


You are assuming Turing follows bedmas... it might just do in-order evaluation. If it does follow bedmas it'd be better to add those conditions as if statements... were it C++ you could do
c++:
vx[i] += abs(mx - x[i]) * (16 - i) != 0 ? (mx - x[i]) / abs(mx - x[i]) * (16 - i) * 0.005 : 0


Oh, and proper formating of code is nice... func() as opposed to func () Wink

Author:  ZeroPaladn [ Fri Sep 29, 2006 11:45 am ]
Post subject: 

That is amazing Cornflake! Yours is interactive, so it could stand a chance at beating Zylum's 3D Rendering program. (a very slight chance, but a chance nontheless)

+20 bits to Cornflake

Author:  [Gandalf] [ Fri Sep 29, 2006 3:30 pm ]
Post subject: 

Cornflake wrote:
Oh, and proper formating of code is nice... func() as opposed to func () Wink

Turing convention is func (). Rolling Eyes

Author:  Silent Avenger [ Fri Sep 29, 2006 10:16 pm ]
Post subject: 

Hey Freakman, just out of curiosity how many enteries do you have now for this contest?

Author:  md [ Fri Sep 29, 2006 11:36 pm ]
Post subject: 

ZeroPaladn wrote:
That is amazing Cornflake! Yours is interactive, so it could stand a chance at beating Zylum's 3D Rendering program. (a very slight chance, but a chance nontheless)

+20 bits to Cornflake


Wha?

Author:  md [ Sun Oct 01, 2006 6:55 pm ]
Post subject: 

System performance measure, really not very useful at all Razz

My workstation: 30864197.5308642JHz
My server: 8646031.471554557JHz

** Note, standard SI rules apply, so my workstation is really 30.8MJHz

jibahertz.cpp
c++:
#include <ctime>
#include <iostream>
#include <pthread.h>
void* RunJiba(void*) {
        int i, i_op; double f_op;
        for( i = 0; i < 500000000U; i++) {      // one jiba
                f_op = (f_op + 0x16680339) / 0x29979245;
                i_op = (i_op + 0x31415926) / 0x27182818;    }
}
int main(int argc, char **argv) {
    std::clock_t tstart, tend;
    int ret; pthread_t thread1, thread2;
    tstart = clock();
    ret = pthread_create(&thread1, NULL, RunJiba, NULL) + pthread_create(&thread2, NULL, RunJiba, NULL);
    pthread_join(thread1, NULL);
    pthread_join(thread2, NULL);
    tend = clock();
    double jibahertz = 1000000000U / (((tend-tstart) * 1.0) / CLOCKS_PER_SEC);
    std::cout.precision(16);  std::cout << jibahertz << "JHz" << std::endl;
}


compile and run with
code:
g++ jibahertz.cpp -lpthread -o jbhz && ./jbhz


[edit] changed the code to a pthreaded version... it should make things more accurate for dual-core/hyperthreading machines. At least in that it should use both cores atthe same time...

Author:  [Gandalf] [ Sun Oct 01, 2006 7:00 pm ]
Post subject: 

The Jibahertz name is © 2006 [Gandalf] though. Wink

My normal Jibahertz: 33967392
My uber computer Jibahertz: 76219512

Anyway, my vote is an even split between my flying circles and md's amazing creation.

*edit* Phew... Updated!

Author:  apomb [ Mon Oct 02, 2006 7:31 am ]
Post subject: 

54MJhz here ... seems this test runs well on Athlon64s Wink cool little deal cornflake, i cant get it to run in VC++ here at school though. pthreads not included in the libraries i guess Confused

Author:  md [ Mon Oct 02, 2006 12:52 pm ]
Post subject: 

you'd need to get teh win32 pthread library manually. Windows implements it's own threading API; and it's much more complex, no way it'd fit in 20 lines.

Author:  Clayton [ Sat Oct 07, 2006 4:47 pm ]
Post subject: 

One week left guys, get those submissions in!

(Could a mod lock this afterwards, as im going to be away on the 13th and wont be back till the 17th)

Author:  apomb [ Sat Oct 07, 2006 6:43 pm ]
Post subject: 

68HC11:
                       ORG   $1
                        MYSTRING           FCC    'HI HOW ARE YOU DOING?'
                        L                        EQU    *-MYSTRING-1
                        SWAP                  RMB    1
                        LOOP1                LDX     #MYSTRING
                                                  LDY     #L
                                                  CLR     SWAP
                        LOOP2                 LDD     0,X
                                                  CBA
                                                  BLS     R1
                                                  STAB   0,X
                                                  STAA   1,X
                                                  INC      SWAP
                         R1                      INX
                                                  DEY
                                                  BNE    LOOP2
                                                  LDAA   SWAP
                                                  BNE    LOOP1
                                                  BRA    *   

yeah, i know its not all graphics oriented, but it does sort the array for you ... IN MEMORY

Author:  md [ Sat Oct 07, 2006 7:17 pm ]
Post subject: 

If we're going to do assembly we might as well jsut go all the way to Corewars Wink

Author:  Clayton [ Wed Oct 11, 2006 6:46 pm ]
Post subject: 

Two days left guys, Get those submissions in, contest closes 11:59pm October 13th

Author:  Tony [ Wed Oct 11, 2006 8:11 pm ]
Post subject: 

not mine, but rather interesting

GPS + Google Maps Mashup in 42 lines of code

actually when you take out the comments, it's more like 27. At the expence of redability and some error proofing (or making and going with assumptions about the user/system), it could be easily cut down to 20.

Author:  ericfourfour [ Wed Oct 11, 2006 8:36 pm ]
Post subject: 

Here is mine:
code:

setscreen ("graphics:max;max")
var x, y, vx, vy, speed, angle, clr : array 0 .. 360 of real
const REVS := 1
const SPEED_MOD := 100
fcn set_value (cond : boolean, var num : real, new_num : real) : boolean
    if cond then
        num := new_num
    end if
    result false
end set_value
for i : 0 .. upper (x)
    exit when set_value (true, x (i), maxx div 2) or set_value (true, y (i), maxy div 2) or set_value (true, speed (i), i / SPEED_MOD) or set_value (true, angle (i), (upper (x) / (360 * REVS)) * i) or set_value (true, vx (i), speed (i) * sind (angle (i))) or set_value (true, vy (i), speed (i) * cosd (angle (i))) or set_value (true, clr (i), (upper (x) / maxcolour) * i)
end for
Draw.FillBox (0, 0, maxx, maxy, black)
loop
    for i : 0 .. upper (x)
        exit when set_value (true, x (i), x (i) + vx (i)) or set_value (true, y (i), y (i) + vy (i)) or set_value (x (i) < 0, vx (i), vx (i) * -1) or set_value (x (i) < 0, x (i), 0) or set_value (y (i) < 0, vy (i), vy (i) * -1) or set_value (y (i) < 0, y (i), 0) or set_value (x (i) > maxx, vx (i), vx (i) * -1) or set_value (x (i) > maxx, x (i), maxx) or set_value (y (i) > maxy, vy (i), vy (i) * -1) or set_value (y (i) > maxy, y (i), maxy)
        Draw.Dot (round (x (i)), round (y (i)), round (clr (i)) rem 255)
    end for
end loop



Mess around with the constants and array size and see what you get. Here are a few I found that looked cool.

code:

size = 3600
REVS = 5
SPEED_MOD = 100

size = 36000 (thirty-six thousand)
REVS = 5
SPEED_MOD = 250

size = 3600
REVS = 1
SPEED_MOD = 100

size = 360
REVS = 10
SPEED_MOD = 100

size = 360
REVS = 10
SPEED_MOD = 100


The one used currently is:

code:

size = 360
REVS = 1
SPEED_MOD = 100

Author:  zylum [ Fri Oct 13, 2006 3:59 pm ]
Post subject: 

some simple turing:

code:
proc tree (x, y, l, sa, ai, n, d, c, t : int, a, b : real)
    var s := - ((n - 1) * ai) / 2
    if d > 0 then
        for i : 1 .. n
            Draw.ThickLine (x, y, round (cosd (sa + s + ai * i * b) * l + x), round (sind (sa + s + ai * i * b) * l + y), t, c)
            tree (round (cosd (sa + s + ai * i * b) * l + x), round (sind (sa + s + ai * i * b) * l + y), l - 20, round (sa + ai * i * a * b), ai, n + 1, d - 1, c, t - 2, a, b)
        end for
    end if
end tree
var mx, my, md : int
View.Set ("offscreenonly,graphics:500;500,nobuttonbar")
loop
    mousewhere (mx, my, md)
    tree (maxx div 2, maxy div 5, 100, 50, 40, 1, 4, 30, 45, (mx * 2 - maxx) / maxx, (my * 2 - maxy) / maxy + 0.5)
    tree (maxx div 2, maxy div 5, 100, 50, 40, 1, 4, 29, 30, (mx * 2 - maxx) / maxx, (my * 2 - maxy) / maxy + 0.5)
    tree (maxx div 2, maxy div 5, 100, 50, 40, 1, 4, 28, 15, (mx * 2 - maxx) / maxx, (my * 2 - maxy) / maxy + 0.5)
    View.Update
    cls
end loop

Author:  War_Caymore [ Fri Oct 13, 2006 4:12 pm ]
Post subject: 

simple. I can't even read it. Then again, i know next to nothing about turing.

Author:  Silent Avenger [ Sat Oct 14, 2006 12:23 am ]
Post subject: 

Isn't someone supposed to lock this so people don't keep entering submissions? I guess it doesn't matter because the time goes with each post.

Author:  Tony [ Sat Oct 14, 2006 1:17 pm ]
Post subject: 

I think Freakman has mentioned being away for a bit, so this thread will be locked until then.


: