# All Questions

12,569 questions
Filter by
Sorted by
Tagged with
1k views

### Self replicating Hello World program [closed]

Create a self-replicating Hello World Program. (The program has the ability to use the compiler, if you want). For example: ...
6k views

### 1P5: Iterated Prisoner's Dilemma

This task is part of the First Periodic Premier Programming Puzzle Push and is intended as demonstration of the new king-of-the-hill challenge-type proposal. The task is the write a program to play ...
2k views

### Fastest python code to find a set of winning words in this game

This is a word game from a set of activity cards for children. Below the rules is code to find the best triplet using /usr/share/dict/words. I thought it was an interesting optimization problem, and ...
844 views

### Product of Digits

For a given positive integer number N, write a complete program to find the minimal natural M such that the product of digits of M is equal N. N is less than 1,000,000,000. If no M exists, print -1. ...
317 views

### Console Role Playing Game [closed]

Below are a basic set of requirements. The following commands (for an interface to the game): ...
9k views

### Look and say sequence [duplicate]

The look and say sequence is a basic form of run length encoding. The sequence starts with the number 1 and each additional number encodes the number of digits that are repeated before each digit ...
1k views

### Build a small and balanced mobile

You are given a bunch of weights, and your task is to build a small balanced mobile using those weights. The input is a list of integer weights in the range 1 through 9, inclusive. There may be ...
87k views

### How to determine if a number is odd or even without mod -or- bitwise operations? [closed]

How to determine if a number is odd or even without mod -or- bitwise operations? This challenge is grossly inefficient, but challenges your ability to think outside the box for a creative solution. ...
5k views

### 1P5: Nested boxes

This task is part of the First Periodic Premier Programming Puzzle Push. You get a hierarchy of items in the following format: 2 Hat 1 Gloves which need to be ...
2k views

### Amicable number calculator

Write a program that calculates amicable numbers, starting from [0,0], intil the maximum value for an integer is reached in the language you chose to write it in. Amicable numbers are two different ...
3k views

### Circle Through Three Points

Given the Cartesian coordinates of three points on a plane, find the equation of the circle through them all. The three points will not be on a straight line. Each line of input to your program will ...
7k views

### Fake error message [closed]

Write a program that prints out the syntax error message of the compiler or interpreter. The error message should be misleading so that code maintainers will take days to find out that the error was ...
654 views

### Calculate an integer sequence derived from prime factors

Create a function, expression, or program which does the following: Take the prime factors of any number and sum them. For example, the prime factors of 28 are 2 2 7, summed to 11. Multiply the ...
2k views

### Write Buggy Code [closed]

Now is the time to show off your abilities to write bad code. I am trying out a new sort of programming puzzle, most similar, I think, to the underhanded C contest. The main difference is that this is ...
7k views

### Find whether a number is happy or not?

A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (...
1k views

### Textual maze solver

Given a maze on stdin and an entry point, write a program that prints a path to the exit on stdout. Any path is acceptable, as long as your program does not generate the trivial path (passing through ...
2k views

### Polyomino generator

Write a program that prints the shapes of one-sided polyominoes. Given input 4 (tetrominos), a sample output would be: ...
2k views

### Smallest Javascript CSS Selector Engine [closed]

Create a small acceptably efficient JS CSS selector engine. Standard css 2.0 properties should be supported in Firefox 3.0+,Safari , Opera, IE7+, and extra brownie points for IE6 support. Smallest ...
31k views

### Tips for golfing in C

What general tips do you have for golfing in C? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C (e.g. "remove comments" is not an ...
4k views

### 'Add' up the letters in a word

My dad is a retired teacher, and he used to give combined spelling and math quizzes, where the student would spell a word, and then 'score' the word by adding up the letters, where a=1, b=2, etc. (e.g....
5k views

### Print the alphabet four times

The program must print the alphabet four times: first in the normal alphabetical order, second in the order of a qwerty keyboard, third in the order of a dvorak keyboard, and lastly in reverse ...
3k views

### Hangman wordgame golf

Inspired by reddit. Write a program which plays Hangman. The program chooses a random word from a list of N words, where N > 2. The word list can be provided to the program in any way you choose. ...
1k views

### Union of Intervals

Given a list of intervals, perform the union of them, and reduce overlaps. That means, overlapping parts are reduced. ([a, b] U [c, d] = [a, d] if ...
503 views

### Fastest alphabetical list sort given the following limitations:

Your function must have an input that takes in an array containing 10000 random names, and must sort these names in alphabetical order. Names have a random length of up to 128 characters. ISO/IEC 8859-...
2k views

### Determine if a polygon is convex

Write a program to determine if the input polygon is convex. The polygon is specified with one line containing N, the number of vertices, then N lines containing the x and y coordinates of each ...
17k views

### The alphabet in programming languages

Our task is to, for each letter of the (English) alphabet, write a program that prints the alphabet, in a language whose name starts with that letter. Input: none Output: ...
237 views

### Numerical Integration through Plotting

Inspired by this on Spiked Math: (source: spikedmath.com) In this code golf, you are going to write a numerical integrator. Instead of weighting, you first plot on a graphic canvas pixel-by-pixel ...
10k views

### Choosing Languages for Golfing [closed]

What are some tips for choosing the right language to golf? What factors affect the language to be chosen? Here are some example problem types: Problems that require I/O solution, either console or ...
570 views

### Intersection of Two Lines

Given equation of two lines in the format Ax+By=C, determine their intersection point. If they are parallel print 'parallel' without quotes. For input/output format refer sample input/output. ...
1k views

### Sum of Fibonacci numbers -- speed contest [closed]

Write a program that print sum of as many Fibonacci numbers as possible. There is a limit in that your program should not run more than 10s on 2GHz single core PC. (equivalents are acceptable, for ...
8k views

### For 2 arrays, subtract every element in one array from the position-matching element in the other [closed]

For 2 arrays each with X elements, what is the SHORTEST code to subtract every element in the second from every element in the first, 1 to 1 so, for example: A1 = [10,11,12] A2 = [1,2,3] A1 "-" A2 ...
3k views

### Manchester encode a data stream

Manchester coding is a telecom protocol used in radio communications that guarantees bit transitions at a regular interval so a receiver can recover the clock rate from the data itself. It doubles the ...
2k views

### Lossy Text Compression [closed]

Background Of the 256 possible characters that a byte can represent, only a few of these are used under most circumstances. Couldn't we somehow take advantage of this, and make our text files smaller ...
1k views

### Implement a sorting algorithm with no change. [closed]

In this task, you have to write a program, that reads a string with a length of up to 1024 characters and prints it out sorted. In order to make an interesting task from a boring one, I set a few ...
3k views

### Long multiply, 8 bits at a time

You are given a 16-bit machine and told to implement multiplication of arbitrary-sized integers. Your registers can only hold 16-bit numbers, and the biggest multiply instruction takes two 8-bit ...
249 views

### Reduction of source code of a program [duplicate]

Possible Duplicate: Sum of positive integers. (Spoj - SIZECON) Here is the question:- Given the set of integers, find the sum of all positive integers in it. Input t – number of test cases [t <...
2k views

### Code-Challenge:The Nearest Prime

Challenge In this task you would be given an integer N you have to output the nearest prime to the integer. If the number is prime itself output the number. The input N is given in a single ...
1k views

### Ascii art equation visualizer

Dealing with equations in the absence of a good equation editor is messy and unpleasant. For example, if I wanted to express an integral and its solution, it might look something like this: Integral[...
3k views

### Find the prime factors

In this task, you have to write a program, that computes the prime factors of a number. The input is a natural number 1 < n < 2^32. The output is a list of the prime factors of the number in the ...
2k views

### What is the average of n, the closest prime to n, the square of n and the closest Fibonacci number to n?

This is a math problem which takes quite many things into question, making it rather challenging, and as you might have guessed, it's a code golf, so it should be as short as possible as well. The ...
1k views

### Artistic source code: Hello World [closed]

Back to basics! Create a "Hello World" program which prints, well, "Hello World". The winner this time though, is the one who gets the most interesting source code done. For instance, use obscure ...
772 views

### Sum of Fibonacci numbers

I found this task here. Given the ith (1<=i<=35) Fibonacci number F(i) calculate the sum of the ith till i+9th number F(i)+F(i+1)+...+F(i+9) and the last digit of the i+246th one F(i+...
1k views

### "list comprehension" in php. [closed]

PHP has closures, let's play around with them. I have some arrays similar to, \$wannabelist = array (1, 2, 3, 4, 5, 6). I want to do this: ...
115k views

### Generate the longest error message in C++

Write a short program, that would generate the longest possible error message, in a standard C++ compiler (gcc, cl.exe, ...
623 views

### Find all Super Powers [duplicate]

A positive number is said to be super power when it is the power of at least two different positive integers. Write a program that lists all super powers in the interval [1, 264) (i.e. between 1 (...
1k views

### Code-Golf: Lattice Points inside a Circle

The following picture shows the problem: Write a function that, given an integer as the circle radius, calculates the number of lattice points inside the centered circle (including the boundary). ...
1k views

### Fastest algorithm for decomposing a perfect power

A perfect power is a positive integer that's equal to one positive integer, to the power of another positive integer (e.g. ab is a perfect power). Note that trivial solutions (e.g. b=1) are excluded; ...
5k views

### Solve 2-SAT (boolean satisfiability)

The general SAT (boolean satisfiability) problem is NP-complete. But 2-SAT, where each clause has only 2 variables, is in P. Write a solver for 2-SAT. Input: A 2-SAT instance, encoded in CNF as ...
Find the greatest gcd of the numbers $n^m + k$ and $(n+1)^m + k$ for given m and k. For example, for ...