Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [code-golf]

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, please state this explicitly in the challenge. If source code length is not the primary scoring criterion, consider using another tag instead.

4
votes
0answers
29 views

Convert an ASCII art table to a UTF-8 table

When I write documentation, comments, etc. I love making ASCII tables. They usually end up looking pretty good, but I always feel that they could look even better - especially since UTF-8/Unicode ...
0
votes
13answers
90 views

String analayser

Use any programming language to display "AWSALILAND" in such a way, so that each letter is in a new line and repeated as many times as its position in the English alphabet. For example letter, (A) ...
5
votes
5answers
192 views

Japanese pitch accent numbers

Your challenge is to turn a Japanese word and a dictionary pitch accent number into a new string where the rises and falls in pitch are marked: e.g. (2, ウシロ) → ウ/シ\ロ...
18
votes
22answers
2k views

Print a Wavy String Line-by-Line

Challenge Write a program or function that takes in a string s and integer n as parameters. Your program should print (or ...
18
votes
12answers
2k views

A Semi-palindrome Puzzle

An palindrome is a word that is its own reverse. Now there are some words that might look like palindromes but are not. For example consider the word sheesh, <...
30
votes
38answers
5k views

List all possible titles for the Anno games

In the Anno video game series there are 6 games with a 7th one announced for early 2019. Their titles always feature a year in a specific pattern: ...
20
votes
24answers
2k views

Minimal Power Root

The minimal power iteration of a number \$n\$ is defined as follows: $$\text{MPI}(n):=n^{\text{min}(\text{digits}(n))}$$ That is, \$n\$ raised to the lowest digit in \$n\$. For example, \$\text{MPI}(...
7
votes
5answers
246 views

Multiply numerical polynomials

A numerical polynomial is a polynomial \$p\$ in one variable with rational coefficients such that for every integer \$i\$, \$p(i)\$ is also an integer. The numerical polynomials have a basis given by ...
1
vote
2answers
161 views

(Javascript) itertools.groupBy, e.g. [0,0,1,1,0] -> [[0,0],[1,1],[0]]

(language-specific challenge) Specification: Language: ECMAScript, any version[1] Challenge: Somewhat like python's itertools.groupBy: Your function ...
16
votes
32answers
2k views

Text compression

With the given text below, there are some words in the text that repeats several times in the text. Use any programming language to write a short code that compresses the text to display it. Or in ...
10
votes
1answer
128 views

Tatamibari solver

Background Tatamibari is a logic puzzle designed by Nikoli. A Tatamibari puzzle is played on a rectangular grid with three different kinds of symbols in it: +, <...
21
votes
12answers
1k views

What numbers are these?

While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&-like characters. And even ...
6
votes
3answers
156 views

Chiral three dimensional texts

Two dimensional chiral objects are not chiral in three dimensional space. This is because you can flip them over which is equivalent to taking the mirror image unlike in two dimensions where only ...
2
votes
11answers
342 views

Cycle my input please [duplicate]

Input A string s of printable ASCII characters, newlines, and spaces (0x20 ( ) to 0x7E (~)),...
15
votes
2answers
470 views

Pentomino 6x10 solution normalizer

As you most probably now, there are 2339 solutions to pentomino puzzle in a 6x10 grid. There are different labeling schemes for the 12 pentominoes, two of them are shown on the image below: Image ...
15
votes
15answers
2k views

Output the anti-clockwise inward spiral of a 2D array

From this stackoverflow question Given a 2D array of size \$ M \times N \$, output the values in a anti-clockwise fashion. The output must start from the outside to the inside and the initial point ...
1
vote
2answers
130 views

Accordion Solitaire: Which First Moves Can I Make?

Introduction: Unfortunately an Accordion Solitaire Solver challenge already exists (Solve a game of Accordion), so instead this easier related challenge. Let's start by explaining how Accordion ...
-1
votes
0answers
37 views

Sorting of XML with XSLT by Tag Name [closed]

i have a little problem that i can't solve. I have an XML file an want to sort it with XSLT. The other sorting with XSLT worked, but not this problem. I have an XML-file like that an i want to sort ...
2
votes
1answer
211 views

Longest Seven Segment Word

This question was inspired by Tom Scott's video here. The English language has plenty of words, but what's the longest one that can be displayed on a seven segment display? Your challenge is given a ...
30
votes
22answers
5k views

Can the number be split into powers of 2?

Yesterday while playing with my kid I noticed the number in his toy train: So we have $$4281$$ that can be split into $$4-2-8-1$$ or $$2^2-2^1-2^3-2^0$$ So simple challenge: given a non-negative ...
16
votes
13answers
1k views

Arbitrary Length Hashing

Consider you have a hash function \$\mathcal{H}\$ which takes strings of length \$2n\$ and returns strings of length \$n\$ and has the nice property that it is collision resistant, i.e. it is hard to ...
12
votes
5answers
361 views

ASCII Calendar Planner

Given a list of activities and their start time/date, output an ASCII-art calendar showing the activities on the appropriate days. All activities are guaranteed to be in the same month, no two ...
20
votes
14answers
5k views

One line Keyboard

The Challenge The goal of this challenge is to determine whether a given String can be typed using only one line of a standard UK QWERTY keyboard. This is ...
17
votes
8answers
2k views

Ternary-if Converter

In Java/.NET/C/JavaScript/etc. you can use ternary-ifs to shorten if-statements. For example (in Java): ...
-1
votes
0answers
69 views

Vigenere Cipher with a Catch [duplicate]

What is a Vigenere Cipher? The Vigenère cipheris a method of encrypting alphabetic text by using a series of interwoven Caesar ciphers, based on the letters of a keyword. It is a form of ...
15
votes
5answers
763 views

The Binary Fences

Input: An integer n in the range 2 <= n <= 10 A list of positive integers Output: Convert the integers to their binary ...
33
votes
37answers
4k views

Be there, for the square

Sometimes when you're lying in bed and reading a message, your phone screen will pop into landscape mode right in the middle of a sentence. Only being able to read left to right, you find yourself ...
4
votes
3answers
161 views

Optimizing edge selection from a list of numbers

You are given a list, L, with the length N. L contains N random positive integer values. You are only able to select from the outer edges of the list (left/right), and after each selection every value ...
18
votes
26answers
3k views

Converting a number from Zeckendorf Representation to Decimal

About Zeckendorf Representations/Base Fibonacci Numbers This is a number system which uses Fibonacci numbers as its base. The numbers consist of 0 and 1's and each 1 means that the number contains ...
6
votes
3answers
175 views

Scoring Chinese Hearts

Chinese Hearts, also known as Gong Zhu (拱猪, Chase the Pig), is a variance of the Hearts game. It is a 4 player card game with the aim to earn the highest amount of points. You may read more about it ...
17
votes
4answers
559 views

You are given a string to make and starting with the empty string, make it using appending and cloning cost

Your task is to create the given target string. Starting with an string that is empty, you will have to add characters to it, until your string is the same as the one we want. You can either add a ...
9
votes
24answers
892 views

Multiplicative undelta

Let us define the "multiplicative deltas" of values \$[\; a_0, \cdots a_N, \;]\$ as: $$ [\; a_1 / a_0, \cdots, a_{i+1} / a_i, \cdots, a_N / a_{N-1} \;] $$ The reverse operation - namely "...
10
votes
5answers
266 views

Amidakuji (阿弥陀籤) simplification

If you have ever had any exposure to Japanese or East Asian culture you will have surely encountered the Amidakuji game: As Wikipedia explains, it is a type of lottery drawn on paper and used to ...
-3
votes
0answers
30 views

Tower of Hanoi Solver [C++] [duplicate]

This question has been answered previously onTower of Hanoi Solver in all major computer languages. But i couldn't find C++. So can anyone write in C++? The Tower of Hanoi (also called the Tower of ...
13
votes
16answers
775 views

Length of a UTF-8 byte sequence

Determine the length of a UTF-8 byte sequence given its first byte. The following table shows which ranges map to each possible length: ...
13
votes
15answers
1k views

Logic Gates Manually

Make a program that simulates the basic logic gates. Input: An all-caps word followed by 2 1 digit binary numbers, separated by spaces, such as OR 1 0. The gates <...
14
votes
44answers
2k views

The max() is not enough

Intro A friend posed this question today in a slightly different way - "Can a single [Python] command determine the largest of some integers AND that they aren't equal?". While we didn't find a way ...
15
votes
9answers
581 views

Stagger, stack, sum

Inspired by this Stack Overflow question. The challenge Input An array of square matrices containing non-negative integers. Output A square matrix built from the input matrices as follows. Let \$...
15
votes
16answers
1k views

Supreme Sum String

Supreme Sum String Given an input string, return the word with the highest sum of each of its unicode characters. Rules The input should be seperated by whitespace The value of each word is based ...
12
votes
2answers
337 views

Making a Mountain out of a Molehill

You are given a string of terrain, with molehills and mountains: ...
16
votes
21answers
2k views

Same number letters

Letters of the words want fairness. They decided to appear same number of times in a sentence equally. Example: Priorities Will become: ...
17
votes
62answers
5k views

Display numbers lacking 2's

Display numbers from one to one-hundred (in increasing order), but number 2 shouldn’t appear anywhere in the sequence. So, for example, the numbers two (2) or ...
13
votes
8answers
1k views

Backhanded Compliments

This challenge is created in celebration of my first esoteric language, Backhand! Backhand is a one dimensional language with a non-linear pointer flow. The pointer moves three steps at a time, only ...
7
votes
43answers
2k views

Letters challenge

Using the word “conemon” print each character 2 times more than the last. The first letter, “c”, should be printed 10 times, the second 12 and so on. Each repeated-letter-string should be printed on a ...
15
votes
25answers
4k views

The Work Day Countdown

I just had I genius idea for making the work-life easier - a countdown to a specific date which only counts workdays. The basic task is to create a countdown to a specific date which only includes ...
9
votes
12answers
997 views

Different combinations possible

Problem Given a value n, imagine a mountain landscape inscribed in a reference (0, 0) to (2n, 0). There musn't be white spaces between slopes and also the mountain musn't descend below the x axis. ...
23
votes
20answers
1k views

Equalize the array

Challenge You are given an array \$a\$ of integers. With a move you can increase or decrease an element of the array by 1. Your task is to equalize the array, that is make all the elements of the ...
13
votes
5answers
449 views

Self Scoring Program

We have a challenge to output your own score, but it seems like all the answers there just hardcode the output and that's boring1. So lets have a new challenge. Your program must output its own ...
26
votes
18answers
3k views

Make them sum to 10,000

We've recently reached the threshold of 10,000 questions on PPCG. Hooray! Let's celebrate this with a simple challenge. Input Two integers \$A\$ and \$B\$, both in \$[1..9999]\$, such that \$A+B<...
10
votes
13answers
858 views

Multiply and Divide

Given a value x find the smallest numerical value greater than y that is capable of being multiplied and divided by x while retaining all original digits. The new numbers do not lose digits. The new ...