Share Your Experience: Take the 2024 Developer Survey

# Questions tagged [open-ended-function]

For challenges where an exact output is not required but some property must still be fulfilled.

106 questions
Filter by
Sorted by
Tagged with
2k views

### Output a 1-2-3-5-7... sequence

Follow-up of my previous challenge, inspired by @emanresu A's question, and proven possible by @att (Mathematica solution linked) For the purposes of this challenge, a 1-2-3-5-7... sequence is an ...
• 2,083
2k views

### Output a 1-2-3 sequence

For the purposes of this challenge, a 1-2-3 sequence is an infinite sequence of increasing positive integers such that for any positive integer $n$, exactly one of $n, 2n,$ and $3n$ appears in ...
• 2,083
1k views

### Horsey sightseeing

A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. For those who are not aware of how knights in chess work, knights are capable of ...
• 17.2k
981 views

### Output an infinitely proportional sequence

In this challenge, an infinitely proportional sequence is defined as a infinite sequence of positive integers such that: All positive integers are contained infinitely many times within the sequence. ...
• 38.4k
1k views

### Encode the input to exclude a given character (part 1)

Your task is to write 2 functions/programs. They may share code. The first function must, given a string and a character, output a new string that does not contain that character. The second function ...
• 12.6k
206 views

### Give the best Chaitin incompleteness bound

This was originally a pure mathematics question, but I think I've got the best chance for an answer here. The Challenge For concreteness, consider Peano Arithmetic (PA). For some language L of your ...
• 221
2k views

### Make a super fair number

An even distribution number is a number such that if you select any of it's digits at random the probability of it being any particular value (e.g. 0 or ...
• 98.8k
443 views

### Convert numbers to dice patterns

The way points are assigned on a dice follows a regular pattern, the center dot is present if and only if the number is odd. To represent the even numbers, pairs of dots on opposite sides of the ...
• 6,015
3k views

### Be big more often

Related You are a manager at a large number factory. You want to show everyone your business is doing well, by showing randomly chosen samples. Unfortunately, your business is not doing that well. But ...
703 views

### Prefix code generator

In this challenge, we consider an encoding from positive integers (up to a limit) to binary sequences. Some examples: ...
• 76.7k
3k views

### Give the fool's Fibonacci sequence

Recently I asked for tips on improving some code-golf of mine. The code was supposed to output every third value of the Fibonacci sequence starting with 2: ...
• 98.8k
710 views

### Generate all linked chains

A followup to this challenge by Jeremy Collprav, inspired by DLosc solving this in Regenerate. Some sections copied from the linked challenge. Linking chains We define a chain to be a string ...
• 49.9k
3k views

### Sudoku as a SAT problem

Background An interesting way to solve a Sudoku puzzle is to represent it as a Boolean satisfiability problem, and then feed it to a SAT solver. A Boolean Satisfiability Problem (abbreviated as SAT ...
• 48.2k
1k views

### Adjacent Items Sorting

Given a list, L, of sets of numbers like this: [[1], [0,2,3], [3,1], [1,2,3]] Output a single list of numbers such that 2 ...
• 12.6k
2k views

### Add two real numbers ... probably

The problem statement here is pretty simple, take two real numbers on the range [0,1) as input and output their sum, with probability 1. The catch here is that there are a lot of real numbers. There ...
• 98.8k
787 views

### Mapping Passing Through Point

(Inspired by this challenge.) Given six real values in three pairs: $(x_1, x_2), (y_1, y_2),$ and $(x_0, y_0)$, where $x_1 < x_0 < x_2$ and $y_1 < y_0 < y_2$, create a function ...
• 7,121
421 views

### Generate number from given range

Your function must accept three numbers in any order: A signed real number (or ±Infinity) - The number (N) for which you have ...
• 1,473
615 views

### Generate a permutation from the high-water marks

Given a permutation, we can define its high-water marks as the indices in which its cumulative maximum increases, or, equivalently, indices with values bigger than all previous values. For example, ...
• 10.5k
365 views

### Injectively saturate bit strings

It can be easily proven using Hall's marriage theorem that given fixed $n$ and $k<n/2$, there is an injective (one-to-one) function from all $n$-bit strings with $k$ ones to $n$-bit ...
• 3,737
1k views

### Approximate a root of an odd degree polynomial

Every odd degree polynomial has at least one real root. However this root does not have to be a rational number so your task is to output a sequence of rational numbers that approximates it. Rules ...
• 2,796
1k views

### Split some points

proposed by @Adám in chat Given an even number of finite points return a line $y=mx+b$ that evenly splits the points on both sides. Specs Take a list of distinct points $(x,y)$ (or a list of x-...
• 9,328
3k views

### Don't repeat yourself

In this challenge you will be tasked with implementing a sequence of natural numbers such that: Each number appears a natural number of times No two numbers appear the same number of times No two ...
• 98.8k
427 views

### Number-only switch

Write a function that takes an ASCII-printable-only (all charcodes ∈ [32..126]) string input x and provides an ASCII-printable-only output string ...
• 24.4k
354 views

### Don't output the file 2

Last time you were required to write program that output a file, such that no byte is same as original file. The request meant to let everyone carry part of information, but it ends up that everyone ...
• 24.4k
2k views

### Enumerate the rationals

The cardinality of the set $\mathbb Q$ of rational numbers is known to be exactly the same as that of the set $\mathbb Z$ of integers. This means that it is possible to construct a bijection ...
• 20.6k
187 views

### Show a balanced binary tree

Given an integer $n > 1$, output a balanced binary tree with $n$ leaf nodes. The tree should be constructed out of (space), ...
• 7,121
329 views

### Incomparable partitions

A partition of a list $A$ is a way of splitting $A$ up into smaller parts, concretely it is list of lists that when concatenated gives back $A$. For example ...
• 98.8k
2k views

### Create a nibble shorthand

I recently stumbled across this image on wikimedia commons. It's a little bit of an information overload at first, but after examining it a bit it shows an interesting number system for writing ...
• 98.8k
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,885