Programming Puzzles

A collection of 10 Articles

Call a method without calling it -Programming Puzzles

Can you come up with a way to get a particular method executed, without explicitly calling it? The more indirect it is, the better. Here's what I mean, exactly (C used just for exemplification, all languages accepted): // Call this. void the_function(void) { printf("Hi there!\n"); } int main(int ...

(x == x+2) make it equal for x - Programming Puzzles

Define value of x in such a way that the expression (x == x+2) would evaluate to true. No rule for this programming puzzle. Solutions Jump to C, CSharp, JavaScript, PHP Solution. You can submit your own solution in comment section in same/different programming language. If your solution is ...

Unix cat program - Programming Puzzles

One of the most common standard tasks is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility cat. Task You should write a full program which reads the contents of the standard input stream and writes ...

1, 2, 3, 4, 5, Shaggy - Programming Puzzles

This is a game where you must count to number from 0 to 1000. However, if the number has a 6 in it, or is divisible by 6, you don't say the number. Instead, you say "Shaggy". Rules: You can't hard-code the numbers. The number only has to satisfy at ...

C Program without main() function - Programming Puzzles

We can write c program without using main() function. To do so, we need to use #define preprocessor directive. The C preprocessor is a micro processor that is used by compiler to transform your code before compilation. It is called micro preprocessor because it allows us to add macros. A ...

Find Anagram String - Programming Puzzles

Given two strings, work out if they both have exactly the same characters in them. Example Input word, wrdo This returns true because they are the same but just scrambled. Input word, wwro This returns false. Rules Here are the rules! Assume input will be at least 1 char long, ...

Build a Rocket - Programming Puzzles

This isn't rocket science. LoL Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as | /_\ |I| |N| |D| |I| |A| |_| /___\ VvV with the input string written from top to ...