Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Challenge: Algorithms having only one line of code.
#85
Here's my one-liner:

Draw a circle, without using the CIRCLE command:

Code:
SCREEN 12: h = 200: k = 200: r = 100: c = 13: FOR x = 0 TO INT(r / SQR(2)) + 1: y = SQR(r ^ 2 - x ^ 2): FOR a = -1 TO 1 STEP 2: FOR b = -1 TO 1 STEP 2: PSET (h + x * a, k + y * b), c: PSET (h + y * a, k + x * b), c: NEXT: NEXT: NEXT

draws a circle with center at (h, k), radius r and color c without using the CIRCLE command, or SIN or COS, and just two PSET commands.

It may seems like a long line but it fits inside a QBASIC IDE line of code. ;)

- neuro


[edit]: I see one of the rules is, no compounded lines (with colons)...

Here's another of my favorite algorithms:

purpose: hang the computer uninterruptibly (written in C):

for ( ; ; fork() ) ;

or this one, which goes on and on 4ever... (or just uses up all stack space):

int func(int x) return func(x+1);
ignatures suck
Reply


Messages In This Thread
To Oracle: 2nd look at your code. - by Moneo - 06-24-2003, 09:07 PM
To Seph and Agamemnus: - by Moneo - 06-24-2003, 09:17 PM
factorial. - by Agamemnus - 06-24-2003, 09:51 PM
To Agamemnus - by Moneo - 06-24-2003, 10:21 PM
To na_th_an: - by Moneo - 06-27-2003, 03:15 AM
ok, - by Agamemnus - 06-27-2003, 05:17 PM
To Oracle re Statlib - by Moneo - 06-27-2003, 10:39 PM
Re: To na_th_an: - by na_th_an - 06-28-2003, 01:14 AM
To LooseCaboose: - by Moneo - 06-28-2003, 03:08 AM
Re: To Oracle re Statlib - by oracle - 06-28-2003, 05:50 AM
To Oracle: - by Moneo - 06-29-2003, 03:10 AM
To Ak00ma: - by Moneo - 06-30-2003, 03:39 AM
Power of 2 - by Moneo - 07-02-2003, 02:42 AM
To Antoni: - by Moneo - 07-02-2003, 03:03 AM
197 - by whitetiger0990 - 07-02-2003, 06:29 PM
To na_th_an re "replacement" logic: - by Moneo - 07-02-2003, 08:29 PM
Re ROUNDING using .5: - by Moneo - 07-02-2003, 08:47 PM
Re: Re ROUNDING using .5: - by Moneo - 03-20-2006, 06:19 AM
Challenge: Algorithms having only one line of code. - by Anonymous - 03-29-2006, 10:09 PM
Challenge: Algorithms having only one line of code. - by Anonymous - 03-29-2006, 10:24 PM
Challenge: Algorithms having only one line of code. - by Anonymous - 03-29-2006, 10:52 PM
my one-liner - by neuro - 03-30-2006, 12:08 AM

Forum Jump:


Users browsing this thread: 5 Guest(s)