# All Questions

13,821 questions
Filter by
Sorted by
Tagged with
243 views

### Write a set as a union of ranges

In this challenge, we define a range similarly to Python's range function: A list of positive integers with equal differences between them. For example, ...
99 views

The aim of this post is to gather all the tips that can often be applied to radiation-hardening challenges. Please only post answers which can apply to a large number of languages, and one tip per ...
1k views

121 views

### I reverse the source code, you reverse the source code! [duplicate]

Write a program that outputs its source code in reverse when run, and outputs its source forwards when I reverse the source. If your program is "abcd", when run with no arguments it should ...
923 views

In this challenge, you'll take an answer as input, and print the answer before it. If the answer passed as input is the first answer, print your own submission's source. You'll be passed any answer in ...
3k views

### Funny Numbers :D

The task is to calculate the average "funniness" of a given number given the following scoring system: 1 point for each "420" in it 2 points for each "69" in it 3 points ...
68 views

### PHP+C polyglot solution to mixed types

Some built-in functions in PHP return mixed types, like file_get_contents that returns both string or ...
2k views

### I (rev)?(pal)? the source code, you (rev)?(pal)? the input!

Just because the reverse and palindrome were not too challenging individually :) Write a program (full program or function) that satisfies the following: given a string input, the program as-is ...
2k views

### Do you win a Numeric Mahjong?

Background Numeric Mahjong is a hypothetical variation of Japanese Mahjong, played with nonnegative integers instead of Mahjong tiles. Given a list of nonnegative integers, it is a winning hand if it ...
1k views

### Reconstruct an array by successive insertions

Given an array of letters in the range 'a' to 'o', compute how to construct the array by successively inserting the letters in alphabetical order. You will always start the insertion with a base array ...
925 views

### Implement Subleq

Subleq is a Turing-complete esolang with only one instruction, SUBLEQ. This instruction takes in three parameters, A, B, and <...
2k views

### Find the largest sum such that no two elements are touching

Inspired by this (off topic) post Given an array of numbers, find the largest sum over a subarray not containing two adjacent elements ...
183 views

### Comparator function in Javascript [closed]

Need to write a JS function compare(a,b) for numbers which return 1 when a > b, 0 when a == b, -1 when a < b. Also following properties should hold: compare(NaN, NaN) = 0 NaN is bigger than any ...
1k views

### Find the longest permutations of integers from 1..k such that all neighbouring pairs sum to a square

OEIS A090461 details the ‘numbers k for which there exists a permutation of the numbers 1 to k such that the sum of adjacent numbers is a square’. This has also been the subject of Matt Parker’s ...
334 views

### Self-referencing tuple in python

Goal: create a self-referencing tuple satisfying x == (x,) in any version of Python. Standard libraries, matplotlib, numpy, pandas only. Answers meeting this extra ...
2k views

### Keep jumping till a cycle

Objective You're on a nonempty list of integers that wraps around. You start at the leftmost entry of the list, and keep jumping to the right to the amount of the integer entry you're at. Eventually, ...
1k views

### Numbers with distinct decimal digits

Write a program or function that outputs all positive integers with distinct decimal digits (OEIS: A010784) Examples: ...
2k views

### Play a game of memory

Playing the game of memory against a machine is highly unfair, because they play almost as good as small children. So let's make the machine play alone, but in a fair way: Input: 1...26 pairs of ...
110 views

### What is the shortest regular expression (REGEX) you can create for file extensions for image formats? [duplicate]

What is the shortest regular expression (REGEX) you can create for file extensions for all of the following image file formats (photographs, paintings, sketches, and drawings)? ...
676 views

### Count the size of the Levenshtein neighborhood

Input A binary string $s$ of length $n$ and a positive integer $k \leq n$. Output The number of binary strings with Levenshtein distance exactly $k$ from the string $s$. Example outputs Each ...
841 views

### Shortest English prompt to produce LLM falsehood [closed]

Since programming is predicted to become natural linguisized by the unstoppable advances in LLM technology, perhaps we can code golf LLMs themselves. Produce the shortest question that is not an ...
367 views

### Sums of Euler's totient function in sublinear time

Related. Given a number $n$, Euler's totient function, $\varphi(n)$ is the number of integers up to $n$ which are coprime to $n$. That is, no number bigger than $1$ divides both of them. For ...
1k views

### Find the smallest integer multiple of a Decimal

The Challenge Given a rational number, determine the smallest number which is a positive integer multiple of it. Eg. ...
225 views

### Sokobunny I (Sokoban, but the boxes are sentient)

Sokobunny 1 You love buns! You love them so much, that you chased one down a bunburrow. The burrows are like mazes, and YOU WANT TO CATCH THE FLUFFBALLS!!!! However, the buns are smart! You can't ...
3k views

### American odds to probabilities

American odds (aka moneyline odds) are numbers like $+150$ or $-400$ used to express how much a winning bet would pay out. Convert odds to a fair win probability like this: Positive odds $+n$ ...
2k views

### What's my score?

The question score on Stack Exchange is the total number of upvotes minus the total number of downvotes a question receives. However, the reputation gained/lost for every upvote/downvote is different (...
372 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 ...
2k views

### How many ways to cut a number into an equation?

Too bad! I had such a beautiful equation, but I lost all my =+-*, so there is nothing left but a chain of digits, looking like a number: ...
1k views