Trending questions
14,497 questions
11 votes
3 answers
304 views
Minimum width to connect both sides
Given two sorted lists of same length \$\{a_i\}\$ and \$\{b_i\}\$, find the smallest \$w\$ such that it's possible to connect each pair of points \$(0,a_i)\$ and \$(w,b_i)\$ with paths such that x-...
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. ...
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 ...
14 votes
10 answers
975 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 ...
525 votes
1k answers
209k views
"Hello, World!"
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
8 votes
4 answers
570 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 ...
0 votes
1 answer
83 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 ...
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 (...
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+...
19 votes
30 answers
2k views
Add Y to X to get a palindrome
Given X>0, return the smallest Y>=0 such that X+Y is a palindrome. Code golf. Tests: 5 => 0 14 => 8 200 => 2 819 => 9 1100 => 11 1122 => 99
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 ...
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 <...
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 ...
-7 votes
1 answer
89 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, ...
18 votes
18 answers
1k views
Peg solitaire starting position
Write a program/function to output a peg solitaire board in its starting position: ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ○ ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ...