All Questions

Filter by
Sorted by
Tagged with
17 votes
13 answers
997 views

Enumerate all pure sets

In set theory, a set is an unordered group of unique elements. A pure set is either the empty set \$\{\}\$ or a set containing only pure sets, like \$\{\{\},\{\{\}\}\}\$. Your challenge is to write a ...
user avatar
  • 30.5k
18 votes
25 answers
2k views

Is it a valid list?

Given a string like [[[],[[]]],[]], made of only commas and square brackets, your challenge is to determine whether it represents a list. A list is either: ...
user avatar
  • 30.5k
18 votes
10 answers
1k views

Position from atomic number in the periodic table

Let us consider the following representation of the periodic table. ...
user avatar
  • 321
-11 votes
5 answers
222 views

12 with no 1234567890, but polyglot

This is my 12th question, so I thought of this idea. Goal: Output 12, with any preceding or trailing whitespace permitted In as many languages as possible (where different versions or flags count as ...
user avatar
15 votes
3 answers
584 views

Universal Unicode Clock

Plot contrivance You wake up to find that something has gone horribly wrong! Your time machine has malfunctioned and you are lost sometime between June 2022 and October 1991. You check the computer ...
user avatar
  • 88.3k
20 votes
20 answers
2k views

Iteratively delete a list

Say I have a ragged list, like: [ [1, 2], [3, [4, 5] ] ] And I want to iterate over each item and delete it one-by-one. However, I don't know the ...
user avatar
  • 30.5k
6 votes
1 answer
198 views

Find the Circle-Tangent Polynomials

Introduction A circle-tangent polynomial is a polynomial of degree \$N\ge3\$ or above that is tangent to the unit circle from inside at all of its N-1 intersection points. The two tails that exits the ...
user avatar
30 votes
5 answers
5k views

Can the 🐸 visit all the 🪷?

In this challenge you will be simulating a frog jumping from lily-pad to lily-pad in a pond. A frog's jump distance is uniquely determined by the size of the lily pad it jumps from. So for example ...
user avatar
  • 88.3k
15 votes
5 answers
2k views

Don't touch the walls!

Given a multi-dimensional rectangular array of non-negative integers, pad it with the minimal number of zeroes so that only zeroes are "touching the edges" of the array, in every dimension. ...
user avatar
  • 21.4k
20 votes
25 answers
3k views

Give f and g that sometimes commute

Let \$Z\$ be either the integers, the positive integers, or the non-zero integers; pick whatever's convenient. Give two functions \$f\$ and \$g\$, each \$Z \to Z\$, such that: \$f(g(a)) = g(f(a))\$, ...
user avatar
  • 1,221
12 votes
15 answers
2k views

Speed up, slowpoke!

In this king-of-the-hill challenge, you will program a bot, consisting of a python function of the form def BOTNAME(info, me, round): pass # ... main body ...
user avatar
19 votes
24 answers
3k views

Consecutive coin flips

This is a cross-post of a problem I posted to anarchy golf: http://golf.shinh.org/p.rb?tails Given two integers \$ n \$ and \$ k \$ \$ (0 \le k \le n) \$, count the number of combinations of \$ n \$ ...
user avatar
  • 17.6k
20 votes
16 answers
2k views

Print the power set of the power set ... of an empty set

Given a non-negative integer n, print the result of P(P(...P({}))), where the number of P's ...
user avatar
10 votes
6 answers
403 views

Parenthetical Names

Parenthetical names Your challenge is to build a program that puts parentheses around the 'title' part of names. For example, Sonic the Hedgehog is converted to <...
user avatar
22 votes
10 answers
2k views

Tell me how many there are, in Polish

Today, you're going to be writing Polish. No, not Polish notation—Polish, the actual language spoken in Poland. Given a number and a noun, output a Polish sentence telling me that there are that many ...
user avatar
23 votes
36 answers
2k views

Count /[^a-z]/ig with /[a-z]/ig

Write a program or function which takes a string of text as input and outputs the number of non-alphabetical characters in it (standard I/O rules apply). A non-alphabetical character is any character ...
user avatar
5 votes
0 answers
239 views

Sort my Cups︎︎︎︎︎︎︎︎︎︎ [closed]

I have a set of colored plastic cups. They come in four colors: green, yellow, pink, and blue. When I put them on my shelf, I like to stack them in a certain pattern. Your job is, given a list of any ...
user avatar
  • 3,350
17 votes
15 answers
2k views

Concatenatable numbers

Given a list of positive integers such as [69, 420], your challenge is to generate the sequence of numbers that can be formed by concatenating numbers from the ...
user avatar
  • 30.5k
-4 votes
0 answers
137 views

Good Rectangles and Evil Numbers

Good Rectangles and Evil Numbers This is meant to be a Puzzling Challenge: Good Rectangles and Evil Numbers - Integrated Original: https://puzzling.stackexchange.com/questions/116168/good-rectangles-...
user avatar
14 votes
11 answers
1k views

Make the list Fibonacci-like

Related, but not dupe. Challenge A list of integers \$a_1, a_2, a_3, \dots, a_n\$ (\$ n ≥ 1 \$) is Fibonacci-like if \$a_i = a_{i-1} + a_{i-2}\$ for every \$i > 2\$. Note that every list that ...
user avatar
  • 827
19 votes
12 answers
2k views

Detect Mongolian vowel harmony

The Mongolian language has "vowel harmony". In short the vowel harmony means that certain vowels are not allowed to be placed next to each other in a word. This means that suffixes of ...
user avatar
  • 88.3k
11 votes
12 answers
771 views

Permutations summing to permutations

Given an integer \$N\$ consider a permutation \$p=p_1,p_2,p_3,\ldots\$ of \$1,\ldots,N-1\$. Let \$P = p_1 , p_1+p_2 \bmod N, p_1+p_2+p_3 \bmod N, \ldots\$ be its prefix sums modulo \$N\$. Sometimes \$...
user avatar
20 votes
19 answers
2k views

Make a list flat

Lists can contain lists and we have nested lists. But we don't like nested lists and want to flatten them. By flattening I mean create a list which does not contain any list, but elements of lists it ...
user avatar
16 votes
8 answers
2k views

Scribble Pad for Nerds

aka. implement an easier version of 05ab1e's canvas element. Description The canvas element is used to draw ASCII lines on the screen. The (easier version of the) canvas element takes a list of ...
user avatar
  • 4,423
0 votes
0 answers
68 views

How much more to a repdigit? [duplicate]

Challenge By Wikipedia, a repdigit is a natural number composed of repeated instances of the same digit. For example, \$0\$, \$1\$, \$33\$, \$555\$, \$9999\$ are repdigits, while \$10\$, \$121\$, \$...
user avatar
  • 827
12 votes
14 answers
635 views

Increasing permutation trees

For this challenge a "binary tree" is a rooted tree where each node has 0 children (leaf) or 2. The children of a node are unordered, meaning that while you might draw the tree with left ...
user avatar
  • 88.3k
9 votes
9 answers
485 views

Two In One: Guess That Language - Robbers

Cops' challenge This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-...
user avatar
18 votes
14 answers
1k views

Two In One: Guess That Language - Cops

Robber's challenge This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-...
user avatar
14 votes
4 answers
403 views

Fill the rectangle

Challenge In this challenge, you have to fill an \$M\$ x \$N\$ rectangle grid with the most \$A\$ x \$B\$ rectangle pieces possible. Requirements: The sizes of the \$M\$ x \$N\$ rectangle grid is ...
user avatar
  • 827
6 votes
7 answers
388 views

Durable Durations

Introduction Time is a really simple concept. Seconds pass, one after the other, all the same. But humans love making it hard. This Stackoverflow question has gathered many answers and even though ...
user avatar
  • 169
13 votes
12 answers
701 views

Count alternating permutations

An alternating permutation is a permutation of the first \$ n \$ integers \$ \{ 1 ... n \} \$, such that adjacent pairs of values in the permutation alternate between increasing and decreasing (or ...
user avatar
  • 21.4k
5 votes
0 answers
62 views

Tips for golfing in J-uby

J-uby is the Language of the Month for June 2022, so I'm looking for tips for golfing in it. As usual, please post one tip per answer, and avoid general tips such as "remove whitespace" or &...
user avatar
  • 6,460
11 votes
17 answers
1k views

Extract the contained powers of two!

Take as input an integer in any reasonable format. Then, output all the proper sub-strings of the base-10 digits of that integer that are powers of two, in any reasonable format. Test cases ...
user avatar
17 votes
9 answers
2k views

How many light changes will a 7-segment display need?

Problem Assume you have a single 7-segment display without a decimal point, so 7 "lines" that can be labelled A through G as seen here. This display will only show the numbers from 0 to 9 ...
user avatar
  • 287
21 votes
22 answers
10k views

`lol` is an ambigram, `dad` isn't

Given a word, decide if it is an ambigram. When rotated: b > q d > p l > l n > u o > o p > d q > b s > s u > n x > x z > z Assume ...
user avatar
14 votes
8 answers
2k views

But is it a pretty place?

Your challenge, should you choose to accept it, is to take as input: A program in DirectionLang (as an ASCII string consisting of DirectionLang instructions) A list of pairs of integers, henceforth ...
user avatar
23 votes
18 answers
3k views

What's the best die to roll?

The "standard" polyhedral game dice have 4, 6, 8, 10, 12 and 20 sides. (Yes, I know that there are two 10-sided dice which together make a d100, but we're ignoring that right now.) If I want ...
user avatar
  • 88.3k
5 votes
1 answer
1k views

fastest matrix multiplication on x86

This challenge requires integration with C, so you can stop reading if you're not interested. Matrix multiplication is a simple operation, but the performance depends a lot on how efficiently the code ...
user avatar
  • 2,213
10 votes
6 answers
715 views

Counting Rhythms

The Narrative You are a bad musician. You never bothered to learn how to count rhythms. To remedy this shortcoming, you decide to write a program that will tell you how to count in any given time ...
user avatar
  • 1,207
28 votes
20 answers
4k views

Add a hidden language to a polyglot

Inspired/mostly copied but I don't think it's a dupe. Also Inspired. In this challenge, you will create polyglots that include all languages from previous answers, and another language which you won't ...
user avatar
  • 30.5k
7 votes
4 answers
859 views

Invert a Non-commutative Function

Intro Imagine a list of elements and their outcomes when some non-commutative function is applied to them. For example, we will use the elements Rock, ...
user avatar
19 votes
15 answers
1k views

Sample integers that sum to one hundred

Given a positive integer n, randomly output n non negative integers that sum to one hundred. n will be at most 200. The output should be present as a list of integers (not sorted). Your random sample ...
user avatar
  • 393
12 votes
5 answers
479 views

Whyte Notation Translator

Whyte Notation is a classification method mainly for steam locomotive, that classifies by wheel arrangement. On a steam locomotive ( we're only focusing on non articulated locomotives here ), the ...
user avatar
15 votes
10 answers
723 views

Determine Uilta Pitch Accent

Uilta is a minority tungusic language spoken in the far east of Russia. A neat thing about Uilta is that it has pitch accent which can be predicted by a computer program. In this challenge we are ...
user avatar
  • 88.3k
7 votes
12 answers
547 views

Calculate the Lowest Even-Harmonic of the Values in a List

PROBLEM For a list of numbers, list: Find the lowest possible integer, x, which is optimally close to the whole number even-...
user avatar
1 vote
0 answers
133 views

Figure out the least amount of duplicate data to fill a quota [closed]

You are given 100 arrays/sets of 5-8 numbers between 1-20. If you combine all the arrays you will always get at least one of each number (1-20), so don't worry about an "unsolvable" case. ...
user avatar
7 votes
1 answer
214 views

Find run ascending lists faster

In this question I asked you to determine if a run ascending list could be made. It was code-golf so naturally most the answers are very slow. But what if we want it to be fast. In this challenge I ...
user avatar
  • 88.3k
18 votes
13 answers
2k views

Straighten my corners... diagonally

We can arrange the positive integers like this: 1_| 2 | 5 | 10 4___3_| 6 | 11 9___8___7_| 12 16 15 14 13 That is, in L-shaped brackets expanding down and right ...
user avatar
  • 30.5k
34 votes
37 answers
4k views

Previous Fibonacci number

The sequence of Fibonacci numbers is defined as follows: \$ F_0 = 0 \\ F_1 = 1 \\ F_n = F_{n-1} + F_{n-2} \$ Given a Fibonacci number, return the previous Fibonacci number in the sequence. You do not ...
user avatar
  • 21.4k
18 votes
29 answers
2k views

Reverse hex cipher

Characters in strings are sometimes represented as their ASCII hexadecimal codes. Printable characters have two hex digits in their representation. Swapping those digits leads to another character, ...
user avatar
  • 11.7k

15 30 50 per page