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

Username:   Password: 
 RegisterRegister   
 Turing Contest 255chr max - changed to 20 line max
Index -> Contests
Goto page 1, 2, 3, 4, 5  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

And the winner is :
(Voting is closed)
not buzpodder's graphics
28%
 28%  [ 2 ]
zylum's graphics
0%
 0%  [ 0 ]
catalyst's graphics
0%
 0%  [ 0 ]
GlobeTrotter's graphics
0%
 0%  [ 0 ]
beard0's graphics
0%
 0%  [ 0 ]
Delos's Blackjack
14%
 14%  [ 1 ]
zylum's graphics (2)
0%
 0%  [ 0 ]
beard0's TicTacToe
28%
 28%  [ 2 ]
Delos's Flashy Pong
0%
 0%  [ 0 ]
zylum's green screen
14%
 14%  [ 1 ]
Catalyst's Pong
0%
 0%  [ 0 ]
Tony's Snake
14%
 14%  [ 1 ]
TheFerret's graphics
0%
 0%  [ 0 ]
Total Votes : 7

Author Message
beard0




PostPosted: Sun Jun 20, 2004 4:47 pm   Post subject: Turing Contest 255chr max - changed to 20 line max

Make the program that is voted "best" in 255 chars or less in Turing - white space not included in character count, so format it nicely.

Voting criteria will be purely up to the voter - whichever program they feel deserves the credit. Very Happy

Contest will close July 10th.
Sponsor
Sponsor
Sponsor
sponsor
zylum




PostPosted: Sun Jun 20, 2004 5:44 pm   Post subject: (No subject)

IMO it shouldnt be characters because then ppl will use var names like a b c etc... it should be either the size of the stand alone or the line count...

i say it should be up to 20 lines...
Tony




PostPosted: Sun Jun 20, 2004 6:07 pm   Post subject: (No subject)

i'm in favour of 20 line rule
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
beard0




PostPosted: Sun Jun 20, 2004 7:31 pm   Post subject: (No subject)

20 lines, after F2 is hit, it is then.
bugzpodder




PostPosted: Sun Jun 20, 2004 8:13 pm   Post subject: (No subject)

I did not make this
but this is so cool i decided it to cut it down to twenty lines (it was like forty) again, i take no credit for the original code

code:

var win1 : int := Window.Open ("graphics:500;500,noecho,nocursor")
var x, y, c, r : real := 250
loop
    for decreasing center : 250 .. -50 by 50
        r := 0
        for q : 1 .. 5
            for i : 1 .. 50000
                r += .001
                c := round ((x + round (((q - 1) * 50000 + i - 1) * .001 + cos (i) * r) + y + round (((q - 1) * 50000 + i - 1) * .001 + sin (i) * r)) / 40 + 40 + cos (round (((q - 1) * 50000 + i
                    - 1) * .001 + cos (i) * r)) + sin (round (((q - 1) * 50000 + i - 1) * .001 + sin (i) * r)) + q * 2)
                x := round (center + ((q - 1) * 50000 + i - 1) * .001 + cos (i) * r)
                y := round (center + ((q - 1) * 50000 + i - 1) * .001 + sin (i) * r)
                drawdot (round (x), round (y), round (c))
                drawdot (round (500 - x), round (y), round (c))
                drawdot (round (x), round (500 - y), round (c))
                drawdot (round (500 - x), round (500 - y), round (c))
            end for
        end for
    end for
end loop
Paul




PostPosted: Sun Jun 20, 2004 9:05 pm   Post subject: (No subject)

Nice Very Happy Now, is that just a cool visual effect or does it have some significance that I don't know about?
zylum




PostPosted: Mon Jun 21, 2004 12:30 pm   Post subject: (No subject)

wow, that's really cool. you guys remember the one me, catalyst, jonos and paulbian had? well jonos and paulbian didnt submit so i guess it was just me and catalyst....

mine:

code:
setscreen ("graphics:220;140,offscreenonly")
const size := ceil (sqrt (2 * 220 ** 2))
var clr : array 1 .. size of int
for i : 1 .. size
    clr (i) := RGB.AddColor (i / (size * 2), i / (size * 2) + 0.35, 1)
end for
var wave : array 1 .. size div 2 of real
for i : 1 .. size div 2
    wave (i) := i / 5
end for
var c : int
drawfillbox (0, 0, maxx, maxy, clr (upper (clr) div 2))
loop
    for decreasing i : size div 2 .. 1
        wave (i) -= 0.7
        c := ceil ((sin (wave (i)) * (abs (size - i * 2.3)) / 3 + (size div 2)))
        drawfilloval (maxx div 2, round (maxy / 2 + c / 20) - 8, i, i div 2, clr (c))
    end for
    View.Update
end loop


catalysts: (bit of a rip off but still cool)

code:
setscreen ("graphics:300;300,offscreenonly")
var vals : array 1 .. 150 of real
proc ColorSet (c1, c2, n : int)
    var r1, g1, b1, r2, g2, b2, p, p0, clr : real
    RGB.GetColor (c1, r1, g1, b1)
    RGB.GetColor (c2, r2, g2, b2)
    for i : 1 .. n
        p := (i / n) * 100
        p0 := 100 - p
        clr := RGB.AddColor ((((r1 * p) + (r2 * p0)) / 2) / 50, (((g1 * p) + (g2 * p0)) / 2) / 50, (((b1 * p) + (b2 * p0)) / 2) / 50)
    end for
end ColorSet
ColorSet (55, 1, 128)
ColorSet (53, 55, 88)
ColorSet (102, 53, 32)
for i : 1 .. 150
    vals (i) := i
end for
drawfillbox (0, 0, maxx, maxy, 7)
loop
    for decreasing i : 150 .. 1
        vals (i) -= 2
        drawfilloval (maxx div 2, 100 - round (sind (vals (i) * 5) * 15), i * 2, i, round (maxcolor - ((sind (vals (i) * 5) + 1) / 2) * 220))
    end for
    View.Update
end loop


maybe we should make this one have a theme too? maybe fire?
Catalyst




PostPosted: Mon Jun 21, 2004 1:19 pm   Post subject: (No subject)

whee

code:
var s, a, b, c, d, e, f, g, h, j : real := 300
fcn sa (var A : real, C : real) : boolean
    A := C
    result false
end sa
for x : 1 .. round (s * s)
    exit when sa (b, x div s) or sa (a, x - b * s) or sa (d, 3.5 / s * b - 1.75) or sa (c, 3.5 / s * a - 1.75) or sa (g, d) or sa (h, c)
    for i : 1 .. 75
        exit when sa (j, i) or (c - s / 2) ** 2 + (d - s / 2) ** 2 > 230 ** 2 or i > 75 or sa (e, d * d - c * c + g) or sa (f, d * c + c * d + h) or sa (d, e) or sa (c, f)
    end for
    drawdot (round (b), round (a), 15 + round (j / 75 * 15))
end for

Sponsor
Sponsor
Sponsor
sponsor
beard0




PostPosted: Mon Jun 21, 2004 3:23 pm   Post subject: (No subject)

Catalyst:
Nice job with the function so that you could put multiple calls on the same line, good thinking.
GlobeTrotter




PostPosted: Mon Jun 21, 2004 3:35 pm   Post subject: (No subject)

code:

var s, a, b, c, d, e, f, g, h, j := 300.0
fcn k (var A : real, C : real) : boolean
    A := C
    result false
end k
for x : 1 .. round (s * s)
    exit when k (b, x div s) or k (a, x - b * s) or k (d, 3.5 / s * b - 1.75) or k (c, 3.5 / s * a - 1.75) or k (g, d) or k (h, c)
    for i : 1 .. 75
        exit when k (j, i) or (c - s / 2) ** 2 + (d - s / 2) ** 2 > 52900 or i > 75 or k (e, d * d - c * c + g) or k (f, d * c + c * d + h) or k (d, e) or k (c, f)
    end for
    drawdot (round (b), round (a), 15 + round (j * 0.2))
end for

I made yours a bit smaller.
beard0




PostPosted: Wed Jun 23, 2004 7:46 am   Post subject: (No subject)

Here's mine. Didn't know it was going to be as interesting as it was, compressing it into a mere 20 lines. Keep posting more programs!
code:
View.Set ("offscreenonly,nobuttonbar,graphics:400;200,title:Curtains")
var c, t := 0
for i : 1 .. maxcolour
    if i < 85 then
        RGB.SetColour (i, (sign (42.5 - i) + 1) / 2 + (sign (i - 42.5) + 1) / 2 * (1 - (i mod 42.5) / 42.5), (sign (42.5 - i) + 1) / 2 * (i mod 42.5 / 42.5) + (sign (i - 42.5) + 1) / 2, 0)
    elsif i < 170 then
        RGB.SetColour (i, 0, (sign (127.5 - i) + 1) / 2 + (sign (i - 127.5) + 1) / 2 * (1 - (i mod 42.5) / 42.5), (sign (127.5 - i) + 1) / 2 * ((i mod 42.5) / 42.5) + (sign (i - 127.5) + 1) / 2)
    else
        RGB.SetColour (i, (sign (212.5 - i) + 1) / 2 * ((i mod 42.5) / 42.5) + (sign (i - 212.5) + 1) / 2, 0, (sign (212.5 - i) + 1) / 2 + (sign (i - 212.5) + 1) / 2 * (1 - (i mod 42.5) / 42.5))
    end if
end for
loop
    t := (t + 20) mod 600 % adjust the 20 for speed/smoothness (factor of 400)
    for x : 1 .. 200 * 200
        c := round ((abs (300 - t) + 20) * ln (x mod 200 + 2) / ln (x div 200 + 2))
        drawdot (x mod 200, x div 200, max (1, min (c, maxcolour - 1)))
        drawdot (399 - x mod 200, x div 200, max (1, min (c, maxcolour - 1)))
    end for
    View.Update
end loop


/**** This is what my if statements above accomplish, through mathematical "ifs", to save lines:
**** (sign(x-y)+1)/2 is 1 when x>y and 0 when x<y, so by multiplying one by the value I'm trying
**** to achieve in one circumstance, plus the other times the value I want in that circumstance I
**** either get 0*val1+1*val2 or 1*val1+0*val2. By combining these, you can actually specify ranges,
**** so if I had a lot of time on my hands, I *could* have done it without any if statements - but my
**** RGB.SetColour line would have been huge.

if i < 42.5 then
RGB.SetColour (i, 1, i / 42.5, 0)
elsif i < 85 then
RGB.SetColour (i, 1 - (i mod 42.5) / (42.5), 1, 0)

elsif i < 127.5 then
RGB.SetColour (i, 0, 1, (i mod 42.5) / (42.5))
elsif i < 170 then
RGB.SetColour (i, 0, 1 - (i mod 42.5) / (42.5), 1)

elsif i < 212.5 then
RGB.SetColour (i, (i mod 42.5) / 42.5, 0, 1)
else
RGB.SetColour (i, 1, 0, 1 - (i mod 42.5) / 42.5)

end if
*/
Delos




PostPosted: Wed Jun 23, 2004 10:08 pm   Post subject: (No subject)

[demoic laugh]
Ha ha ha ha ha!!!!!
[/demoic laugh]

You all with your graphical impressions!
I present you all with an interactive game!
Ha!
Fully functioning!
20 lines!
Bloody tight coding!
It hurt my head making this.
And I've finished school.
My head shouldn't be hurting for something like this.
But it did.
And it works!

I present to you...BlackJack in 20 Lines!
(Sorry, no nice graphics...I can only do so much in 20 lines!)

code:

var player1, player2 : int := 0
var answer : string (1)
loop
    put "Draw? (y/n)", repeat (".", 10), "You: ", player1, "   Comp: ", player2
    exit when player1 > 21 or player2 > 21
    getch (answer)
    if answer = "y" or answer = "Y" then
        player1 += Rand.Int (1, 10)
        player2 += Rand.Int (1, 10)
    elsif answer = "n" or answer = "N" then
        if player1 > player2 and player1 > 16 then
            put "You Win!"
        else
            put "You lose"
        end if
        player1 := 0
        player2 := 0
    end if
end loop
put "The player with ", max (player1, player2), " points has lost!"



[Muwahahahahahahahaha]

I can just feel it...someone is going to do all of this in like, 12 lines...and totally make me look the fool...meh!
zylum




PostPosted: Wed Jun 23, 2004 11:43 pm   Post subject: (No subject)

im sure some of you have seen me post this before but i shortened it down a bit and made it better too:

code:
var coords : array 1 .. maxx, 1 .. maxy of int
var clrs : array 1 .. 500 of int %change the upper bound to alter smootheness ( > makes smoother)
for i : 1 .. upper (clrs)
    clrs (i) := RGB.AddColor (i / upper (clrs), i / upper (clrs), i / upper (clrs)) %(i,i,i) = b&w, (1,i,i) = red, (0,i,i) = teal etc...
end for
coords (1, 1) := Rand.Int (upper (clrs) div 3, upper (clrs) - upper (clrs) div 3)
for x : 1 .. maxx
    for y : 1 .. maxy
        if x = 1 and y > 1 then
            coords (x, y) := min (upper (clrs), max (1, coords (x, y - 1) + Rand.Int (-5, 5)))
            drawdot (x, y, clrs (coords (x, y)))
        elsif y = 1 and x > 1 then
            coords (x, y) := round (min (upper (clrs), max (1, coords (x - 1, y) + Rand.Int (-5, 5))))
            drawdot (x, y, clrs (coords (x, y)))
        elsif x > 1 and y > 1 then
            coords (x, y) := round (min (upper (clrs), max (1, ((coords (x, y - 1) + coords (x - 1, y - 1)) / 2) + Rand.Int (-5, 5))))
            drawdot (x, y, clrs (coords (x, y)))
        end if
    end for
end for


Wink
beard0




PostPosted: Thu Jun 24, 2004 12:38 pm   Post subject: (No subject)

Delos wrote:
[demoic laugh]
Ha ha ha ha ha!!!!!
[/demoic laugh]

You all with your graphical impressions!
I present you all with an interactive game!

With a challenge like that, I had to rise to it. To counter Delos's "Black Jack" in which the computer only draws when you do, and you even get to see exactly what the computer has, I produce the mouse controlled TicTacToe game, in 20 lines.
Th demonic laugh is now mine Twisted Evil
code:
var x, y, b, ob, count := 0
var whatchar : array - 2 .. 4, -2 .. 4 of char := init (" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ")
put repeat (repeat ("     |     |" + chr (10), 3) + "-----+-----+-----" + chr (10), 2) + repeat ("     |     |" + chr (10), 3),"Welcome to Matt's TicTacToe Game, in 20 lines.",chr(10),"Use the mouse in turns with a friend to play the game.",chr(10),"Enjoy!"
loop
    ob := b
    mousewhere (x, y, b)
    if x < 135 and maxy - y < 180 and b > 0 and ob = 0 and whatdotcolor ((x div 45) * 48 + 18, ((maxy - y) div 60) * -64 + 373) = white then
        count += 1
        locate (((maxy - y) div 60) * 4 + 2, (x div 45) * 6 + 3)
        whatchar (x div 45, (maxy - y) div 60) := chr (ord ("O") + count mod 2 * (ord ("X") - ord ("O")))
        put chr (ord ("O") + count mod 2 * (ord ("X") - ord ("O"))) ..
        exit when (whatchar (x div 45 - 2, (maxy - y) div 60) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45 - 1, (maxy - y) div 60) = whatchar (x div 45, (maxy - y) div 60)) or (whatchar (x div 45 - 1, (maxy - y) div 60) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45 + 1, (maxy - y) div 60) = whatchar (x div 45, (maxy - y) div 60)) or (whatchar (x div 45 + 1, (maxy - y) div 60) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45 + 2, (maxy - y) div 60) = whatchar (x div 45, (maxy - y) div 60)) or (whatchar (x div 45, (maxy - y) div 60 - 2) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45, (maxy - y) div 60 - 1) = whatchar (x div 45, (maxy - y) div 60)) or (whatchar (x div 45, (maxy - y) div 60 - 1) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45, (maxy - y) div 60 + 1) = whatchar (x div 45, (maxy - y) div 60)) or (whatchar (x div 45, (maxy - y) div 60 + 1) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45, (maxy - y) div 60 + 2) = whatchar (x div 45, (maxy - y) div 60)) or (whatchar (x div 45 - 2, (maxy - y) div 60 - 2) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45 - 1, (maxy - y) div 60 - 1) = whatchar (x div 45, (maxy - y) div 60)) or (whatchar (x div 45 - 1, (maxy - y) div 60 - 1) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45 + 1, (maxy - y) div 60 + 1) = whatchar (x div 45, (maxy - y) div 60)) or (whatchar (x div 45 + 1, (maxy - y) div 60 + 1) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45 + 2, (maxy - y) div 60 + 2) = whatchar (x div 45, (maxy - y) div 60)) or (whatchar (x div 45 + 2, (maxy - y) div 60 - 2) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45 + 1, (maxy - y) div 60 - 1) = whatchar (x div 45, (maxy - y) div 60)) or (whatchar (x div 45 + 1, (maxy - y) div 60 - 1) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45 - 1, (maxy - y) div 60 + 1) = whatchar (x div 45, (maxy - y) div 60)) or (whatchar (x div 45 - 1, (maxy - y) div 60 + 1) = whatchar (x div 45, (maxy - y) div 60) and whatchar (x div 45 - 2, (maxy - y) div 60 + 2) = whatchar (x div 45, (maxy - y) div 60))
    end if
    if count = 9 then
        count += 1
        exit
    end if
end loop
locate (12, 1)
put repeat (chr (ord ("O") + count mod 2 * (ord ("X") - ord ("O"))) + "'s win!", 1 - count div 10) + repeat ("Tie game!", count div 10) + repeat (chr (10), 3)

Yes, maybe my "exit when" line is a little long - but it is one line!
Tony




PostPosted: Thu Jun 24, 2004 2:38 pm   Post subject: (No subject)

wow beard0, that's impressive Laughing
+20Bits
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 1 of 5  [ 62 Posts ]
Goto page 1, 2, 3, 4, 5  Next
Jump to:   


Style:  
Search: