# All Questions

13,232 questions
Filter by
Sorted by
Tagged with
51 views

### Program a compiler compiler

Program a compiler compiler Write a program, function, or likewise that takes in a BNF-like grammar specification(see below) and outputs a program or function in a language of your choice that takes ...
• 459
139 views

### Solve the Greek Computer Puzzle Toy [closed]

Solve the Greek Computer Puzzle Toy There is a small toy of a series of stacked dials -- loosely inspired by the Antikythera Device. The puzzle, made by Project Genius, has a series of dials that must ...
2k views

### A challenge for rookies

Print or return the following string: ...
• 12.2k
1 vote
103 views

### Is there a way to optimize this? [closed]

I tried solving the following problem by following the suggested approach to solving the problem in the problem tutorial. However, the online judge still says my solution exceeds the time limit. Is ...
• 19
190 views

### Rotatable numbers (Upside down) [duplicate]

Searching for rotatable numbers, like: 68089 If you consider numbers upside-down, 6 looks like ...
2k views

### smallest number of steps for a knight in chess

If you place a knight on any square of a chessboard, what is the smallest amount of steps to reach every position? Rules It is an 8 by 8 board. The knight starts at an arbitrary position, taken as ...
• 301
113 views

### Generate a Kirkman triple system

Given a universe of $v$ elements, a Kirkman triple system is a set of $(v-1)/2$ classes each having $v/3$ blocks each having three elements, so that every pair of elements appears in exactly ...
• 793
218 views

### Optimal strategy to defeat the wizard

Consider the following setup. An evil wizard has ten opaque boxes in front of him. Hidden from you, he chooses a random number of coins $x \in \{1 \dots 10\}$ and spreads them uniformly at random ...
• 643
444 views

### CGCC Rocket Biking

Something I found while looking through some old files. It seemed like a neat idea for a code golf challenge. The intro One of the most popular events at the annual Cyclist's Grand Competition for ...
• 1,003
243 views

### Change the quotations as if in Microsoft Word

I noticed that in Microsoft Word, single quotations are either or , but not in Notepad. Your task today is: given a string <...
659 views

### A better Hexagony template

We once made a Hexagony template without actually knowing it. But after a bit of experience with Hexagony, it becomes apparent that it is not enough; sometimes the source code is too short for the ...
• 64.8k
71 views

### Benchmark games, but polyglot code [closed]

Benchmark games can be fun: https://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/nbody.html But it's only monoglot code :( Can't we try to do them in polyglot instead? :)
2k views

### Seeing the queen's lasers

In chess, the queen piece can move arbitrarily far in each cardinal and intercardinal direction. What does this mean? Well, I'll show you with an ASCII drawing: ...
• 2,395
2k views

### Divisor of a string

Challenge Given a positive-length string $S$, a divisor of $S$ is another (not necessarily distinct) string for which there exists a number $a$ such that when we repeat the divisor $a$ times, ...
• 1,017
840 views

### Cartesian - polar conversion couple

We don't have a challenge for conversion between Cartesian and polar coordinates, so ... The challenge Write two programs (or functions) in the same language: one that converts from polar to ...
• 100k
60 views

### Polyglot for C and PHP [closed]

I was thinking of a compiler that spits out C/PHP polyglots, but not sure if possible. Main issue is the PHP opening/closing brackets, <?php and ...
2k views

### Anti-divisors of a number

Given a positive integer n, output all of its anti-divisors in any order. From OEIS A006272: Anti-divisors are the numbers that do not divide a number by the ...
• 64.8k
2k views

### Add parentheses to Polish notation

In most programming languages, arithmetic is written with infix notation -- i.e. the operator is put in between the operands -- e.g. 1+2. In contrast, with Polish ...
• 1,423
1 vote
198 views

### Find number components with lowest distribution

Let us assume that we have number X. Let us assume that we have positive integer "components" (C) of this ...
• 143
2k views

### Optimal strategy for wandering robots

Consider four agents sitting on four different number lines, all starting at the origin. In this game your only move is to choose one of the four agents to move. When you do that the agent you have ...
• 643
887 views

### Python: can I shorten this code further for checking substrings

So the golf question was like this: You are given a number T and then a total of T number of 17-character strings. For each of ...
• 143
2k views

### Implement String Projection

Given two strings: a string s and an alphabet a, implement string projection in the shortest code possible. String projection ...
• 3,233
666 views

### Help me golf this C program checking for string patterns in a sorted hand of cards

I could not think of a better title. This is a tips question. I'm asking for tips on golfing my code. I recently took part in a code golf competition in C. The competition ended and I lost. The ...
• 3,816
1k views

### PUT-PIXEL in every language

During work on some project I needed to draw pixels on screen. I found some put-pixel function in JS, but code was quite big and clumsy - so I wonder, how small put-pixel function can be... Challenge ...
732 views

### Tips for golfing in Knight

Knight is the Language of the Month for August 2022, and I noticed that it didn't have a tips page, so here it is! I'm looking for ideas which can be applied to code-golf problems and which are also ...
• 5,712
1k views

### Cryptic Multiplications

Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592. If now each digits is ...
• 2,153
1k views

### Find The Average String Between Two Strings

Inspired by this Your task today: given two strings, find the string with the lowest maximum Levenshtein distance to the input strings. For example, using Steffan ...
• 3,347
216 views

### Case Conversion Polyglot

Your task is to write a program that performs case conversion from plain text, and other case formats, into one of the specified formats below. Inputs will be either plain lowercase text, or one of ...
• 22.6k
439 views

### Train Route Planning

We can model a rail network as a directed graph, where each node is a train station and each edge is a train connecting two train stations. We'll assume that each train travels between its ...
• 3,197
2k views

### Remove redundant parentheses

Given a string containing some parentheses and some other ASCII printable characters, like this: (abc((123))(k)) your task is to remove any sets of parentheses that ...
• 1,635
293 views

### Encode the systematic binary Varshamov–Tenengolts code

Background Here on CGCC, a commonly seen subgenre is radiation-hardening – writing a program that works even if one character is deleted. A similar problem is studied in the field of coding theory: ...
3k views

### Transform characters of your choice into "Hello, world!"

Write a program or function that takes a character as input and outputs a character. Also, choose a list of 13 distinct ASCII printable characters (32-126). When a character from this list is passed ...
• 1,335
1 vote
201 views

### Decompose number N into the sum of three triangular numbers

It is known that any natural number can be decomposed into the sum of three triangular numbers (assuming 0 is triangular), according to Fermat's Polygonal Number Theorem. Your task is to come up with ...
• 35
2k views

### IE's Extra Robust Color Parsing®

Recently, I've found a rant from 2004 about Internet Explorer's color parsing. Turns out, MS made sure that just about anything will be parsed as a color somehow and I think it makes for a neat ...
• 1,003
2k views

### Generate all Possibilities of Words

This is not the same as m-ss-ng-lette-s Challenge: Given a string with masked characters, generate all possible words, inclusive of non-meaningfull words. Rules: The sequence of the characters in the ...
3k views

### Repeat Hello World according to another string's length

This was related to a program I am writing. Although the title is simple, the challenge is a lot more complicated. Your challenge You must write a program that takes an input, and your answer must ...