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  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Artimes




PostPosted: Thu Sep 28, 2006 10:17 pm   Post subject: (No 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
Sponsor
Sponsor
Sponsor
sponsor
BenLi




PostPosted: Fri Sep 29, 2006 7:58 am   Post subject: (No 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
md




PostPosted: Fri Sep 29, 2006 10:33 am   Post subject: (No 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
ZeroPaladn




PostPosted: Fri Sep 29, 2006 11:45 am   Post subject: (No 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
[Gandalf]




PostPosted: Fri Sep 29, 2006 3:30 pm   Post subject: (No subject)

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

Turing convention is func (). Rolling Eyes
Silent Avenger




PostPosted: Fri Sep 29, 2006 10:16 pm   Post subject: (No subject)

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




PostPosted: Fri Sep 29, 2006 11:36 pm   Post subject: (No 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?
md




PostPosted: Sun Oct 01, 2006 6:55 pm   Post subject: (No 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...
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Sun Oct 01, 2006 7:00 pm   Post subject: (No 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!
apomb




PostPosted: Mon Oct 02, 2006 7:31 am   Post subject: (No 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
md




PostPosted: Mon Oct 02, 2006 12:52 pm   Post subject: (No 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.
Clayton




PostPosted: Sat Oct 07, 2006 4:47 pm   Post subject: (No 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)
apomb




PostPosted: Sat Oct 07, 2006 6:43 pm   Post subject: (No 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
md




PostPosted: Sat Oct 07, 2006 7:17 pm   Post subject: (No subject)

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




PostPosted: Wed Oct 11, 2006 6:46 pm   Post subject: (No subject)

Two days left guys, Get those submissions in, contest closes 11:59pm October 13th
Display posts from previous:   
   Index -> Contests
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

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


Style:  
Search: