Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
12 votes
5 answers
2k views

Risk, the Warlight Way

Introduction In this game, players use their armies to fight other players' armies, capture territories, and become the last man standing. Each turn, players receive a base number of armies to use at ...
TNT's user avatar
  • 2,482
31 votes
7 answers
3k views

Write a C / C++ Polyglot [closed]

This challenge's concept is pretty simple. All you have to do is write a program that will compile as both valid C and valid C++! Well, there are some catches. The program must behave differently when ...
Mewy's user avatar
  • 429
14 votes
15 answers
14k views

Compare two integers in C or C++ without comparison operators

Produce the shortest program which takes two signed integers as input (through stdin or as arguments) and displays 3 different outputs depending upon whether the first number is (1) greater than, (2) ...
grove's user avatar
  • 159
8 votes
9 answers
3k views

Shortest C \ C++ function to generate -1, 0 ,1 [closed]

Let a function receive two integers i and j between 0 and ...
Nathaniel Bubis's user avatar
5 votes
6 answers
2k views

Make FizzBuzz using only preprocessor directives

I have a source file here: #include <FizzBuzz.h> fizzbuzz And I want to make "fizzbuzz" turn into a FizzBuzz program ...
Joe Z.'s user avatar
  • 35.1k
3 votes
1 answer
861 views

Flip the commented-out code [closed]

This puzzle works for any programming language that has the same // single-line and /* ... */ multi-line comments that C++, C# ...
Timwi's user avatar
  • 12.9k
12 votes
1 answer
809 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 <...
Joe Z.'s user avatar
  • 35.1k
5 votes
4 answers
3k 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 ...
Vincenzo Pii's user avatar
2 votes
3 answers
853 views

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

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 ...
Bogdan Alexandru's user avatar
11 votes
5 answers
3k views

m3ph1st0s's programming puzzle 3 (C): “Easy bug” [closed]

This is the 3rd of my series of C/C++ puzzles; in case you missed the first 2 they are here: (1) m3ph1st0s's programming puzzle 1 (C++) (2) m3ph1st0s's programming puzzle 2 (C++): "Call ...
Bogdan Alexandru's user avatar
-2 votes
2 answers
3k views

Conversion to palindrome with minimal points used

Input: a word (2-100 characters) Convert this word to a palindrome: delete character - 13 points add character - 12 points increase character - 5 points ('d' > 'e') decrease character - 4 points ('n'...
e-MEE's user avatar
  • 123
7 votes
7 answers
2k views

Shortest code that return SIGSEGV among the given languages [duplicate]

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 ...
Anil Arya's user avatar
  • 1,377
2 votes
2 answers
904 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: ...
Kiril's user avatar
  • 131