All Questions

Filter by
Sorted by
Tagged with
16
votes
15answers
1k views

City names game

If you like, write a program which sorts cities according to the rules of city name game. Each name of the city should start from the last letter in the previous city name. E.g. ...
-3
votes
10answers
9k views

Triangle Puzzle [closed]

Triangle Puzzle Consider the triangle below. This triangle would be represented by the following input file.    5   9 6  4 6 8 0 7 1 5 By starting at the top and ...
4
votes
10answers
951 views

Day of the week for a given date of this year. Do not use any date tools [duplicate]

Please write a program that takes as input two numbers 'day of the month' and 'month number' for any day of this year (2012) and outputs day of the week. Examples: ...
9
votes
5answers
778 views

Doors doors doors, c'mon down to the door store!

The challenge is twofold: Make a program that builds a door. ASCII, HTML or otherwise Make the door functional. Opens and closes Either open-able through input or interaction! Non-functional door +...
23
votes
15answers
1k views

Topographic Strings

Here is some example input, so I can explain what the problem is: ((1 2)(3 (4 5) moo)) (i (lik(cherries)e (woohoo))) Think of this line of text as a topographic ...
32
votes
11answers
2k views

Tips for golfing in J

GolfScript gets its own way far too often and I feel that a repository of handy hints for golfing in J might help in the fight against the evil empire. What tips do you have for making this already ...
4
votes
12answers
703 views

Finding duplicate balls in a basket?

Question A basket is full n colored balls . Except one ball all the other colors are repeating. Find the one color that does not repeat,in O(n) space complexity. What if each ball is repeated ...
4
votes
1answer
254 views

Christmas Lists

The challenge is to create one program that will accept as arguments (arrays of arrays) or on standard input (line-by-line, separated by commas) a collection of families and names, like so: ...
8
votes
13answers
1k views

Program that outputs a program that outputs a program … that outputs “Hello!”

Challenge Write the shortest program P such that P takes any positive integer n as input, and outputs a program string P1 executing P1 (with no input) outputs a program string P2, executing P2 (...
17
votes
17answers
2k views

Display the result of doing 8 perfect shuffles of a deck of cards

Explanation A perfect shuffle is where a deck of cards is split exactly in half and the cards from each pile are alternately interleaved. The original bottom cards and the original top card must be ...
4
votes
2answers
587 views

Lenient typing test

A typing speed test loads up a dictionary of words, and gives you one to type: pinball. You, with your fast but inaccurate fingers, type in ...
24
votes
1answer
2k views

Conway's Hello World

It is often said, that all programmers should be able to write a "hello world" program in any programming language after a few glances on that language (And quicksort after a few more glances). As ...
5
votes
3answers
578 views

Mouse in a room

There is a mouse in a room, in the top-left corner. It can move up, down, left, or right, and the mouse cannot go through any cell in the room twice. Given this, return all the possible paths in which ...
-6
votes
14answers
779 views

Sort, with your hands tied behind your back [closed]

The problem is very simple: write a program that accepts a single unsigned integer from the command line, and prints out that many random numbers on the standard output, in ascending order. For ...
22
votes
9answers
2k views

Name the poker hand

Name the poker hand Given five cards, output the name of the poker hand, which will be one of: ...
1
vote
3answers
3k views

Project Euler's “Harshad Numbers”

Project Euler Problem 387 states: A Harshad or Niven number is a number that is divisible by the sum of its digits. 201 is a Harshad number because it is divisible by 3 (the sum of its digits.) ...
16
votes
6answers
861 views

Code Golf: Mix the nuts so that none of the same kind are touching

Input: Input is a randomized array of nuts (in your language), the possible nuts follow. Your program must have a way of representing each kind of nut, such as an integer code. Program must be able ...
3
votes
1answer
2k views

Calculate Network Average Clustering Coefficient

The clustering coefficient of a graph (or network) is a: measure of degree to which nodes in a graph tend to cluster together The Wikipedia article gives a much better description of how network ...
12
votes
11answers
2k views

Generating Minesweeper grids

Minesweeper is a logic game found on most OS's. The goal of the game is to determine where the mines are on a grid, given numbers indicating the number of mines around that spot. Given a grid size, ...
8
votes
27answers
3k views

Generate Sexy Primes

Sexy Primes are pairs of numbers (n, m) such as n and m both are prime, and ...
-2
votes
7answers
1k views

Knight's tour on a rectangle

Given an a-by-b sized grid, and a chess knight, determine: A starting point and path the knight can take to visit every square in the grid or "NOT POSSIBLE", if not possible. Input: Two integers, <...
5
votes
9answers
997 views

Pythagorean Triplets

The Pythagorean Theorem states that for a right triangle with sides a, b, and c, a2+b2=c2. ...
38
votes
8answers
4k views

Shortest terminating program whose output size exceeds Graham's number

Write the shortest possible program (length measured in bytes) satisfying the following requirements: no input output is to stdout execution eventually terminates total number of output bytes exceeds ...
7
votes
4answers
374 views

generate a valid equation using specified operators

A twist on a recently asked question, you are given a list of operators and a result and you need to find integers which, when operated on by those operators, generate the result. Example 1 input <...
10
votes
2answers
819 views

Generate a valid equation using user-specified numbers

This is based on a game one of my math teachers used to play in middle school. He would write 5 random one-digit numbers on the board, and then a random two-digit number. We would try to create an ...
13
votes
8answers
2k views

Determining the continued fractions of square roots

The continued fraction of a number n is a fraction of the following form: which converges to n. The sequence ...
2
votes
6answers
302 views

All non-empty finite sets of positive integers

The challenge is to create an iterator(/generator) which iterates (in any order so as to reach all of them... ie no set should occur at infinity) over all possible non-empty finite sets(/tuples/lists) ...
3
votes
7answers
2k views

Generating combinations without recursion [closed]

Given a list of strings and a length, give all combinations of that list with the given length. The problem is: your code must not be recursive. Yes, it can be done. I have done it myself, when I had ...
0
votes
0answers
242 views

Brainf*** interpreter [duplicate]

Possible Duplicate: Interpret Brainfuck As the name suggests, the challenge is to create the smallest brainf** interpreter, in the language of your choice. It can either accept input from the ...
2
votes
19answers
475 views

Shortest code to dump a file into workable memory

This is a slightly different code golf from the usual problems. I'm forced to work with Java at my workplace and I'm increasingly annoyed at what I must do to read a file into memory to a String so I ...
5
votes
7answers
917 views

Generating Binary shapes [closed]

How could we generate shapes or images using binary? I got to messing around trying to create something that looked matrix like and got to thinking, wouldn't a great CodeGolf be to see who can make ...
6
votes
3answers
1k views

Implementing Binary Arithmetic

Given two binary numbers (strings containing 0s and 1s), perform operations on them, with one problem: You must keep them in binary. That means no going ...
6
votes
12answers
835 views

Range of numbers

Came over a similar problem in a project I'm working on and found it quite hard to solve it without excesive use of if. I'm eager to see if anyone can come up with ...
27
votes
21answers
32k views

List of first n prime numbers most efficiently and in shortest code [closed]

Rules are simple: First n primes (not primes below n), should be printed to standard output separated by newlines (primes should be generated within the code) primes cannot be generated by an inbuilt ...
5
votes
4answers
14k views

Solve the Magic Hexagon [closed]

A magic hexagon is a hexagon where every row and every diagonal add up to the same value. In this case the value is 38. Each number from 1 to 19 must be used exactly once. This image shows a solution ...
6
votes
3answers
304 views

Line through Polygon

Input: A line of the standard slope-and-intercept form: mx+b, as well as a set of Cartesian points determining the vertices of a polygon. Assume that the x and y ...
9
votes
5answers
2k views

Words from periodic table of elements [closed]

Back when I was a freshman in highschool taking chemistry, I'd look at the periodic table of elements and spell dirty words out with the number of the elements (HeCK would be 2619, 2-6-19). I was ...
43
votes
37answers
14k views

Draw A Sierpinski Triangle

The Sierpinsky Triangle is a fractal created by taking a triangle, decreasing the height and width by 1/2, creating 3 copies of the resulting triangle, and place them such each triangle touches the ...
14
votes
3answers
1k views

Universal (rule-bending) Code Golf solver

Code golf always involves some answers that bend the rules more or less by breaking constraints that the challengers took for granted or just haven't thought about and didn't list in the rules. One of ...
10
votes
13answers
784 views

Operations with Lists

Inspired by this question. Given a list containing numbers, print: The sum and product of the numbers in the list The average and median The differences between each term in the list (e.x. ...
3
votes
2answers
602 views

Detect the character encoding of the input [closed]

Your task is to golf a program that prints which character encoding, if any, the data read from the input represents. It should be able to detect the following encodings: ASCII ISO 8859-1 UTF-8 UTF-...
34
votes
12answers
5k views

Code Golf of Death [closed]

Write some code that causes a BSOD or kernel panic! Rules: On Windows, you must cause a BugCheck (Blue Screen of Death), on Linux (or other *nix systems) you must cause a kernel panic. Must not ...
19
votes
19answers
2k views

Calculate hamming weight with low hamming weight

Create a program that computes the hamming weight of a string. Winner is the program with the lowest hamming weight. Rules: Hamming weight for an ASCII character is defined as the total number of ...
5
votes
19answers
1k views

Arithmetic Sequences

An arithmetic sequence is a sequence of numbers of the form a,a+n,a+2n,...
0
votes
0answers
167 views

Program to match the requirements in “The World's Worst Passwords Requirements List” [duplicate]

Possible Duplicate: Security by Post-It I'm looking for the shortest program that validates passwords match the requirements in the World's Worst Password Requirements List, available here. The ...
19
votes
10answers
3k views

Egyptian Fractions

Overview: From Wikipedia: An Egyptian fraction is the sum of distinct unit fractions. That is, each fraction in the expression has a numerator equal to 1 and a denominator that is a positive integer, ...
16
votes
3answers
882 views

Security by Post-It

As you may know, hackers are everywhere and they want to hack everything. You were asked to make password requirements which will stop any hacker. The problem is, that your boss has heard that paying ...
17
votes
17answers
3k views

Write a program that is valid after circular character shift

Potentially very difficult, but I've seen some amazing things come out of this site. The goal is to write a program, in any language, that does whatever you want. The catch is that the program must ...
7
votes
7answers
2k views

Big integer multiplication

Your challenge (if you choose to accept it) is to implement big integer multiplication in the shortest code possible. Rules: Take two integers (decimal form) as ASCII strings from the command line ...
4
votes
9answers
963 views

Subtracting, the old-fashioned way

Overview Adding slightly to the complexity of working with Roman numerals... The ancient Romans devised a number system using Latin letters, which served them well, and which is still used by modern ...

15 30 50 per page