All Questions

11
votes
2answers
444 views

What is a good way to deal with tasks that require arrays using Haskell?

Often a task requires real arrays. Take for instance the task to implement Befunge or ><>. I tried to use the Array module for this, but it's really cumbersome, ...
16
votes
6answers
6k views

Count number of hefty decimals between 2 numbers

Let's say we have a non-negative integer that is "hefty" (that is, "heavy") if its average digit value is greater than 7. The number 6959 is "hefty" because: (6 + 9 + 5 + 9) / 4 = 7.5 The number ...
12
votes
25answers
2k views

Mathematical Combination

Write a program that takes an input such as: n,k which then computes: and then prints the result. A numerical example: Input: ...
12
votes
4answers
954 views

Polynomial Interpolation

Write a program that performs Polynomial Interpolation using true arbitrary precision rational numbers. The input looks like this: f(1) = 2/3 f(2) = 4/5 f(3) = 6/7 ... You may assume that there's ...
12
votes
8answers
738 views

Finding maximum paths

Given a square of positive, natural numbers write a program find a horizontal and a vertical path with the sum of numbers along them being maximal. A horizontal path goes from the first column to the ...
18
votes
15answers
3k views

The Time Traveler

The shortest code to generate the correct times on the clocks wins. You are a seasoned time traveler and have been known to stop at many planets during your journies. Each planet rotates at a ...
44
votes
3answers
4k views

What can you do in a 4k data URI? [closed]

Bounty is over, thephpdeveloper wins with Conway's Game of Life The web platform today is advancing at a rapid rate. Features like CSS3 animations, transforms, drop shadows and gradients, ...
12
votes
8answers
1k views

An Old Irish Blessing

I don't know who coined these words, and I'm not Irish, but I give you an Irish blessing: ...
8
votes
4answers
650 views

A subset of Verbal arithmetic

Implement a verbal arithmetic solver of several same sequence of numbers added together: ...
15
votes
6answers
2k views

Decompose a permutation into cycles

There is a well-known theorem that any permutation can be decomposed into a set of cycles. Your job is to write the shortest possible program to do so. Input: Two lines. The first contains a ...
14
votes
17answers
4k views

Shuffle a deck without local variables [closed]

The object of this puzzle is to take a deck of 52 cards and shuffle it so that each card is in a random position. Given: An array, deck, of 52 distinct integers ...
8
votes
7answers
1k views

Find all number pairs that sum to 121212 [closed]

This problem is quite easy to do by brute force. In fact, it'll be reasonably fast to brute force as well. But where's the fun in that? The Problem Produce a list of all unique 5 digit number ...
12
votes
9answers
1k views

Forking Factorials

This golf requires a factorial calculation be split up among multiple threads or processes. Some languages make this easier to coordinate than others, so it is lang agnostic. Ungolfed example code is ...
16
votes
4answers
2k views

Visualize long division with ASCII art

Write a program that visualizes long division with ASCII art. Input consists of two integers, a numerator and a denominator, using the input format of your choice. Examples: 1234 ÷ 56: <...
10
votes
9answers
4k views

Arbitrary Base Conversion [closed]

Create a routine that takes an array of blocks in one numeric base system, and convert them to an array of blocks in another numeric base system. Both the from and to systems are arbitrary and should ...
9
votes
2answers
815 views

Floating point addition, without floats!

Your task is to write a program, in any language, that adds two floating point numbers together WITHOUT using any fractional or floating point maths. Integer maths is allowed. Format The format for ...
21
votes
13answers
2k views

Langton's ant ASCII art.

Draw the path of Langton's ant. Description Squares on a plane are colored variously either black or white. We arbitrarily identify one square as the "ant". The ant can travel in any of the four ...
21
votes
7answers
3k views

Interpret ><> (Fish)

While ><> is not a popular language, it can be good for golfing and has been used on this website. It was inspired by Befunge and has some similarities in its instructions. Required Commands: <...
9
votes
1answer
5k views

Build a simple proxy

Make the shortest proxy server. Input/Output Specifications Client: Input: a port number (32-bit integer) (,) or (space) a url (see test cases) Output: html source of the url Server: Input: port ...
13
votes
11answers
2k views

Compute the first N digits of e

Challenge Write a program to compute the the first N (<= 10^3) digits of e. Your program should take an integer N as input. Input: 100 Output: ...
13
votes
20answers
1k views

Uptime Progress Bar

Write a program which parses the output of uptime and generates an anatomically suggestive progress bar (as shown) with a length equal to the current uptime in days:...
8
votes
4answers
380 views

The fourth power (Juzuk)

In 1939 Juzuk described a way to generate the fourth powers of natural numbers. Group the natural numbers like this: ...
77
votes
97answers
12k views

Hello World 0.0!

source: Dilbert, September 8, 1992 I'm hoping to add a new twist on the classic "Hello World!" program. Code a program that outputs Hello World! without: String/...
32
votes
14answers
2k views

Draw a Suanpan abacus

Write the shortest program that takes a single integer as input and prints out a Suanpan abacus Testcases Input: 314159 Output: ...
8
votes
2answers
629 views

Simple Geometric problem

This problem (see below) has been given as a High School Programming League code golf challenge. The shortest codes submitted during the contest were: 177 bytes in Ruby, 212 bytes in Python 2.5, 265 ...
15
votes
10answers
3k views

Calculate digits of Pi

This is a somewhat different task. Calculate 1024 hexadecimal digits of π, beginning at the 1024th hexadecimal place. Formally: Your program should complete in less then 1 minute and produce the ...
14
votes
3answers
473 views

Permutation group operation

There is a well-known bijection between the permutations of n elements and the numbers 0 to n!-1 such that the lexicographic ordering of the permutations and the corresponding numbers is the same. For ...
24
votes
33answers
10k views

Determine if 4 points form a square

Write a function that takes 4 points on the plane as input and returns true iff the 4 points form a square. The points will have integral coordinates with absolute values < 1000. You may use any ...
10
votes
7answers
782 views

Circles of text

Find a way to make circles of a given radius using characters in a console. Please specify the font name and size. Also, please provide at least one example of the output. For example: Input: ...
44
votes
74answers
7k views

Answer to life, the universe, and everything

Task Given a String as input, your task is to output 42 only if the input String happens to be exactly the following : ...
11
votes
6answers
1k views

Code-Golf: Quine Challenge I

Challenge In this task you have to write a program that will take input an integer N (-1e9 <= N < 0 && 0 < N <= +1e9), then compute T = (abs(N) % M+1),if N is positive ...
7
votes
2answers
618 views

GolfScript - The missing function

The GolfScript language has one serious lack, no float or fixed point handling. Remedy this by creating a function F for converting an integer number, given as a string, to a string representing 1 / ...
18
votes
41answers
2k views

Detect rotated strings

Read two strings from stdin. Output Yes if one string is a rotated version of the other. Otherwise output ...
12
votes
1answer
3k views

Solve the 8 Puzzle

The 8 Puzzle is the smaller variant of the 15Puzzle (or the Sliding puzzle). You have a 3x3 grid which is filled with numbers from 0-8 (0 denotes the blank tile) ...
7
votes
4answers
553 views

Obtain a number from 4 numbers using any combination of mathematical operations [closed]

Given 4 numbers n1, n2, n3, n4, and a goal n5, obtain n5 using n1 through n4 combined with any operations. Eg. Given four numbers 2,3,4,5 and the goal as 8, output (one of many) is ...
5
votes
8answers
792 views

Code Golf: Number of paths!

Challenge Consider a square matrix of order N(N rows and N columns). At each step you can move one step to the right or one step to the top. How many possibilities are to reach (N,N) from ...
8
votes
2answers
569 views

Turn 2D boolean array into (rectilinear) polygons

Challenge Write a program which, given a 2-dimensional boolean array (equivalently, a monochromatic bitmap), outputs a series of polygons that describe the outline of the region that is “true” (1). ...
85
votes
133answers
11k views

Determine whether strings are anagrams

Challenge 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 ...
18
votes
38answers
3k views

Chessboard pattern

Input: a positive number, smaller then 80, from stdin or as a command-line argument. Output: A square chessboard pattern, the size of the input number. The dark fields are represented by the letter '...
3
votes
1answer
352 views

Check printer - Convert to English text from the input value.

Check printer function (or subroutine) - Convert to English text from the input value. 12.34 -> "twelve dollars and thirty four cents". For the range .01 to 9999.99 assuming valid input.
6
votes
3answers
571 views

Break the broken hash [closed]

Some time ago, I found this unused hash function (written in Java) in our codebase: ...
17
votes
4answers
2k views

ASCII art Bresenham line drawing

Write the shortest possible program that draws a Bresenham line in ASCII art. Your program should take two integers x and y (...
12
votes
12answers
2k views

Hitting 495 (Kaprekar) [duplicate]

Input: A three digit number from stdin or as an argument not all digits are the same may start with one or two zero's Process Order the input-digits ascending and descending to form two new ...
4
votes
4answers
296 views

Rotate Cartesian coordinates.

Write a program rotates some Cartesian coordinates through an angle about the origin (0.0,0.0). The angle and coordinates will be read from a single line of stdin in the following format: ...
-3
votes
3answers
334 views

Shorten this code while fixing a major bug [closed]

I found the code below today after much hair pulling. Shorten it down (code golf) and fix the bug that I found (bonus). ...
10
votes
7answers
3k views

Implement Shamir's Secret Sharing reconstruction

Shamir's secret sharing scheme is a simple way of protecting a secret by splitting it into several parts needed to reconstruct it. Your task is to implement Shamir's Secret Sharing reconstruction ...
12
votes
1answer
760 views

Break the broken cipher

I have designed a simple random generator that cycles two numbers in a chaotic way using a multiply and modulus method. It works great for that. If I were to use it as a cipher generator it would ...
10
votes
20answers
836 views

Calculate probability of getting half as many heads as coin tosses.

Write a program that, given a small positive even integer from standard input, calculates the probability that flipping that many coins will result in half as many heads. For example, given 2 coins ...
10
votes
13answers
2k views

Draw a BCD Binary clock

Create a BCD binary clock in ASCII. As implied, it shall display time in six columns of dots: (source: Wikimedia Commons) Each column is a binary-coded digit, reading hours, minutes and seconds ...
8
votes
8answers
2k views

Output a playable crossword grid

Write a program to produce a file containing a crossword grid that the user can print out and work the puzzle on. Input A filename representing a crossword grid file and optionally a second ...

15 30 50 per page