Newest Questions
14,496 questions
0
votes
1
answer
64
views
Golf a number bigger than all other answers [duplicate]
You have to code in python, and the number generated by your code must be bigger than all other current submissions. You need to make your code as small as possible, it has to terminate but you can ...
-7
votes
1
answer
84
views
Quine for both C++ and python [closed]
I'm a Chinese so I use AI to translate this question to English,if there was any grammar mistake,please tell me and I'll fix it.
You need to write a piece of code that, for the specified language, ...
-7
votes
0
answers
127
views
Buscar (a,b,c) que cumpla a!*b! /c! = 1
Find all triples (a,b,c) that satisfy (a! * b!) / c! = 1
The following non-trivial combinations were found in the first 50 numbers:
(3! * 5!) / 6! = 1
(4! * 23!) / 24! = 1
(6! * 7!) / 10! = 1
In ...
-1
votes
1
answer
116
views
Generare a toothbrush diagram [closed]
Given a String of opening brackets and the letter G, such that it makes a applicative tree of the leaf node G and ( representing ...
8
votes
4
answers
559
views
Find a primitive polynomial
Objective
Given a prime number \$p\$ and an integer \$n \geq 2\$, find a degree-\$n\$ primitive polynomial modulo \$p\$.
Mathematical explanation
When we perform "modular arithmetic" over ...
4
votes
1
answer
176
views
Through maze with a compressed guide
Given a wall maze of 50x50, exactly same generating algorithm, at different RNG, so every two positions are connected by exactly one path, etc.
Write two functions:
One takes the maze as input and ...
4
votes
1
answer
105
views
Python Buckshot Roulette KOTH
What is Buckshot Roulette?
Buckshot Roulette is an indie game, released by Mike Klubnika to itch.io in 2023.
Okay, but how do you play?
To quote from the wiki:
"At its core, Buckshot Roulette is ...
14
votes
10
answers
970
views
Polynomial Basis Conversion
The most common way to represent a polynomial is writing it as a linear combination of monomials, i.e., powers of the variable. For example, the polynomial \$p(x) = x^3 + 2x^2 + x + 1\$ is a linear ...
17
votes
18
answers
1k
views
Order a list by the difference of its elements
Task
Given an unsorted list of integers, order it in such a way that the absolute difference of every two adjacent elements will always be equal to 1:
\$|dx| = 1\$
There will be guaranteed one or more ...
2
votes
0
answers
170
views
Through maze with a hint
Given a wall maze of 50x50, write two functions:
One takes the maze as input and returns a positive integer;
The other takes the integer and walk through the maze from left-top to right-bottom. At ...
11
votes
7
answers
600
views
Sticks expectation
This was originally a question from interviewstreet.com over a decade ago
You are given an array (or whatever - your choice of input) of positive integers \$y_1,\ldots,y_n\$ that represents \$n\$ line ...
18
votes
8
answers
1k
views
English to Dutch number order conversion
Introduction:
When saying numbers out loud, the order is slightly different in Dutch than in English. For a number like \$1234\$:
in English you'd say: one thousand, two hundred and thirty-four
in ...
11
votes
17
answers
911
views
Identify Redundant Regex
A redundant regular expression (regex) is defined here as a regex which has some amount of characters which can be removed while not affecting its functionality -- i.e. it matches the exact same set ...
8
votes
8
answers
961
views
Validate DNA Sequences with Telomeres
This is inspired by this homework assignment.
Telomeres are regions of repetitive DNA sequences that occur at the ends of linear chromosomes in eukaryotes (such as humans and other mammals). In ...
29
votes
27
answers
5k
views
Creating the mythical XAND Gate
a XAND b
a AND b, but not at the same time.
I've always found the idea of an XAND gate amusing.
Many would claim such a gate can not exist, but I suspect they're just not trying hard enough.
...
8
votes
6
answers
942
views
Counting the sequences
I was thinking when SQL can be less verbose than traditional programming languages and came up with this challenge.
Input
Natural number N
Generating data
We ...
18
votes
3
answers
992
views
Cancel and minimize game
Here is a game: Start with the set {1,2,3,...,n} of natural numbers. At any turn of the game, you may pick two numbers from this set, a and b, then replace them with their product a*b. Since it is a ...
-7
votes
8
answers
308
views
Internationalisation -> I18n (numeronym)
Write the shortest program or function that accepts a sequence of three or more letters and returns its I18n-style numeronym, preserving the original letter case. The I18n-style numeronym is formed by ...
1
vote
2
answers
225
views
Create an autoclicker for Bands and Bonds
Bands and Bonds is a browser clicker game about delving in a dungeon. It has the particularity that only one of the actions you may take can be auto-repeated at the same time: You may start several ...
9
votes
3
answers
315
views
Divide 1 by a sum/difference of square roots
Divide 1 by a sum/difference of square roots
Input: An expression that is a sum/difference of square roots of positive integers. You can assme it will not equal 0.
The general form is \$\pm\sqrt{a_1}\...
5
votes
4
answers
351
views
DNA reading frame
DNA is read in groups of three nucleotides (the letters you see in a sequence), called codons, for determining what protein sequence the portion of DNA will yield. I already used this in a previous ...
6
votes
9
answers
695
views
Parse rpip7 musical notation
Parse rpip7 musical notation
rpip7 is a minimalist music notation derived from ip7, designed for simple playback (for example, on an Arduino with a buzzer).
It supports only these symbols:
...
21
votes
17
answers
1k
views
A yet-unlisted sequence
I was looking for a simple sequence that's not yet referenced on the OEIS and came up with this one(*):
\$a_1=2\$
\$a_2=3\$
For \$n>2\$, \$a_n\$ is the smallest number of the form \$a_i\times a_j+...
14
votes
17
answers
1k
views
Compute the NFL passer rating
Each quarterback in the NFL is given a passer rating at the end of the game, which measures how good their forward passes were. It is not strictly a basic arithmetic formula, and is calculated as ...
10
votes
8
answers
744
views
Closest Palindromic Number with Matching Smallest Valid Base
An extension of Find the closest palindromic number mixed with Numbers Interpreted in Smallest Valid Base.
A number is a palindrome if its sequence of digits is the same when reading them from left to ...
15
votes
18
answers
1k
views
Rebase Until Inert
This is a sequel to Numbers Interpreted in Smallest Valid Base.
Let us define the operation of rebasing a number as writing out its digits in decimal form, then interpreting them in the smallest base <...
19
votes
13
answers
2k
views
Interpret G-code
G-code is a set of instructions used to manipulate machines in CNC, 3d printing, or other similar applications. It controlls the position of a tool, manuvering it to create a path.
Your goal is to ...
20
votes
31
answers
2k
views
Numbers Interpreted in Smallest Valid Base
Let us define the operation of rebasing a number as writing out its digits in decimal form, then interpreting them in the smallest base N possible (...
-5
votes
14
answers
443
views
Text Flattening Program
Input: A string, can be multi-line. The newlines must to be real newline (e.g., you cannot request that each newline be (n)). There is another input, a number (not ...
8
votes
3
answers
331
views
The Mind: King of the Hill Edition
Sandbox
In this king-of-the-hill challenge, you will be playing a variant of the popular game The Mind.
In this variant, every round, a deck of K cards labeled 1 - K are shuffled, and hands of size N ...
15
votes
10
answers
2k
views
Verify a Chinese ID Number
Verify a Chinese ID Number
The Resident Identity Card (居民身份证) is a document issued to most Chinese citizens. It contains information about its holder, including their name, address, and ID number, an ...
11
votes
7
answers
736
views
On the Subject of Switches
This challenge is from a video game, Keep Talking And Nobody Explodes.
A yes or no choice isn’t too bad. Unfortunately you have to make five of them and any of them could be your last. — from the ...
12
votes
12
answers
743
views
Recursive cumulative sum [duplicate]
Challenge:
Given inputs \$i\$ and \$n\$, calculate \$R_i(n)\$ where:
$$R_0(n)=n \\
R_i(n)=\sum_{j=0}^nR_{i-1}(j)$$
Note that \$R_1\$ is triangular function, and \$R_2\$ is tetrahedral function.
This ...
10
votes
2
answers
368
views
Check if a number is a power with its program value being a power
Task:
Your task is make a program to check if there exists integers \$a \ge 2, b \ge 2\$ such that \$a^b=i\$ where \$i\$ is the input integer at least 2.
The catch is that your program must return a ...
8
votes
12
answers
2k
views
Return sum of last 3 odd numbers
Introduction
In my CS4 class I worked with another student to golf this lab as much as possible. I learned a lot about Ruby with it, and I am curious what optimizations could be done. :D
Challenge
A ...
11
votes
11
answers
784
views
Find a linear function such that if f(0), f(1), f(2), ⋯ are indices of the elements of the list, the sum must equal to its slope
Challenge:
Find integers \$a\$ and \$b\$ defining linear function \$f(x) = ax + b\$ with \$a > 0, b \ge 0\$ such that the sum of the elements of the input list \$l\$ located at the values of the ...
5
votes
13
answers
854
views
Which letter is missing? [closed]
Given a printable ASCII string, return any letter which is not present (ignoring case), if possible, else return the empty string.
Test Cases:
...
13
votes
4
answers
705
views
Continue the spiral
Write a program or function which, given a clockwise spiral as input, extends that spiral by one character.
When given no input, your function returns the start of the spiral:
...
5
votes
3
answers
975
views
Multiply the input by 2
Your goal is to write a program which will take an input and multiply it by 2. However, there are some catches.
You will get an input in one of a few forms:
A number (...
1
vote
1
answer
147
views
Tips for making a compiler that generates a golfed program
I would like to create a language that is specifically designed for compiling/translating to another Turing tarpit language. I want to make the program of the target language to be as short as ...
18
votes
18
answers
1k
views
Peg solitaire starting position
Write a program/function to output a peg solitaire board in its starting position:
● ● ●
● ● ●
● ● ● ● ● ● ●
● ● ● ○ ● ● ●
● ● ● ● ● ● ●
● ● ●
● ● ●
...
17
votes
22
answers
2k
views
Find the first relabeling
I had this problem come up for me recently and I thought it would make a fun code-golf.
You will receive as input a list of positive integers. e.g.
...
16
votes
11
answers
2k
views
A million and one constants
When code golfing, it can be useful to write numbers succinctly. This challenge involves using a source language to generate code for a target language. For the submission to be valid, it must ...
8
votes
6
answers
837
views
How does the NSDT program end?
Challenge:
NSDT is like a calculus model invented by me that contains only 4 commands and grouping. Your task is to check in which way the program ends. The program is read from left to right. There ...
3
votes
4
answers
775
views
Emoji-art sunburst
Write a program or function to output an N x N sunburst image made of red, orange and yellow emoji icons.
For N=40, it should look roughly like this:
...
17
votes
10
answers
1k
views
Output the colour code of a given resistance
Should be relatively easy to do, given an input of a resistance (in ohms) and a tolerance (%), output the colour codes for a 4 band resistor, left to right. Input will always be a valid ohm value and %...
12
votes
2
answers
232
views
Autocomplete a word at the cursor position
You will be given a block of text and a cursor position at the end of a possibly incomplete word.
You must output a suggestion for what this word (let's call it w) ...
14
votes
20
answers
2k
views
Sum of Neighbours in a 2D Grid
This is the 2D version of Sum of neighbours: Given a 2D grid of integers, output a grid of the same size where each cell contains the sum of the values of its orthogonal and diagonal neighbors (up to ...
5
votes
1
answer
336
views
Implement 2ˣ using the polynomial system
Your job is to implement \$2^x\$ using polynomials, such that in a way that for all integers \$x\$ and \$y\$,
$$\exists(v_0,v_1,\dots)[P_1(x,y,v_0,v_1,v_2,\cdots) = 0 \land P_2(x,y,v_0,v_1,v_2,\cdots)=...
12
votes
9
answers
1k
views
Exit a pinball board
You will be given a pinball board with a ball on it. Determine where the ball will exit the board. The ball will fall straight down, unless obstructed by a left or right bumper, in which case it will ...