# Questions tagged [code-golf]

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

10,633 questions
Filter by
Sorted by
Tagged with
776 views

### Double trace of a square matrix

Inspired by a question (now closed) at Stack Overflow. Given a square matrix, let its double trace be defined as the sum of the entries from its main diagonal and its anti-diagonal. These are marked ...
101 views

...
1k views

### Find the smallest solution for this simple equation

Input 4 integers w, x, y, z from the range -999 to 999 inclusive where none of the values is 0. Output 4 integers a, b, c, d so that aw + bx + cy + dz == 0 where none of the values is 0. Restrictions ...
1k views

3k views

### Make S + S + ... + S as Large as Possible!

Let $S \subset \mathbb N_{\geq0}$ be a subset of the nonnegative integers, and let $$S^{(k)} = \underbrace{S + S + \dots + S}_{k\ \textrm{times}} = \{ a_1 + a_2 + \dots + a_k : a_i \in S\}.$$ For ...
1k views

### Alphabet Reconstruction

You are a historian studying a long forgotten language. You have just discovered a clay tablet which seems to list all known words in the language, in alphabetical order. Your task is to find this ...
2k views

### Crossing a river with weird animals

Background One kind of river-crossing problems involves two kinds of animals. One such problem reads like this: (all wordings, including animal species, are arbitrary) A farmer has to cross a river ...
3k views

### Is This Scrabble Board Valid?

Background Scrabble is a word game in which players collaboratively build a board consisting of letter tiles that spell words. Each word must be connected to another word, and players gain points ...
3k views

### Pythagorean triples given the hypotenuse

Definition (from Wikipedia) A Pythagorean triple consists of three positive integers a, b, and c, such that a² + b² = c². The typical example of a Pythagorean triple is (3,4,5): 3² + 4² = 9 + 16 = 25 ...
2k views

### Is it a prefix normal word?

Prefix normal words arise in the context of binary jumbled pattern matching. A binary word $w$ consisting of $0$s and $1$s is said to be prefix normal * if, among all of its substrings, none ...
2k views

### Swap Two Values in a List

Introduction: Although we have a lot of challenges where swapping two items in a list is a subtask, like Single swaps of an array; Swap to Sort an Array; $n$ swaps into a nop; etc., we don't have ...