Questions tagged [code-golf]

Code-golf is a competition to solve a particular problem in the fewest bytes of source code.

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

Appearing a unique number of times

Your task is to write a program or function that takes as input a list of positive integers and determines if there are any two integers in the list, that both appear the same number of times. For ...
15
votes
25answers
2k views

Ones and Twos for days

Inspiring myself on a recent challenge, we ought to compute a sequence that is very close to A160242. Task Your task is to generate the sequence \$ \{s_i\}_{i=0}^\infty \$: ...
13
votes
9answers
537 views

Smaller Strings in Printable ASCII base

Task Given a input string s which contains only printable ascii characters output all strings which contain only printable ascii characters and are strictly ...
11
votes
16answers
878 views

Progressing Two's

Given an positive integer n (including 0 if you decide to support it), output all numbers in the generated sequence up to the index ...
24
votes
20answers
2k views

How many balloons do I need in each corner?

You have a square board with a bunch of items laid out on it in one of a \$3 \times 3\$ grid of cells and you want to lift it up using balloons, but you can only attach balloons to the corners of the ...
16
votes
10answers
2k views

An unknowably odd function

This challenge initially appeared in this challenge as a an extra brain teaser. I am posting it with permission from the original author so that we can have a formal competition. Your task here ...
2
votes
15answers
541 views

Convert a decimal integer to binary only using arithmetic operators

There are 10 types of people in the world, those who understand binary and those who do not. Where are you? Let's see! Challenge Your task is to convert a decimal integer to binary, only using a ...
18
votes
15answers
1k views

(RGS 5/5) Computing the set of all set partitions with fixed sizes

Task Given a set of n unique elements and a multiset l of positive numbers that add up to n,...
25
votes
13answers
4k views

This highway needs rain across both of its lanes

In this challenge you will take a an ascii art image of a highway like so ...
5
votes
5answers
418 views

Special Character Coding Challenge - Check string for validity (Lots of rules) [closed]

There are 5 different "special characters": % & # $ ! These special characters are in a string with numbers. Like so: "5 ! 60%2$5.3" (valid). You must determine the validity of the string and ...
7
votes
6answers
319 views

Japanese Encoding Conversion

Background In JIS X 0208 a 94 by 94 map (kuten (区点)) is defined to encode Chinese characters (kanji), phonetic moras (kana) and other symbols. Along with this standard there are 3 different encodings ...
36
votes
15answers
3k views

Error-correct text

Correct a single-letter typo in a fixed text. Input: The paragraph below but with exactly one typo, where a single letter a-zA-Z is replaced by a different letter <...
14
votes
23answers
2k views

The SBEVE Challenge

She said s(he) be(lie)ve(d), he said sbeve. Input A non-empty string, s. It's guaranteed that s will have only printable ASCII ...
-4
votes
13answers
288 views

Convert a string to upper case without using built in methods/functions [closed]

Challenge You will be given a string as an argument. You need to convert that string to upper case. But you can't use any built in method or function nor any external programs. Rule No use of ...
18
votes
21answers
4k views

Print a list of iPhones

Write the shortest program that prints, in order, a complete list of iPhone iterations, according to this site: ...
25
votes
9answers
755 views

Mad Libs number sequences

My robot for generating Mad Libs-style sequence challenges has gone rogue! To defeat it, I need you to write code that can solve all the challenges it can crank out. Your input is three selections ...
1
vote
1answer
158 views

Summing intertwined terms of an array

I'm recieving 2-dimensional positions of two objects as a string with this format: x1,y1,x2,y2. The string is recieved from a ...
17
votes
16answers
879 views

(RGS 4/5) Inverting matrices modulo m

Task Given an integer matrix M and a modulus m, find an inverse of M modulo ...
33
votes
18answers
6k views

Bad factorial joke

Sometimes I make bad jokes... And a bad joke I like to make involves interpreting exclamation marks in sentences as the factorial sign. Task Your task is to write a program that receives a sentence ...
22
votes
27answers
5k views

When I grow up I want to be ASCII

Task Your task is to take a character in: AÁÀÃÂBCÇDEÉÊFGHIÍJKLMNOÕÓÔPQRSTUÚVWXYZaáàãâbcçdeéêfghiíjklmnoõóôpqrstuúvwxyz and turn it into a characters in: ...
20
votes
28answers
2k views

Alternating Triangles

Given a strictly positive integer n (therefore 0 isn't a valid test case), produce an approximate triangle of height ...
22
votes
10answers
3k views

Any lips images

Introduction The \$n\$-ellipse is a generalization of the ellipse with possibly more than two foci. Specifically, given \$n\$ points on the plane, called foci, the \$n\$-ellipse is the set of points ...
18
votes
3answers
508 views

All roads lead to Rome

"All roads lead to Rome" is a saying that essentially means there are plenty of different ways of achieving an objective. Task Your task is to write a program that finds a set of link connections ...
27
votes
27answers
3k views

(RGS 3/5) Help me write Portuguese!

Context (Feel free to skip, doesn't really matter for the algorithmic explanation of the task) European Portuguese is a fairly complicated language to learn, mostly because of its grammar. One ...
28
votes
45answers
4k views

How many petals around the rose

How many petals around the rose How many petals around the rose is a dice game you can play with your friends. Similar to "can I join the music box", there is a person that knows how the game works ...
10
votes
34answers
2k views

Find the number of integers in the range from 1 to N that ends with 2

Task As input you have: a positive integer N And you should output: The number of integers in \$[1,N]\$ (an inclusive range) which end with the digit \$2\$ in ...
-6
votes
3answers
240 views

Determine the Kth character in the concatenated string

You are given a list that contains \$N\$ strings of lowercase English alphabets. Any number of contiguous strings can be found together to form a new string. The grouping function accepts two integers ...
5
votes
2answers
276 views

Your Oscilloscope has ExPloDEd ! Make a sine wave [closed]

[ CODE GOLF] BAM! - Fire and Smoke Your Oscilloscope has exploded from one too many waves. Re-create these waves assuming the following: All waves are Sine Waves An amplitude of ...
22
votes
78answers
8k views

Scream very loudly

Write a script that outputs A to stdout infinitely. There shold be no newlines or seperators between the characters Standard loopholes apply This is code-golf. ...
23
votes
10answers
1k views

Embedding Sets of Sets

Setup: For two sets \$A,B\$, we say \$A \subseteq B\$ if every element in \$A\$ is also in \$B\$. Another way of saying this, is that we can order the elements of \$A,B\$ into two lists \$L_A,L_B\$, ...
20
votes
41answers
2k views

(RGS 2/5) How many strings can you count within these character classes?

Task Given a string composed of ASCII printable characters, return how many strings could fit the given pattern with character literals and regex-like ranges. Pattern string The pattern string ...
7
votes
1answer
224 views

Branch Out - Monkey Edition

The Monkey has swung home to find his tree all in pieces. He likes order and scoops up all his 'tree-parts' and sets them out in 3 groups. The Monkey's ...
15
votes
15answers
1k views

Square-Cube Digit Usage

The point of this challenge is to find the smallest positive integer that uses up at least all of the digits supplied in the input after it is squared and cubed. So, when provided an input such as <...
8
votes
6answers
521 views

Pairs of palindromic anagramic dates separated by a palindromic number of days

Definitions: A palindrome is a string which reads the same backward or forward (not counting spaces or special characters), such as "madam" or "Sorel Eros". A date is said to be a palindrome when ...
3
votes
5answers
233 views

String-wise calculus (i)

This will turn into a series involving other aspects of calculus, including using the "derivative" of a string to find "stationary points" etc, as well as "integration" of sentences Introduction If ...
1
vote
1answer
148 views

Polyglot “Hello world” in Fortran and Lisp [duplicate]

Simple challenge: The code must be both valid Lisp and valid Fortran, and must print out "hello world" in both. Note: I've sunk about 5 hours into this at this point, I'm not even sure it's possible ...
15
votes
23answers
2k views

Summing a sub-square of a quarter of an infinite chessboard

Description of the problem Imagine a quarter of an infinite chessboard, as in a square grid, extending up and right, so that you can see the lower left corner. Place a 0 in there. Now for every other ...
20
votes
8answers
975 views

Counting Distinct Real Roots of Low-Degree Polynomials

Challenge: I want to know about the real roots of polynomials. As a pure mathematician, I care about the existence of such roots, rather than their numeric values. The challenge is to write the ...
16
votes
1answer
570 views

Impress Donald Knuth by counting polyominoes on the hyperbolic plane

This challenge is inspired by a talk about Schläfli symbols, etc that I gave in a Geometry seminar. While I was putting together this challenge, I saw that Donald Knuth himself was interested in (some ...
29
votes
41answers
6k views

Is it really time?

A time in the format hhMMss is represented by six numbers in the range 0..9 (e.g.100203 for 3 seconds after 2 minutes after 10am (10:02.03), or ...
9
votes
5answers
477 views

Computing a specific coefficient in a quotient of polynomials

Context After "Computing a specific coefficient in a product of polynomials", asking you to compute a specific coefficient of polynomial multiplication, I wish to create a "mirror" challenge, asking ...
34
votes
45answers
3k views

(RGS 1/5) Binary multiples

A binary multiple of a positive integer k is a positive integer n such that n is written ...
13
votes
15answers
2k views

Is this a circular step sequence?

Background We define a circular step sequence of order \$n\$ as follows: $$ a_1, a_2, \dots, a_n = \text{Permutation of } 1 \dots n \\ b_i = \min ( |a_{i+1} - a_i|, n-|a_{i+1} - a_i| ), 1 \le i < ...
7
votes
18answers
841 views

Put in the quotes

Background There's a terrible problem in my console - the quotes never get included inside the arguments! So, when given this argument: ["abc","def","ghi","jkl"] ...
1
vote
0answers
39 views

Bracket Checker [duplicate]

Given a string of brackets tell the user whether or not the brackets are well matched or not. Brackets include []{}(). For example: ...
0
votes
4answers
512 views

Broken Keyboard

You're writing your favorite language and you want to display the following string: abcdefghijklmnopqrstuvwxyz to your happy customer. Unfortunately, your keyboard ...
26
votes
14answers
3k views

Toggle Shift Key

Objective Given an ASCII character, toggle its "shift-ness" on the standard US keyboard (ANSI-INCITS 154-1988 (R1999)), then output it. Mapping ...
4
votes
12answers
412 views

Creating words by structure

Context As a conlanger, I am interested in creating a uniform, naturalistic language. One of the tricks is to create vocabulary according to certain structures of words. An example from English: In ...
12
votes
14answers
2k views

Simulate a random walk

Context In this challenge, a random walk is a stochastic process in which a particle at a position with integer coordinates (or a drunk man) moves at each integer time step (that is, at ...
22
votes
22answers
2k views

Find self-locating strings in a number

Based on this Numberphile video A self-locating string is a number (or set of numbers) in a decimal expansion which corresponds to its location, from the start of the decimal. For example, take the ...