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

Username:   Password: 
 RegisterRegister   
 The 20line or less weekly contest!
Index -> Programming, Turing -> Turing Submissions
Goto page Previous  1, 2, 3, 4, 5, 6  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
copthesaint




PostPosted: Wed Apr 01, 2009 5:08 pm   Post subject: RE:The 20line or less weekly contest!

Umm What are you two talking about... This is Kinda off topic don't you think...
Sponsor
Sponsor
Sponsor
sponsor
saltpro15




PostPosted: Wed Apr 01, 2009 5:28 pm   Post subject: RE:The 20line or less weekly contest!

Yes it is, my bad. I should get cracking on a real submission
Zren




PostPosted: Wed Apr 01, 2009 8:08 pm   Post subject: Re: The 20line or less weekly contest!

copthesaint @ Wed Apr 01, 2009 12:15 pm wrote:
Here is a 19 line program that will take a string and split up the values inbetween each space.
This is usefull for online programs and loading txt files.

Turing:
var First, Last, NextValue : int
var Words : array 1 .. 10000 of string
procedure GetStrings (S : string)
    First := 1
    NextValue := 0
    for i : 1 .. length (S)
        if S (i) = " " then
            Last := i - 1
            NextValue += 1
            Words (NextValue) := ""
            for s : First .. Last
                Words (NextValue) += S (s)
            end for
            First := i + 1
        end if
    end for
end GetStrings
GetStrings ("Enter any string and the program will split it and give the number of words")


Your program doesn't catch the last word into the array without having a trailing space. Just pointing that out dude. Good try though.
SNIPERDUDE




PostPosted: Wed Apr 01, 2009 10:56 pm   Post subject: RE:The 20line or less weekly contest!

do note the difficulty it would be to add error checking with such limited room. Although just to make it work in this case have the function just add one to the output number.
BBPProductions




PostPosted: Thu Jun 04, 2009 9:42 am   Post subject: RE:The 20line or less weekly contest!

I relly liked the sphere!
stas054




PostPosted: Sat Jun 13, 2009 7:58 pm   Post subject: RE:The 20line or less weekly contest!

var pie:string:="I <3 pie"
put pie
stas054




PostPosted: Sat Jun 13, 2009 8:03 pm   Post subject: Re: The 20line or less weekly contest!

The_Bean @ Thu Mar 05, 2009 6:47 pm wrote:
Did someone say 3D?
Turing:

View.Set ("graphics:500,500,offscreenonly")
var xm, ym, bm : int
loop
    Mouse.Where (xm, ym, bm)
    cls
    for x : -18 .. 18
        for y : -18 .. 18
            Draw.FillOval(round(200*cosd(x*10)*sind(y*10)*cosd(xm)+200*cosd(y*10)*sind(xm))+maxx div 2,round(200*sind(x*10)*sind(y*10)*cosd(ym)+(200*cosd(y*10)*cosd(xm)-200*cosd(x*10)*sind(y*10)*sind(xm))*sind(ym))+maxy div 2,1,1,7)
        end for
    end for
    View.Update
end loop

A sphere rotating with your mouse in 12 lines.
The formula can be changed to incorporate any 3D formula, although they may not turn out that great being as it is just dots.


suggestion: making it white on the black background would look better Razz
Carey




PostPosted: Tue Aug 25, 2009 6:17 pm   Post subject: Re: The 20line or less weekly contest!

Turing:

View.Set ("graphics:500,500,offscreenonly")
var xm, ym, bm : int
loop
    Mouse.Where (xm, ym, bm)
    Draw.FillBox (0, 0, 500, 500, 7)
    for x : -18 .. 18
        for y : -18 .. 18
            Draw.FillOval (round (200 * cosd (x * 10) * sind (y * 10) * cosd (xm) + 200 * cosd (y * 10) * sind (xm)) + maxx div 2, round (200 * sind (x * 10) * sind (y * 10) * cosd (ym) + (200 * cosd (y * 10) * cosd (xm) - 200 * cosd (x * 10) * sind (y * 10) * sind (xm)) * sind (ym)) + maxy div 2, 1, 1, 0)
        end for
    end for
    View.Update
end loop


Like that?
Sponsor
Sponsor
Sponsor
sponsor
Magix




PostPosted: Sun Oct 25, 2009 3:57 pm   Post subject: [SUBMISSION] Image 2 Source Convertor

A new submission:

Note: This is note my code. I found it somewhere on this forum, and all I did was compress it from 42 lines of code to 18 lines of code, while still following proper coding etiquette. I take no credit for this, I just think that it is very worthy of winning an award on this contest.

Anyways, it is an image-to-source convertor that can take any image and convert it to a turing file using the Draw.Dot command. Its rather awesome, considering its only 18 lines of code. Here it is...

code:
var image, stream : int
var filename : string
    cls
    put "Enter the image file location: " ..
    get filename : *
View.Set ("graphics:" + intstr (Pic.Width (image)) + "," + intstr (Pic.Height (image)) + ",nobuttonbar")
Pic.Draw (image, 0, 0, picCopy)
open : stream, filename + ".t", put
put : stream, "View.Set (\"graphics:" + intstr (Pic.Width (image)) + "," + intstr (Pic.Height (image)) + ",nobuttonbar\")"
for x : 1 .. maxx
    View.Set ("title:Converting..." + intstr (round ((x / maxx * 100))) + "%")
    for y : 1 .. maxy
        if not whatdotcolor (x, y) = white then
            put : stream, "Draw.Dot (" + intstr (x) + ", " + intstr (y) + ", " + intstr (whatdotcolor (x, y)) + ")"
        end if
    end for
end for
close : stream


Just in case you are wondering how I compressed it so much, I removed the code to check if the image exists, and I removed the code to check if the filename of the output file is taken or not. If you are interested, here is the original code...

code:

%State variables
var image : int
var filename : string
var stream : int

%Start of loop
loop
    cls
    put "Enter the image file location: " ..
    get filename : *
    if File.Exists (filename) then
        image := Pic.FileNew (filename)
        exit
    else
        put "The file does not exist. Press any key to try again..."
        Input.Pause
    end if
end loop
%End of loop

%"If the image exists...
if File.Exists (filename + ".t") then
    put "When converting your image to a Turing source file, the file " + filename + ".t will be overwritten."
    put "Press any key to continue..."
    Input.Pause
end if
%End of "If" statement

View.Set ("graphics:" + intstr (Pic.Width (image)) + "," + intstr (Pic.Height (image)) + ",nobuttonbar")
Pic.Draw (image, 0, 0, picCopy)
open : stream, filename + ".t", put
put : stream, "View.Set (\"graphics:" + intstr (Pic.Width (image)) + "," + intstr (Pic.Height (image)) + ",nobuttonbar\")"
for x : 1 .. maxx
    View.Set ("title:Converting..." + intstr (round ((x / maxx * 100))) + "%")
    for y : 1 .. maxy
        if not whatdotcolor (x, y) = white then
            put : stream, "Draw.Dot (" + intstr (x) + ", " + intstr (y) + ", " + intstr (whatdotcolor (x, y)) + ")"
        end if
    end for
end for
close : stream


To make this work, put enter the image location when prompted for it. If it is in the same directory as the Turing Code, just type in the filename with the extension. Example: filename.jpg.
If it is the a different directory, use /, ./ and ../ commands to show this. This image only recognizes BMP and JPG images.

I attached a sample of what this program can do.



Blue Vampire.rar
 Description:
This was created with the program above.

Download
 Filename:  Blue Vampire.rar
 Filesize:  799.6 KB
 Downloaded:  716 Time(s)

A.J




PostPosted: Sun Oct 25, 2009 6:16 pm   Post subject: RE:The 20line or less weekly contest!

You are missing something...

add the following line after getting the filename:
Turing:

image := Pic.FileNew (filename)
Magix




PostPosted: Sun Oct 25, 2009 6:24 pm   Post subject: RE:The 20line or less weekly contest!

Oh! Sorry I didn't even notice that! Thanks! So the full code would go...

code:
var image, stream : int
var filename : string
    cls
    put "Enter the image file location: " ..
    get filename : *
image := Pic.FileNew (filename)
View.Set ("graphics:" + intstr (Pic.Width (image)) + "," + intstr (Pic.Height (image)) + ",nobuttonbar")
Pic.Draw (image, 0, 0, picCopy)
open : stream, filename + ".t", put
put : stream, "View.Set (\"graphics:" + intstr (Pic.Width (image)) + "," + intstr (Pic.Height (image)) + ",nobuttonbar\")"
for x : 1 .. maxx
    View.Set ("title:Converting..." + intstr (round ((x / maxx * 100))) + "%")
    for y : 1 .. maxy
        if not whatdotcolor (x, y) = white then
            put : stream, "Draw.Dot (" + intstr (x) + ", " + intstr (y) + ", " + intstr (whatdotcolor (x, y)) + ")"
        end if
    end for
end for
close : stream
SNIPERDUDE




PostPosted: Mon Oct 26, 2009 3:58 pm   Post subject: Re: RE:The 20line or less weekly contest!

Magix @ October 25th 2009 wrote:
Oh! Sorry I didn't even notice that! Thanks! So the full code would go...

code:
var image, stream : int
var filename : string
    cls
    put "Enter the image file location: " ..
    get filename : *
image := Pic.FileNew (filename)
View.Set ("graphics:" + intstr (Pic.Width (image)) + "," + intstr (Pic.Height (image)) + ",nobuttonbar")
Pic.Draw (image, 0, 0, picCopy)
open : stream, filename + ".t", put
put : stream, "View.Set (\"graphics:" + intstr (Pic.Width (image)) + "," + intstr (Pic.Height (image)) + ",nobuttonbar\")"
for x : 1 .. maxx
    View.Set ("title:Converting..." + intstr (round ((x / maxx * 100))) + "%")
    for y : 1 .. maxy
        if not whatdotcolor (x, y) = white then
            put : stream, "Draw.Dot (" + intstr (x) + ", " + intstr (y) + ", " + intstr (whatdotcolor (x, y)) + ")"
        end if
    end for
end for
close : stream


I was messing with the code (it would be over 20 lines now), and made it much more efficient by putting some of those repetitive values in for loops. This not only significantly reduced the length of the output file (9.1X on one test, 11.9X on another), but also really sped up the process. I can send you the code if you wish, but this is probably not the right thread.

I was bored really.
petree08




PostPosted: Thu Nov 12, 2009 9:36 am   Post subject: Re: The 20line or less weekly contest!

Here is my Rorschach ink blot generator


code:

var X, Y : int
X := 1
Y := maxy div 2
loop
    X := X + Rand.Int (-2, 2)
    Y := Y + Rand.Int (-2, 2)
    if X < -maxx or X > maxx or Y < 1 or Y > maxy then
        X := 1
        Y := maxy div 2
    end if
    drawfilloval ((maxx div 2) + X, Y, 2, 2, 7)
    drawfilloval ((maxx div 2) - X, Y, 2, 2, 7)
    View.Update
end loop

petree08




PostPosted: Thu Nov 12, 2009 9:45 am   Post subject: RE:The 20line or less weekly contest!

so i don't know if it is an ink blot generator any more but i messed with it more and got this

[code]
var X, Y : int
X := 1
Y := maxy div 2
for C : 1 .. Rand.Int (800, 1700)
X := X + Rand.Int (-1, 1)
Y := Y + Rand.Int (-1, 1)
if X < -maxx or X > maxx or Y < 1 or Y > maxy then
X := 1
Y := maxy div 2
end if
drawdot ((maxx div 2) + X, Y, 7)
drawdot ((maxx div 2) - X, Y, 7)
View.Update
end for

[\code]


i like this one better
mirhagk




PostPosted: Tue Nov 24, 2009 12:25 pm   Post subject: Re: The 20line or less weekly contest!

um so yeah they should have posted a line length limit or else i could just do this

its mona lisa and random special drawing effects in 11 lines of code. (without special effects its 7 lines of code).

no i did not use a picture file at all, it draws it point by point.

Wanna know how i did it, well first i modified the earlier picture to turing code into the following

code:

var image, stream : int
var filename : string
cls
put "Enter the image file location: " ..
get filename : *
image := Pic.FileNew (filename)
View.Set ("graphics:" + intstr (Pic.Width (image)) + "," + intstr (Pic.Height (image)) + ",nobuttonbar")
Pic.Draw (image, 0, 0, picCopy)
open : stream, filename + ".t", put
put : stream, "View.Set (\"graphics:" + intstr (Pic.Width (image)) + "," + intstr (Pic.Height (image)) + ",nobuttonbar\")"
put : stream, "var pic:array 1.." + intstr (Pic.Width (image)) + ",1.." + intstr (Pic.Height (image)) + " of int:=init(" ..
for x : 1 .. Pic.Width (image)
    View.Set ("title:Converting..." + intstr (round ((x / maxx * 100))) + "%")
    for y : 1 .. Pic.Height (image)
        put : stream, intstr (whatdotcolor (x, y)) + "," ..
    end for
end for
put : stream, ")\nfor x:1.." + intstr (Pic.Width (image)) + "\n\tfor y:1.." + intstr (Pic.Height (image)) + "\n\t\t" ..
put : stream, "Draw.Dot(x,y,pic(x,y))\n\tend for\nend for"
close : stream


instead of thousands of Draw.Dot commands (and close to a million kb for some pictures) it creates an array of all the points to store a colour variable, then it adds the code to use a for loop and draw the picture using the array.

then i opened the created 7 line program and proceeded to add the special effects.
try it out, and you can create your own programs like this using the above code (which still qualifies for the 20 lines or less btw)



monalisa.jpg.t
 Description:
11 lines of code, and the special effects are actually pretty good looking... like almost photoshop-ish

Download
 Filename:  monalisa.jpg.t
 Filesize:  685.34 KB
 Downloaded:  178 Time(s)

Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

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


Style:  
Search: