Code-golf is a competition to solve a particular problem in the fewest bytes of source code. If you want to score by characters instead of bytes, state this explicitly in the challenge. If source code length is not the primary scoring criterion, consider using another tag instead.

learn more… | top users | synonyms

-3
votes
7answers
99 views

Find the remaining side of the tangential quadrilateral!

(Taken from https://en.wikipedia.org/wiki/File:Tangential_quadrilateral.svg) A tangential quadrilateral (see example above) is a quadrilateral in which a circle can be inscribed. Your task is to ...
1
vote
0answers
58 views

Tiling by substitution

Consider the following substitutions, where the substituted rhomb(us) is scaled up and shown in red: A rhomb ... becomes ... B rhomb ... becomes ... Each substitution is made up of some ...
-1
votes
0answers
33 views

Sudoku Solver: Create an algorithm to solve basic sudoku puzzles [duplicate]

Obviously it would be unreasonable to ask for code that could universally solve all sudoku puzzles. Therefore in this case I'm only asking for something which can solve fairly easy puzzles. To define ...
3
votes
0answers
98 views

Interpret DOGO!

Interpret DOGO DOGO is a lesser known programming language. While the original DOGO (a joke language from a Usenet post) has never been implemented, a language resembling it has been created. The ...
3
votes
3answers
118 views

Golf the K-means algorithm

K-means is a standard unsupervised clustering algorithm, which, given a set of "points" and a number of clusters K, will assign each "point" to one of K clusters. Pseudo-Code of K-means Note that ...
-4
votes
0answers
31 views

How to set VAR as a list with more than one output and use it in command line argument [on hold]

netsh wlan show profiles > profile.txt for /f "skip=9" token=2 delims=:" %i in (profile.txt) do set "var=%i" netsh wlan show profile name=%var% key=clear now this command works if only one SSID is ...
16
votes
3answers
171 views

ASCII piano keyboard

Piano keys are 3 characters wide, and 7 characters tall. However, if every key was 3 charactes wide, there wouldn't be enough room for the black keys. That's why some of the white keys have parts ...
2
votes
2answers
143 views

Filter this string!

Your task is to write a program that will filter out some characters in a string, so that the remaining spells out (part of) the other string. Let's say we received the string ...
14
votes
11answers
1k views

Counting in bijective base 62

The task is to generate all the strings from 'a' to '999' including upper case characters like so: 'a', 'b', 'c' ... 'y', 'z', 'A', 'B', 'C' ... 'Y', 'Z', '0', '1', 2' ... '8', '9', 'aa', 'ab', 'ac' ...
4
votes
5answers
319 views

Calculate the Gamma function for half-integer arguments

Gamma function is defined as It is a well-known fact that for positive integers it coincides with a properly shifted factorial function: Γ(n) = (n - 1)!. However, a less famous fact is Γ(1/2) = ...
17
votes
6answers
1k views

Determine If a Challenge is Worth Answering

I am a very casual code golfer, and don't often see posts until they show up in the "Hot Network Questions" sidebar over on StackOverflow. Usually, I'm late to the game, and since the only language I ...
5
votes
13answers
303 views

Briefest code to find vowels and print consonants

Challenge: Read a string from user, print number of each vowel, then place all remaining chars in a line. Shortest answer wins! Output must look like this: Enter String: Input Vowel Count: ...
23
votes
7answers
647 views

Between the Lines

While doodling around on square-ruled paper the other day, I came up with the above negative-space font for digits. In case you haven't spotted it yet, the spaces between the above shapes yield the ...
10
votes
5answers
460 views

Print the Nth non-palindromic number

Print the Nth non-palindromic number A palindromic number (in case you don't know) is a number which reads the same backwards and forwards (example, 11). The first 15 non-palindromic numbers are: 10, ...
22
votes
27answers
4k views

The rice and chess problem

An Indian legend tells the story of the alleged inventor of the chess game, who impressed the emperor of India with his game so much that he would get rewarded with anything asked. The man said he ...
10
votes
15answers
935 views

Probability of something happening at least n out of m times

Write a program or function, that given a success probability p, a number n and a number of trials m returns the chance of at least n successes out of m trials. Your answer must be precise to at ...
11
votes
3answers
323 views

Minimize Those Ones [on hold]

Your task is to build a natural number using the fewest number of ones and only the operators + or -. For example, the number seven can be written 1+1+1+1+1+1+1=7, but it can also be written as ...
6
votes
1answer
57 views

Tips for golfing in Swift

What are some tips for code-golfing in Swift? Its focus on safety seems to make it difficult to golf in, but that makes little tips and even more useful. Are there any features in Swift that may help ...
20
votes
3answers
1k views

Rainbowlify An Image

This challenge is about gradually shifting hues in an image to make pretty pictures like this: (original) Challenge Write a program or function that takes in two non-negative integers and an image ...
19
votes
13answers
2k views

Golf Text into DNA

Text to DNA golf Challenge Convert input into a DNA output. Algorithm Convert text into ASCII code points (e.g. codegolf -> [99, 111, 100, 101, 103, 111, 108, 102]) String the ASCII codes ...
-18
votes
12answers
185 views

Reverse a 1-dimensional array

Note: This challenge is not the same. Challenge Believe it or not, we haven't got ONE challenge for reversing one-dimensional arrays (although we've got one for n-dimensional ones)! This should ...
-1
votes
1answer
86 views

Encrypting and Decrypting Challenge [on hold]

Encrypting Challenge Your encrypting program must be able to do following things: Input password Generate random key Encrypt random key with set key Then, the decrypting program must be able to ...
2
votes
1answer
72 views

Scale up an image! [duplicate]

Your task is to write a program/function to scale up an image (list of strings) by a factor of n. Specs You will receive two inputs: an image, and a positive integer. The image will only contain ...
10
votes
2answers
195 views

Is this uniquely concatenable?

In this challenge about prefix code, we learnt that prefix codes are uniquely concatenable. That means, they can be joined together without separator, and without ambiguity. For example, since ...
24
votes
16answers
2k views

Is it a prefix code?

In information theory, a "prefix code" is a dictionary where none of the keys are a prefix of another. In other words, this means that none of the strings starts with any of the other. For example, ...
6
votes
6answers
289 views

Draw a phi triangle

Clarification: Basically, you need to make this Euler's totient function has the name phi. Let's try to calculate phi(8) First, list all numbers 8 and under backwards, not including 0 or under 8 7 ...
7
votes
1answer
102 views

Drilling For Oil

Congratulations! You have just been hired by a Fortune 499 company specializing in oil drilling. Your job is to write a program to determine the optimum placement of OilRUs' drill (represented by a ...
-7
votes
7answers
194 views

Are my eyes open or closed?

You are trying to guess my emotion. I will give you an adjective, as the input to the function/program. Your task is to output the state of my eyes, either O_O for open, or ._. for closed. Details ...
13
votes
11answers
544 views

Smallest groups in an array

Introduction Let's observe the following array: [1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1] A group consists of the same digits next to each other. In the above array, there are 5 different ...
14
votes
5answers
303 views

Automatic house-builder

Automatic house building nanobots have been fabricated, and it's your job to code them. Here is the house created by input 7 4 2 /-----/| / / | |-----| | | | | | | / |_____|/ The ...
-7
votes
14answers
178 views

Am I happy or sad?

You are trying to guess my emotion. I will give you an adjective, as the input to the function/program. Your task is to output my emotion, either :) for happy, or :( for sad. Details For these ...
-1
votes
1answer
96 views

Random word-sentence-story generator

This question got me nostalgic: Build a word generator! In the '80s I wrote a simple word generator in under 42kB (code and working memory) that would take a collection of strings and use them to ...
5
votes
12answers
287 views

Polygonal numbers

A polygonal number is the number of dots in a k-gon of size n. You will be given n and k, and your task is to write a program/function that outputs/prints the corresponding number. Scoring This is ...
4
votes
15answers
266 views

Counting triangles with integer perimeter

Mary has given John two sticks of lengths a and b respectively, where a and b are positive integers. John is very curious. He would like to know how many triangles with integer perimeter can be ...
5
votes
3answers
119 views

Find the number of ways to choose `n` objects from `r` objects with repetition so that every object has a matching neighbour

For example, if n is 5 and r is 2, it would mean the number of lists below: [1,1,1,1,1] [1,1,1,2,2] [1,1,2,2,2] [2,2,1,1,1] [2,2,2,1,1] [2,2,2,2,2] which is 6. If n is 4 and r is 3: [1,1,1,1] ...
1
vote
4answers
66 views

Bijective mapping from integers to a variable number of trits

This challenge is a harder version of this one. A variable number of trits is an array of 0 or more trits (a trit is a ternary digit). So [0, 2, 2, 1] is a variable number of trits, but so is []. ...
12
votes
13answers
830 views

Find the n-th perfect power!

A perfect power is a number of the form a**b, where a>0 and b>1. For example, 125 is a perfect power because it can be expressed as 5**3. Goal Your task is to write a program/function that ...
6
votes
15answers
257 views

Find the positive divisors!

Definition A number is positive if it is greater than zero. A number (A) is the divisor of another number (B) if A can divide B with no remainder. For example, 2 is a divisor of 6 because 2 can ...
11
votes
4answers
283 views

Map a list of indefinite size to a number!

It is well known, in the field of Mathematics studying infinity, that the Cartesian product of any finite amount of countable sets is also countable. Your task is to write two programs to implement ...
3
votes
6answers
169 views

Build a word generator!

Your task is to create a program/function to replicate this word generator. Details Your program/function take two input. One input is the categories. The other input is the syllable types. ...
8
votes
12answers
391 views

Decompose a number!

Your task is to decompose a number using the format below. This is similar to base conversion, except that instead of listing the digits in the base, you list the values, such that the list adds up ...
14
votes
9answers
757 views

Compute CRC32 Hash

Credits This challenge originated from @miles. Create a function that computes the CRC32 hash of an input string. The input will be an ASCII string of any length. The output will be the CRC32 hash ...
1
vote
0answers
43 views

Find the shortest variable length encoding [duplicate]

There is an algorithm, which, given the probabilities of certain outcomes, returns the optimal variable length encoding. Say we have a five character alphabet, with these letter probabilites: A | ...
5
votes
1answer
129 views

Will it ​float?

The challenge Given a 2d string representing the bottom of a boat as an input, you must determine whether or not the boat will float. This 2D string can be in whatever format is most convenient. ...
0
votes
1answer
87 views

Calculate the a ^ b WITHOUT using *, / and ^ [duplicate]

Challenge Your goal is, given two positive integer numbers a and b, to calculate (and output) a ^ b without using either multiplication, division and the power itself (not directly, at least). And, ...
0
votes
5answers
55 views

exponential without exponential [duplicate]

Your goal is to calculate the exponential of a float (e**x) up to 2 decimal places for any float within 1 to 10. The accepted error range is 0.01. However, you must not use the built-in exponential ...
7
votes
1answer
175 views

How many shapes are in this picture?

Children are very good at classifying objects and counting them. Computers seem to have more trouble. This is a simplified version of this problem. Can you write a small program that can classify and ...
30
votes
31answers
2k views

Compute the Adler-32 checksum

Background Adler-32 is a 32-bit checksum invented by Mark Adler in 1995 which is part of the widely used zlib library (also developed by Adler). Adler-32 is not as reliable as a 32-bit cyclic ...
10
votes
10answers
1k views

hackertyper.net

Introduction hackertyper.net is a website that simulates "hacking" (as the media portrays it) by outputting complicated code from the crypto section of the Linux kernel onto the screen as you type at ...
-4
votes
4answers
85 views

Reverse number - shortest [on hold]

Who write shortest code win. for example: input: 1 2 3 4 5 6 54321 output: 54321 6 5 4 3 2 1