Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Best "Anything" in 20 Lines (Choose Your Language)
Index -> Contests
Goto page Previous  1, 2, 3, 4, 5
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tony




PostPosted: Wed Oct 11, 2006 8:11 pm   Post subject: (No 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: Wed Oct 11, 2006 8:36 pm   Post subject: (No 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
zylum




PostPosted: Fri Oct 13, 2006 3:59 pm   Post subject: (No 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
War_Caymore




PostPosted: Fri Oct 13, 2006 4:12 pm   Post subject: (No subject)

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




PostPosted: Sat Oct 14, 2006 12:23 am   Post subject: (No 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.
Tony




PostPosted: Sat Oct 14, 2006 1:17 pm   Post subject: (No subject)

I think Freakman has mentioned being away for a bit, so this thread will be locked until then.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Contests
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 5 of 5  [ 66 Posts ]
Goto page Previous  1, 2, 3, 4, 5
Jump to:   


Style:  
Search: