Code Golf

166 readers
1 users here now

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
1
4
Cyclically Sort a List (codegolf.stackexchange.com)
submitted 11 months ago by [email protected] to c/[email protected]
 
 

Given a list of Integers greater than zero, Sort each of the unique values in ascending order, then repeat the process on the remaining duplicate values and append.

Example:

[1,5,2,2,8,3,5,2,9] ==> [1,2,3,5,8,9,2,5,2]
2
 
 

[the video] [github]

TL/DW: The contest is to submit a C# chess bot in which the code uses a maximum of 1024 tokens. (Every usage of a variable, value, function, and operator, counts as a token)

3
 
 

Write a function that prints an n big tree, e.g. for n=5:

     * 
    * * 
   * * * 
  * * * * 
 * * * * * 
    | |

Here is what I came up with in C:

N,i;a(n){for(i=N=N?N:n+2;i--;printf(i?"* "+(N-n-1<i):--n?"\n":"\n%*s",N,"| |"));n&&a(n);}

// the invocation isn't part of the golf:
main(){a(5);}

PS: Code blocks currently wrap around when they are too long, I've already submitted a patch to make them scroll horizontally instead.

4
 
 

cross-posted from: https://programming.dev/post/24297

u/msage's comment on another post made me remember seeing this a couple of days ago.

From the site:

This seems exactly like the IOCCC but for Python?

This contest is a complete rip-off the IOCCC idea and purpose and rules. If you like this contest, you will almost certainly love the IOCCC. Check it out!