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

1
vote
0answers
5 views

Minimum cost block diagonalisation

Consider binary block diagonal matrices which have square blocks of 1s on the main diagonal, and are 0 everywhere else. Let's call such matrices "valid" matrices. For example, here are some valid 4x4 ...
-1
votes
0answers
21 views

Make the smallest constant check program [on hold]

First Disclaimer I am very new, and this is my first challenge and might be downvoted, or not the best. Please bear with me Task Make the smallest constant check program, with python programming ...
4
votes
1answer
79 views

Visualize Church numerals

Background Visualizing λ-calculus terms Famous lambda-juggler (and code golfer) John Tromp devised an interesting visualization of terms in the λ-calculus. In his words: abstractions (lambdas) ...
3
votes
0answers
45 views

Compute the RFC 2550 timestamp

RFC 2550 is a satirical proposal (published on April 1, 1999) for a space-efficient ASCII representation of timestamps that can support any date (even those prior to the beginning of the universe and ...
10
votes
3answers
180 views

My “keybore” is key-boring me! Help me find a minimal keystrokes

Credits to @Agawa001 for coming up with this question. Explanation My new "keybore" only has 2 buttons, namely + and -. The number in the memory starts at 0. Each consecutive press of + or - will ...
10
votes
6answers
378 views

Longest arithmetic subsequence

Given a non empty finite sequence of integers, return an arithmetic subsequence of maximal length. If there are multiple of the same maximal length, any of them can be returned. Definitions: An ...
10
votes
21answers
446 views

Alternating Sign Sequence

Introduction The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the ...
4
votes
1answer
112 views

Approximate the Fransén-Robinson constant

Given an input n, output the value of the Fransén-Robinson constant with n digits after the decimal place, with rounding. Rules You may assume that all inputs are integers between 1 and 60. You may ...
21
votes
12answers
1k views

Falsify brief truths

Find the longest run of true in a list of booleans. Return the same list, with all other trues falsified. Input, output A list; any usual format (e.g., a delimited list as a string). Details True ...
-1
votes
0answers
59 views

Written Integers [duplicate]

Task is to write a program that takes an Integer and outputs it's spoken form as a String. Examples: 12 outputs twelve 416 outputs four hundred sixteen 72135 outputs seventy-two thousand one ...
8
votes
12answers
846 views

Maximum Maxima!

Inspired by this question and refined by Luis Mendo. Challenge Given a 2D matrix of integers, each row has a maximum value. One or more elements of each row will be equal to the maximum value of ...
2
votes
9answers
680 views

Generate an infinite group of infinite galaxies

Here is the challenge as proposed by @trichoplax thanks to him for consolidating my post and standarizing it to PPCG common-rules. A galaxy is a group of numbers where each one is mapped to ...
4
votes
17answers
1k views

Illiteral Prime numbers

Your challenge is to write a program (full program, not a function), that will take an integer and output all prime numbers up to (including) the given integer. Output is any readable list containing ...
5
votes
5answers
254 views

Make the lowest number square that equals n

A number square containing the values 1, 2, 3, 4 looks like this: 12 34 To work out what a number square is, you first make four numbers by reading across the rows and across the columns; for the ...
43
votes
24answers
1k views

Generate Wordenticons

Identicons are visual depictions of hash values, often made from symmetrical arrangements of geometric shapes. Your default Stack Exchange avatar is an identicon. This challenge is about creating ...
-3
votes
0answers
57 views

Syllable Counting Through Dictionary.com Data-mining [on hold]

Syllable counting is a natural language processing task which can be difficult to pull off without drawing from a database, and there aren't always great APIs out there as they require expensive ...
15
votes
4answers
522 views

Correct way to add numbers to get lots of 8's

Inspired by this question which was further inspired by this one, write a program which takes two integers and adds them in a unique way, by performing an OR operation on the segments used to display ...
2
votes
5answers
205 views

Is the gas lighter than air?

Air balloons need a gas that is lighter than air. However, hydrogen is flammable, while helium is not sustainable, so we need a replacement! You must write code that determines whether any given gas ...
3
votes
3answers
164 views

Surjective, Injective, Bijective, or Nothing?

Given a mapping from the integers from 1 to N to the integers from 1 to N, determine if the mapping is surjective, injective, bijective, or nothing. You may choose any character/digit for the four ...
14
votes
1answer
221 views

Parse a 1D language

Given a string containing only 0's 1's, 2's and brackets, output the grammar tree of the string. A 2 requires 2 arguments - one to the left and one to the right A 1 requires a single argument - to ...
12
votes
1answer
187 views

Convert ASCII box drawing into Unicode

I am shamelessly posting a request for something I would actually find useful. The task is to take an arbitrary ascii box drawing like this | +----+----+ | state A +---+ +---------+ | ...
14
votes
20answers
1k views

Separate alphabets and numbers

A paragraph of text has numbers and alphabetic letters mixed. Your task is to separate the numbers to the left side and the alphabetic letters to the right side in the same order of each line. ...
15
votes
20answers
3k views

Female and Male Sequences

This question is probably harder than all of those "generate a sequence of numbers" tasks, because this requires TWO sequences working in unison. Really looking forward to the answers! In his book ...
24
votes
34answers
2k views

Mean bits: an average challenge

Given an integer N >= 1, output the mean number of bits in an integer from 0 to N - 1 Specification The output can be calculated as the sum of the number of bits in the binary representation of ...
2
votes
5answers
287 views

Include a JavaScript script with JavaScript

To dynamically include a JavaScript file in a web page, you'd normally insert a <script> tag pointing to your script. For example: var js_file= document.createElement("script"); ...
1
vote
2answers
147 views

Nine Nines of Uptime

Uptime is a very important metric, as we all know, so we'd like to measure the uptime since our service was first launched. The SLA specifies an uptime of a certain number of nines, such as 3 nines ...
11
votes
3answers
198 views

AppleSauce Fader

Back in the day, all the 1337 kids used text faders in chatrooms. I don't know about you guys, but I want to feel cool like they did. The only problem is that their old scripts and applications were ...
11
votes
7answers
343 views

Find a function with cycles of every length

A function is said to have a cycle of length n if there exists an x in its domain such that fn(x) = x and fm(x) ≠ x for 0 < m < n, where the superscript n denotes n-fold application of f. Note ...
15
votes
19answers
936 views

Greatest Number in a Range When The Sum of Squares of its Prime Factors are Subtracted

The formula Take for instance the number 300 The prime factors of 300 are [2, 3, 5] (unique numbers that are factors of 300 and prime) Squaring each of those numbers will give you [4, 9, 25] ...
23
votes
6answers
2k views

Golf a golf-scorer

As a kid, I used to play the card game "golf" a lot. Your challenge, should you choose to accept it, is to calculate the score of a golf hand. Since there are over 9000 variations on this card game1, ...
8
votes
26answers
2k views

The Nine Pattern

Introduction I stumbled across this (useless) pattern the other day while I was watching TV. I named it "the 9 pattern" because the first number to use it was 9. The gist of it is, you enter a number ...
7
votes
7answers
220 views

Largest Distinctly Sum-Free Partition

related and inspired by -- Finding sum-free partitions A set A is defined here as being distinctly sum-free if 1) it consists of at least three elements, |A| ≥ 3, and 2) its distinct self-sum A + ...
21
votes
23answers
958 views

Divisor reduction

A divisor of a number n is any number that evenly divides n, including 1 and n itself. The number of divisors d(n) is how many divisors a number has. Here's d(n) for the first couple n: n divisors ...
7
votes
8answers
1k views

On the Subject of Passwords

In Keep Talking and Nobody Explodes, players are tasked with defusing bombs based on information from their "experts" (other people with a manual). Each bomb is made up of modules, one of which can be ...
-3
votes
0answers
82 views

Output the first character at least ten thousand times in Lazy K [closed]

In the fewest number of terms (application/parentheses are free), write a lazy K program that takes a single character of input and outputs it a fixed finite number of times which is at least ten ...
30
votes
17answers
2k views

Print the nth prime that contains n

This question will be a twist on finding the nth prime number. Challenge You must write a program that will take one input n, and output the nth prime number whose decimal representation contains ...
7
votes
7answers
388 views

Get the most dominant color!

In this challenge, your task is to write a program that takes in an image and returns the most dominant color in it. Dominant color here means the color with which most of the image is covered (see ...
3
votes
2answers
131 views

Chaining Words Together

Given two words and a list as input, your program must (in as few characters as possible, of course) find the shortest way to "chain" the first word to the last using the ones in the list. Two words ...
8
votes
8answers
309 views

Calculate the Numpad Taxicab

Credit goes where credit is due Given two digits, x, and y, calculate the shortest number of horizontal or vertical jumps to get from x to y on a standard numpad, e.g. 789 456 123 00 You can ...
6
votes
1answer
136 views

Judge Some Titrations

In chemistry class, we were learning about titrations, and attempting one as a lab. We were using phenolphthalein as the indicator for the titration, so on top of grading the lab normally, my teacher ...
-14
votes
11answers
199 views

Output the alphabet using the alphabet

The title is pretty self-explanatory, isn't it? Your task is to output the alphabet (the string "abcdefghijklmnopqrstuvwxyz") to STDOUT, using each and every letter of the alphabet in your program ...
4
votes
14answers
667 views

Find the number I/O shortest algorithm

Find the shortest function/algorithm to translate these numbers to the ones after the dash: 0 - 0 1 - 10 2 - 20 3 - 30 4 - 40 5 - 50 6 - 60 7 - 70 8 - 80 9 - 90 10 - 100 11 - 115 12 - 130 13 - 150 14 ...
15
votes
32answers
1k views

Toggle a string

The challenge involve simply toggling a string within another string. Explanation If the toggle string is a substring of the main string, remove all instances of the toggle string from the main ...
10
votes
1answer
180 views

RegEx-golf: match all contents in a string

Your task is to write a RegEx that matches everything inside strings. A string is defined as everything surrounded by (but not including) two unescaped ". A " can be escaped by \, which can also be ...
3
votes
7answers
182 views

Randomly Assign People to Tasks

The challenge is to assign people to tasks randomly~. From stdin you get 2 lines. Line one is a comma-separated list of names. Line 2 is a comma-separated list of jobs. The output required is one line ...
-1
votes
2answers
138 views

Find words that rhyme [closed]

Challenge Joe the rapper is struggling with rhyming words in his lyrics. He needs your help. For this situation, we will use rhymes where the last syllable in a word is the same as the other word ...
4
votes
1answer
211 views

Let's play ASCII mini-golf [closed]

Let's play code golf... by playing golf. Input Your input will be a string consisting of #'s, an o, an @, and .'s. For example: ......@.. .....##.. ......... ......o.. . - playable golf course ...
30
votes
19answers
4k views

Will the beam hit?

A laser shoots a straight beam in one of the four orthogonal directions, indicated by <>^v. Determine whether it will hit the target O on a rectangular grid. Each of these will hit (True): ...
17
votes
7answers
862 views

Normal and visual string reversion

Write some code that acts as a cat program. That is, to input a string and output it as is. But the normal reversion of your code must output the normal reversion of the input string. And the visual ...
10
votes
1answer
161 views

Recursive Steiner Chains

Steiner Chains are a set of N circles where each circle is tangent to 2 other non-intersecting circles as well as the the previous and next circles of the chain, as seen in the below images: In ...