-3
votes
0answers
79 views

Shortest code for Factorial in C\C++ [duplicate]

This contest is language specific Write the shortest program in C\C++ that will take in a number and print its factorial. The factorial is found by multiplying a number by each of the digits that ...
10
votes
14answers
1k views

Golfed+Fast sorting in C

[Latest update: benchmark program and preliminary resuls available, see below] So I want to test the speed/complexity tradeoff with a classic application: sorting. Write an ANSI C function that ...
14
votes
1answer
711 views

Create a C preprocessor

The goal is to create a preprocessor for the C language, as small as possible in terms of source code size in bytes, in your preferred language. Its input will be a C source file, and its output will ...
8
votes
8answers
938 views

Shortest C \ C++ function to generate -1, 0 ,1

Let a function receive two integers i and j between 0 and 3, it should return the value in position (i,j) in the following 2D array: 1, 0, -1, 0 1, 0, -1, 0 0, 1, 0, -1 0, -1, 0, 1 Shortest ...
0
votes
1answer
2k views

Smallest C code to Crash an Operating System? [duplicate]

A shortest C program, that can crash the Operating system, either on a Windows or a Linux PC... Rules: The code is to be developed in C language, but it may use other api, specific to linux or ...
7
votes
1answer
396 views

Implement an IEEE 754 64-bit binary floating point number through integer manipulation

(I've tagged the question "C" for the time being, but if you're aware of another language that supports unions, you can also use that.) Your task is to build the four standard mathematical operators ...
0
votes
1answer
145 views

Shortest conditional to run a specific statement: C code golf

Currently I have the code (expanded for your benefit): <number> != <number> ? printf("|\\"); : <number>; The idea here, is to do this condition in the least number of characters. ...
8
votes
20answers
2k views

print 1 to 100 without using recursion and conditions

can we print 1 to 100 without using any if conditions and loops in c&c++? Conditon: main point is you must not use recursion...and doesnt hardcode code in it for e.g print(1 2 3..etc);
5
votes
3answers
1k views

The shortest code to tell if a number is even or odd

One of my colleagues proposed us a challenge: to write the shortest C/C++ program to determine if a number is even or odd. These are the requirements: Get a number from keyboard, at run-time (not ...
3
votes
3answers
472 views

m3ph1st0s's programming puzzle 4 (C/C++): “3-way swap”

My last puzzle has generated some confusion and controversy so I decided to give up, for now, on those "replace one character"-type puzzles. Hope this 4th puzzle will redeem myself after all the ...
0
votes
11answers
608 views

Code-golf: square of the number of ones

I'm solving problem: in file "a.in" given the number N - length of the number consists of ones. Need to gets square of it, and put this in file "a.out". This is my shortest solution(150 bytes): char ...
7
votes
12answers
931 views

“First time” test

What is the shortest C expression that is defined to evaluated to false the first time and true for every time after that: Reference implementation: bool b = false; // you get this for free. (b ? ...
3
votes
2answers
389 views

HangOver ACM problem!

there is only one rule: get accept for this problem http://acm.ut.ac.ir/sc/problemset/view/1032! to submit your code, you need to create an account(if you don't want to do so, just post your code ...
5
votes
7answers
606 views

Shortest code that return SIGSEGV among the given languages

I come across a question in a coding competion "write a code that returns SIGSEGV(Segmentation fault ) " . Points were given on the basis of length of code. The prgramming languages available ...
2
votes
2answers
430 views

Fastest C/C++ comparison function for an opaque field containing doubles

Description: Write the fastest comparison function for an opaque field containing a double. Here is my example: // Three-way comparison function: // if a < b: negative result // if a > b: ...
1
vote
5answers
1k views

C: Output “tomorrow's date”

I'm a code golf novice, but I'm eager to give it a go. My challenge is: Write the shortest program in C which takes in a date D as input and outputs the date D + 1 day Rules: program must compile ...
0
votes
1answer
2k views

Poisson random number generator

What is the shortest function (implemented in C) that will return a random draw from a Poisson distribution (given the mean or λ parameter)? int random_poisson(double lambda);