text stringlengths 180 608k |
|---|
[Question]
[
## Background
This puzzle is a variation on the [four fours puzzle](http://en.wikipedia.org/wiki/Four_fours) (itself the topic of a [past question](https://codegolf.stackexchange.com/questions/12063/four-fours-puzzle)). Like that puzzle, the aim is to find mathematical expressions for different whole n... |
[Question]
[
The number of partitions of an integer is the number of ways that integer can be represented as a sum of positive integers.
For example:
```
5
4 + 1
3 + 2
3 + 1 + 1
2 + 2 + 1
2 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1
```
There are 7 ways to represent the number 5, therefore 7 is the partition number correspondin... |
[Question]
[
You will choose *m* languages and write *n* programs in each language, each with length *n\*m*. The *k*th program should output the *k*th character of each program, ordered by the program number.
For example, in this submission (for demonstration only; they can be any characters including newlines and ... |
[Question]
[
## Challenge:
Draw **Sri Yantra**.
## How to:
There are different ways to draw it. All include many steps. If you think you can draw it without following the linked steps scroll below for the **elements you must have in your drawing**.
Complete steps can be found here:
<http://www.saralhindi.com/Shri_Y... |
[Question]
[
Lets say I was writing something, and I accidentally wrote it in the wrong box:
```
+-------+--------+
| Verbs | Nouns |
+-------+--------+
| Truck | |
| eat | Banana |
| | Car |
+-------+--------+
```
So I, being lazy, merely draw an arrow to the space it should be:
```
+-------+---... |
[Question]
[
**Input:** An array **I** of **k** positive integers. The integers will be no larger than 100 and **k ≤ 100**.
**Output:** Your code must output all possible arrays **O** of non-negative integers of length **k** with the restriction that **0 ≤ Oi ≤ Ii**. To get from one array to the next you may add or... |
[Question]
[
I love functional programming in Octave, but it's rather unwieldy in practice. I'm wondering about the shortest way to define an anonymous recursive function.
I have some ideas, but I'm wondering if there is a way to combine these ideas to make them even shorter (or equally short but more versatile). F... |
[Question]
[
### Background:
Pi (`π`) is a [transcendental number](https://en.wikipedia.org/wiki/Transcendental_number), and therefore it has a non-terminating decimal representation. Similar, the representation doesn't terminate if written in any other integer base. But what if we wrote it in base `π`?
Digits in d... |
[Question]
[
If we define a Fibonacci-like sequence as **fk(n) = (fk(n-1) + fk(n-2)) % k**, for some integer **k** (where **%** is the modulo operator), the sequence will necessarily be cyclic, because there are only **k2** different values for **(fk(n-1), fk(n-2))**. However, this cycle doesn't usually include *al... |
[Question]
[
[Fermat numbers](https://oeis.org/A000215) are positive integers that can be expressed as 22x+1 with an integer x.
Let us now define an attribute of a number called "Fermat-ness":
* The Fermat-ness of the number is one less than the length of the chain of powers of two, starting from the base, with pow... |
[Question]
[
**Overview**
In this challenge, you will be given two numbers which are both a small offset larger than a multiple of a medium-size number. You must output a medium-sized number that is almost a divisor of both of the numbers, except for a small offset.
The size of the numbers involved will be paramete... |
[Question]
[
OEIS: [A167171](https://oeis.org/A167171)
A *dense number* is a number that has exactly as many prime divisors as non-prime divisors (including 1 and itself as divisors). Equivalently, it is either a prime or a product of two distinct primes. The first 100 dense numbers are:
```
2, 3, 5, 6, 7, 10, 11, ... |
[Question]
[
# Across the alphabet
In this challenge, you have trouble remembering the letters of the alphabet. To circumvent this, you go up and down the alphabet, till you get to the letter.
Because you want your code to be portable, you'll be writing it with letter blocks. You have a limited amount of letter bl... |
[Question]
[
## Task
Write a program or function that takes an image of width `w` and height `h`, and two integers `a <= w/2` and `b <= h/2`, and outputs an ascii art representation of the image, with the dimensions `a` x `b`.
The ascii art should be generated through the following steps (or another process with th... |
[Question]
[
The diamond square algorithm is a fractal terrain (heightmap) generating algorithm. You can find a nice description how it works here:
<http://www.gameprogrammer.com/fractal.html> (Used as a reference.)
<http://www.playfuljs.com/realistic-terrain-in-130-lines/> (Great JS implementation, perhaps you mig... |
[Question]
[
The [Four color theorem](http://en.wikipedia.org/wiki/Four_color_theorem) States that no more than four colors are required to color the regions of a map.
## The challenge
Given a list of State borders assign each state ID a color so that no two adjacent states have the same color. The output Should be... |
[Question]
[
## Reducing fractions *the wrong way*
In this code-golf challenge you have to find fractions that can be reduced the wrong way but still end up in the same number.
**Note:** reducing fractions *the wrong way* does here have an exact definition, see details.
Example:
64/16 = 64/16=4/1 = 4
Of course you ... |
[Question]
[
**Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers.
---
**Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/26778/edit).
Closed 9 years ago.
[Improve this question](/p... |
[Question]
[
Create the shortest program to check who has won in an nd tic tac toe game.
Your program should work when `n` (width) and `d` (dimension number) are in these ranges:
```
n∈[3,6]∩ℕ ie a number from this list: 3,4,5,6
d∈[2,5]∩ℕ ie a number from this list: 2,3,4,5
```
`n = 3; d = 2` (32 ie 3 by 3):
```
... |
[Question]
[
Write a program that performs *Polynomial Interpolation* using true arbitrary precision rational numbers. The input looks like this:
```
f(1) = 2/3
f(2) = 4/5
f(3) = 6/7
...
```
You may assume that there's exactly one whitespace before and after the `=` sign, all the numbers are either fractions or int... |
[Question]
[
Compare two numbers N1 = abc, N2 = def by constructing a function f(a,b,c,d,e,f) that:
* returns 1 if N1 > N2
* returns -1 if N1 < N2
**Note:** You are not required to return any value for any other relation between N1 and N2. e.g. when they are equal or when their relation is undefined (complex number... |
[Question]
[
Write the shortest program or function that mimics the addition in this [XKCD strip](https://xkcd.com/2637/):
[](https://i.stack.imgur.com/cEgxQ.png)
## Input
Two positive decimal integers containing only the digits `150`.
## Output
Th... |
[Question]
[
Write a program that translates an arithmetic expression to a Brainfuck program which evaluates the expression and prints the result in decimal numbers. For example, this arithmetic expression,
```
2 * (3 + 4)
```
can be translated to Brainfuck as,
```
++ 2
>+++ 3
>++++ 4
[-<+>]< add
<[>[->+>+<<]>[-<+>... |
[Question]
[
## Background
[**Shadow transform**](https://oeis.org/wiki/Shadow_transform) of a 0-based integer sequence \$a(n)\$ is another 0-based integer sequence \$s(n)\$ defined with the following equation:
$$
s(n) = \sum\_{i=0}^{n-1}{(1 \text{ if } n \text{ divides } a(i), 0 \text{ otherwise})}
$$
i.e. \$s(n)\... |
[Question]
[
[Dotcomma](https://github.com/Radvylf/dotcomma) is a simple esolang I made a while ago that only uses four operators: `[.,]`. In this challenge, you'll determine if a dotcomma program consisting only of `[.]` halts. Without `,`, there is no input, output, or queue, making this challenge possible.
**Blo... |
[Question]
[
With all the gyms closed down with the COVID-19 situation, we have to exercise with the weight we have lying around at home. The problem is, we have a small selection of plates at varying weights, and can't immediately determine if we can create a setup at the desired weight.
Given an unsorted array o... |
[Question]
[
Your task is to create a program that determines whether a given string is a valid regular expression or not using code snippets sourced from sites on the StackExchange network.
For the purposes of this challenge, the regular expression dialect will be a stripped down and mostly minimal set of meta-cha... |
[Question]
[
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 includes the [box drawing characters](https://unicode-table.com/en/blocks/box-drawing/). However, these cha... |
[Question]
[
### This is the followup challenge from [this one](https://codegolf.stackexchange.com/questions/166673/number-of-fifo-cache-misses), if you're confused please check that one out first.
---
First, let \$m(s, k)\$ be the number of cache misses a sequence \$s\$ of resource accesses would have assuming our... |
[Question]
[
# Pangrams
>
> The quick brown fox jumped over the lazy dog.
>
>
>
This is an example of a pangram - a sentence that contains every letter of the alphabet at least once.
A *self-enumerating* pangram is a sentence that fulfills the criteria to be a pangram by producing an analysis of its own letter ... |
[Question]
[
If a string **T** of length **K** appears **K** or more times in a string **S**, then it is *potentially communistic*. For example, `10` in `10/10` is potentially communistic, for it appears *2* times and is of length *2*. Note that these substrings cannot overlap.
A *communistic transformation* is one... |
[Question]
[
# Background
A [Lyndon word](https://en.wikipedia.org/wiki/Lyndon_word) is a non-empty string which is strictly lexicographically smaller than all its other rotations. It is possible to factor any string uniquely, by the [Chen–Fox–Lyndon theorem](https://en.wikipedia.org/wiki/Chen%E2%80%93Fox%E2%80%93L... |
[Question]
[
Many formulas in math involve nested radicals (square root signs inside other square roots signs). Your task here is to draw these using ascii art.
# Specs
You will be given two integers, the number inside the radical, and the number of radicals. I think the best way to explain what you have to do is w... |
[Question]
[
# Introduction
Bob likes to have different passwords for each website he uses. He wants passwords in a special format so that he can remember. Help him by building a password generator which is as short as possible in code length, because he likes keeping stuff short just like his name.
# Challenge
Bui... |
[Question]
[
## Challenge
Write a program which, using the XML data from the site [here](http://www.bleb.org/tv/data/listings/0/bbc1.xml), display the name of the programme which is currently showing on BBC 1.
## Information
All times are given at London time (GMT+1 at the time of posting and GMT+0 after the 30th O... |
[Question]
[
Credits to [@Agawa001](https://codegolf.stackexchange.com/users/38337/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 increment/decrement the memory for e... |
[Question]
[
[The inspiration for this challenge should be ridiculously obvious at the time of posting.](https://codegolf.stackexchange.com/q/70638/44713)
## The Task
You must create a Shut the Box style program (not function, program). The basics of shut the box are:
Players attempt to shut the box by turning a se... |
[Question]
[
Write a program or function that given some text, a number of columns, and the column width, formats the text into columns. This is plain text [typography](/questions/tagged/typography "show questions tagged 'typography'").
# Rules
## Input
* The text will be a string of printable ASCII and may contain... |
[Question]
[
I have some books and a bookshelf. I would like to put as many books on the shelf as possible but I have a rule. All dimensions of the books (height, width and depth) should form a non-increasing sequence on the shelf.
This means every books has to be at least as high as the ones after it on the self. ... |
[Question]
[
The difficulty with sharing pizza with friends is that it is hard to make sure that everyone gets the same amount of pepperoni on their slice. So, your task is to decide how to fairly slice a pizza so that everyone is happy.
## Directions
Write a program that, given a list of the positions of pepperoni... |
[Question]
[
# Strings with Context
For the purposes of this challenge, a *string with context* is a triple of strings, called the *left context*, the *data part*, and the *right context*. It represents a substring of a longer string. We use the vertical pipe `|` as a separator, so an example of a string with conte... |
[Question]
[
Pretty soon it's going to be [50 years](http://www.wired.com/thisdayintech/2011/04/0407ibm-launches-system-360-computers/) since IBM unveiled its [System/360](http://en.wikipedia.org/wiki/System/360) family of computers. These were the first to use the [EBCDIC](http://en.wikipedia.org/wiki/EBCDIC) char... |
[Question]
[
\$1729\$, known as the [Hardy–Ramanujan number](http://en.wikipedia.org/wiki/1729_%28number%29), is the smallest positive integer that can be expressed as the sum of two cubes of positive integers in two ways (\$12^3+1^3=10^3+9^3=1729\$). Given an integer \$n\$ (as input in whatever form is natural to ... |
[Question]
[
Create a function that takes a string of a pinyin syllable as the argument, and returns true of the combination exists, false otherwise.
Use "v" for "ü".
Here is a full list of combinations.
<http://www.pinyin.info/rules/initials_finals.html>
Examples
```
f("bu") == true
f("zheng") == true
f("nv") == t... |
[Question]
[
An [angry bird](http://en.wikipedia.org/wiki/Angry_birds) is shot at an angle \$β\$ to the horizontal at a speed \$u\$. The ground is steep, inclined at an angle \$α\$. Find the horizontal distance \$q\$ that the bird traveled before it hit the ground.
![diagram showing an inclined plane at angle α and... |
[Question]
[
# Challenge
Your task is to write a program or function which, given a positive integer \$N\$, finds all positive integers less than or equal to \$N\$ that can be expressed as a perfect power in more than one way.
# Definition
A perfect power is defined as a number \$i\$ found by \$m^k\$, where:
* \$m\... |
[Question]
[
# Objective
Given a [vertex figure](https://en.wikipedia.org/wiki/Vertex_figure) consisting of regular convex polygons, determine whether it represents a convex [uniform polyhedron](https://en.wikipedia.org/wiki/Uniform_polyhedron).
# What is a uniform polyhedron?
A uniform polyhedron is a polyhedron w... |
[Question]
[
# Problem statement
Pólya is playing about with his urn again and he wants you to help him calculate some probabilities.
In this urn experiment Pólya has an urn which initially contains 1 red and 1 blue bead.
For every iteration, he reaches in and retrieves a bead, then inspects the colour and places t... |
[Question]
[
[Its been a while since you killed that hydra](https://codegolf.stackexchange.com/questions/137980/become-the-hydra-slayer), you basked in the glory for years, but now people are calling you washed up, a has been. Well its time you prove them wrong, you've heard the whereabouts of annother hydra. Simpl... |
[Question]
[
Given a series of `o`s representing dots, connect them vertically or horizontally
## Examples
Input:
```
o o
o
```
Output:
```
o---o
|
|
o
```
---
Input:
```
o o o
o
```
Output:
```
o---o----o
|
o
```
## Spec
* If you want the input padded with spaces to form a rectangle, please spec... |
[Question]
[
# Overview
In this challenge, your task is to randomly generate a [monotonic mathematical function](https://en.wikipedia.org/wiki/Monotonic_function) between two sets.
# Input
Your inputs are two positive integers `s` and `n`.
After getting these inputs, your program shall generate a [random](http://me... |
[Question]
[
Make a plot (Poincare disk) of a tessellation on a hyperbolic plane, such as:
[](https://i.stack.imgur.com/yaMq2.png)
The program takes *four* inputs:
1) How many edges/polygon (three in this example).
2) How many intersect at each ver... |
[Question]
[
Consider a rectangular two-dimensional grid where each cell can either be empty (`.`) or full (`0`).
e.g.
```
..00....
0000....
.00000..
000...00
..000000
000.00..
```
The grid is considered infinite, all cells outside the depicted region are empty.
The goal is to cover the filled spaces and leave the ... |
[Question]
[
[Today's XKCD](http://xkcd.com/1529/) is a sports-tournament style bracket, where the contestants are well-known names, put into groups of possibly confusing names.
Give the probability that a given contestant will win the entire tournament, based on each contestant in a given round having an equal cha... |
[Question]
[
I have $15 in my pocket. Likewise, I am in a store which doesn't give change. While browsing, I spot an item that costs $10 (tax included). Can I buy that item without losing any money?
In this case, the answer is yes. No matter how my $15 is divided up (one 10 and one 5, or three 5s, or something else... |
[Question]
[
# Intro
Let's play some mini-golf! The golf ball is represented by a `.` and the hole by a `O`.
You want to get a hole in one on every hole, but you are not good at putting. In fact, you refuse to attempt putting diagonally! Only up, down, and to either side.
You plan to cheat by placing extra bumpers ... |
[Question]
[
Consider [compass-and-straightedge construction](https://en.wikipedia.org/wiki/Straightedge_and_compass_construction), where you can construct new points from existing ones by examining intersections of straight lines and circles constructed with one of the following two options:
* Draw the unique infi... |
[Question]
[
Alice and Bob are perfect logicians trapped on an island with a puzzle generator. Although they can instantly solve the Riemann hypothesis and P=NP just by thinking about it, rather than doing anything useful, they amuse themselves by giving each other puzzles. The setup is as follows: a positive integ... |
[Question]
[
About a year ago you were asked to find the [XOR primes](https://codegolf.stackexchange.com/q/66911/56656). These are numbers whose only factors are 1 and themselves when performing [XOR multiplication in base 2](https://codegolf.stackexchange.com/q/50240/56656). Now were are going to spice things up a... |
[Question]
[
Cheat is a card game where you're trying to get rid of your hand. A turn looks something roughly like this:
1. Determine what card rank you have to play that turn. In most variants this is one rank higher than the previous turn.
2. Play 1-4 cards, face down. These don't have to match the valid rank. If... |
[Question]
[
# Introduction
The game of [xiangqi](http://en.wikipedia.org/wiki/Xiangqi), also known as Chinese chess, is a chess-like game
popular in China, Vietnam, Taiwan, and other East Asian countries. The colours
of the two sides in xiangqi are red and black. There are seven pieces in
xiangqi: the general (`G`... |
[Question]
[
## Challenge
Given an ASCII art shape, you must find out whether the shape is a regular hexagon or not.
## Hexagons
A regular hexagon is defined using two rules:
* It has six sides
* Each side has equal numbers of characters
For example, the following shape is regular but it doesn't have six sides and ... |
[Question]
[
In races in which racers go around at least one turn of a curved track, the starting positions for each racer are staggered, so that each racer travels the same distance around the track (otherwise, the racer in the innermost lane would have a huge advantage).
Given the lengths of the major and minor a... |
[Question]
[
# The challenge
Given a 2d string representing the bottom of a boat as an input, you must determine whether or not the boat will float. This 2D string can be in whatever format is most convenient. (String with newlines, list of string, list of list of chars, etc.) Print a truthy value if it will float,... |
[Question]
[
**Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers.
---
This question does not appear to be about code golf or coding challenges within the scope defined in the [help center](https://codegolf.stackexchange.com/help/on-topic).
Closed last year.
[... |
[Question]
[
[Accordion](http://en.wikipedia.org/wiki/Accordion_(solitaire)) is a solitaire card game I recently came across where nearly every layout is solvable, but incredibly hard. You can play it [here](http://www.solitairenetwork.com/solitaire/accordion-solitaire-game.html).
## Rules
52 face cards are placed ... |
[Question]
[
**Cryptic Kicker**
A common but insecure method of encrypting text is to permute the letters of the alphabet. In other words, each letter of the alphabet is consistently replaced in the text by some other letter. To ensure that the encryption is reversible, no two letters are replaced by the same lette... |
[Question]
[
Circles and squares have a single, definite center point. However, the notion of the center of a triangle has long been discussed. Four different centers were known to the Ancient Greeks:
* [Incenter](http://mathworld.wolfram.com/Incenter.html): The intersection of the angle bisectors of the triangle
*... |
[Question]
[
Write a program to take a graph (from either standard input or a file, your choice) and find a shortest path in the graph.
Graphs are specified using the following format:
```
A---S F--T
| / \ |
| / 5 0
|/ \|
D----3--E
A-Z: nodes in the graph
-|/\: edges in the graph
0-9: weights o... |
[Question]
[
A *sentence* of number theory (for our purposes) is a sequence of the following symbols:
* `0` and `'` (successor) - successor means `+1`, so `0'''' = 0 + 1 + 1 + 1 + 1 = 4`
* `+` (addition) and `*` (multiplication)
* `=` (equal to)
* `(` and `)` (parentheses)
* the logical operator [`nand`](https://en... |
[Question]
[
>
> Pancake sorting is the colloquial term for the mathematical problem of
> sorting a disordered stack of pancakes in order of size when a spatula
> can be inserted at any point in the stack and used to flip all
> pancakes above it. A pancake number **P(n)** is the minimum number of
> flips required ... |
[Question]
[
# Background
Minifiers are used, commonly, when serving JavaScript to your Web Browser. It is commonly used to reduce the number of bytes that have to be sent. Saving bandwidth is useful for obvious reasons. Some people use obfuscaters (that intentionally make code harder to read), I am not talking abo... |
[Question]
[
A [quotation](https://en.wikipedia.org/wiki/Quotation) is "the repetition of one expression as part of another one". In American English, a quotation is surrounded by double-quotation marks ("), as in the previous sentence. However, this rule differs when a quote appears inside another quote. In this c... |
[Question]
[
Consider depicting a [simple](http://mathworld.wolfram.com/SimpleCurve.html), [open](http://mathworld.wolfram.com/ClosedCurve.html), two-dimensional curve on a W wide by H high grid of text where `X` represents part of the curve and `.` represents empty space and no other characters are used.
Every gri... |
[Question]
[
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:
[](https://i.stack.imgur.com/dN2Rn.png) [ is a category of fairy chess piece which moves by "jumping." A normal knight is a (1,2)-leaper, meaning each move involves moving a distance of 1 square in an orthogonal direction and 2 squares in the perpendicular direction.
```
.o.o.... |
[Question]
[
**Your task** is to output a single number; the number of ISO weeks that a given date range intersects. To quote Wikipedia: `An average year is exactly 52.1775 weeks long`, but this is not about the average.
**Input** consists of two space-separated ISO dates:
```
0047-12-24 2013-06-01
```
The end date... |
[Question]
[
## Challenge
Given an element name, output its electron configuration.
## Input
Your input will be the full name of each element (the range being from Hydrogen, 1, to Calcium, 20) with some exceptions - you should be able to account for the following inputs:
```
Natrium - This is sodium
Kalium - This i... |
[Question]
[
# Background
An atomic bomb has exploded near the fencepost factory!
Since fenceposts are essential for the survival of our civilization, we must rescue as many as possible.
We are sending radiation-resistant robots to search the area, and it is your task to program their artificial vision.
# Input
You... |
[Question]
[
**UPDATED SCORING**: *As this challenge is more difficult than I anticipated, I have adjusted the scoring. A program that can solve a single mirror input is a valid answer. More sophisticated programs get a bonus to their score.*
There have been several puzzles on PPCG to find a laser path in a box of
... |
[Question]
[
**Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers.
---
This question does not appear to be about code golf or coding challenges within the scope defined in the [help center](https://codegolf.stackexchange.com/help/on-topic).
Closed 7 years ago.... |
[Question]
[
How about giving the good ol' arcade game Frogger a revival, Code Golf-style!
Your task is to create a version of this classic game, with as few characters of code as possible. Use the language of your choice (libraries, like *jQuery* etc., are allowed).
## Requirements
* You have 3 lives, and lose 1 l... |
[Question]
[
## Problem description
Vertices \$V\$ of directed graph \$G=(V,E)\$ represent gossipping ladies; edge \$(u,v) \in E\$ signifies that lady \$u\$ knows of lady \$v\$ (which does not imply that lady \$v\$ knows of lady \$u\$). Assume that each lady knows of herself.
Intuitively, lady \$a\$ gossips about e... |
[Question]
[
Pyth is perhaps the most successful general-purpose golfing language. Though it is somewhat in [decline](https://codegolf.meta.stackexchange.com/questions/16561/what-happened-to-languages-like-cjam-and-pyth) as a result of newer languages, from 2014 to 2016 Pyth's concise syntax, constant updates, over... |
[Question]
[
You are given a string of terrain, with molehills and mountains:
```
/\
/ \
_/\__ / \
___/ \_/ \_
____/\___/ \___
```
Your job is to replace every molehill in the string with an equivalent mountain ... |
[Question]
[
Write 3 programs that do the following task:
Let A, B, C source codes of those three programs;
* if A runs BC is produced as output,
* if B runs CA is produced,
* if C runs AB is produced;
so each program writes a string (cycled for each program) and hides itself from it.
Additional, but essential cons... |
[Question]
[
**Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers.
---
**Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/116627/edit).
Closed 6 years ago.
[Improve this question](/posts/116627/edit)... |
[Question]
[
**The problem:** Write a function which, given a cycle length `n` and a number of cycles `m`, where 'm' is within `[2, n-2]`, generates `m` random cycles, each of length `n`, and all of which are [derangements](https://en.wikipedia.org/wiki/Derangement) of each other. Then `n=7`, for example, `m` could... |
[Question]
[
A vector partition is splitting a vector up a series of vectors such that their sum is the original. Here are a couple partitions:
```
[3, 1, 2] = [3, 1, 2]
[3, 1, 2] = [0, 0, 1] + [0, 0, 1] + [0, 1, 0] + [1, 0, 0] + [2, 0, 0]
[3, 1, 2] = [1, 1, 2] + [2, 0, 0]
```
Here vector addition is done element-w... |
[Question]
[
This is based off a previous deleted challenge of mine with the same name
### Introduction
You are tasked with writing a program that returns a truthy or falsey value based on if the input has all its XML-like1 tags appropriately opened and closed and in the right order. Consider the following as input... |
[Question]
[
This is thematically similar to [Generate keyboard shortcuts for a menu](https://codegolf.stackexchange.com/questions/29936/generate-keyboard-shortcuts-for-a-menu), but its actually a pretty different challenge.
Let's take PHPStorm's menu as an example:
```
New Project
New
Open Directory
Open
Open URL
... |
[Question]
[
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 either the left or right
A `0` doesn't require any arguments and is the base case
A pair of brackets c... |
[Question]
[
Given a `WxH` grid, how many possible mazes are there?
Things you know about the maze:
1. The grid is exactly `H` squares high and `W` squares wide.
2. There are three types of squares: Start, Finish, and Empty. Your maze must contain exactly 1 Start and 1 Finish, and all remaining squares are Empty.
3... |
[Question]
[
Your job, for this golf, is to write a program that will take moves of a game of [reversi (othello)](http://en.wikipedia.org/wiki/Reversi) and display the result to the user.
### Input
A string of numbers taken from the range [0-7]. Each pair of numbers represent first the X coordinate, then the Y coor... |
[Question]
[
Your challenge is to take input like this (a Hello World program):
```
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
```
And output a prompt (which will be `"> "`):
```
>
```
The user can then enter anything at the prompt. Your simple debugge... |
[Question]
[
Find Santa and his reindeer in a crowded scene.
## Input
Input will be on STDIN and will be a variable number of lines of characters of equal, but variable, length.
If Santa (represented by the character `S`) is in the scene, his sack of presents (represented by the character `P`) will be in one of the... |
[Question]
[
### Task
Suppose that `p` pepole have to split a bill; each of them is identified by a triple `(Name, n, k)` made up of:
* `Name`: *the name*;
* `n`: *the amount she/he has to pay*;
* `k`: *the amount she/he actually paid*.
The challenge here is to find out how much who owes whom.
### Assumptions
* Inp... |
[Question]
[
This challenge is completely ripped off*heavily inspired by* [All Light](https://play.google.com/store/apps/details?id=com.soulgit.allightflowpuzzle.gp), developed by Soulgit Games.
# Challenge
You are an electrician, and it's your job to wire up all the lights to the battery.
* The lights and battery ... |
[Question]
[
Input:
Firstly
An array of three cards representing the cards played by each player formatted like
```
[JD][TH][9S]
```
Representing
```
Jack of Diamonds, 10 of Hearts, and Nine of Spades.
```
As you always sit across from your team-mate in Euchre, the second element represents your team mate's play.... |
[Question]
[
Inspired by the [Lego gear ratios](https://codegolf.stackexchange.com/questions/7143/lego-gear-ratios) challenge by Keith Randall.
I, too, plan on building a giant lego robot that will eventually be able to destroy the other robots in the never-before-mentioned competition.\* In the process of construc... |
Subsets and Splits
Python Q&A Count
Counts the number of questions and answers related to Python in the dataset, providing insight into the prevalence of Python content.