instruction stringlengths 34 53.1k |
|---|
Consider the triangular numbers and their forward differences:
$$
T = 1, 3, 6, 10, 15, 21, ... \\
\Delta T = 2,3,4,5,6, ...
$$
If we alter \$\Delta T\$ so that it begins with a different integer, we get a different, yet similar sequence (assuming that it begins with \$T'_1 = 1\$):
$$
\Delta T' = 3,4,5,6,7,8,... \\
T' =... |
Although there was a prime factors challenge posted ten years ago, it has tedious I/O and restricted time. In this challenge, your task is to write a program or function which takes an integer \$n \ge 2\$ as input, and returns its prime factors.
Task:
Input will consist of an integer, \$n \ge 2\$. Your program should t... |
Your program must accept as input six numbers, which describe a triangle - for example, the inputs 80, 23, 45, 1, 76, -2 describe a triangle with vertices (80, 23), (45, 1), and (76, -2). The input must be given as six plain real numbers or as a list of six real numbers, in the order given in the example. Your task is ... |
One day in July 2020, I made the following C program:
#define A m]
a[9999],*m=a;main(){for(2[A=4[A=1;;){for(;4[A;putchar(6[m-=3]+48));
for(puts(a);7[A;2[A=4[A,4[A=1)if(4[A+=3[m+=3]-1,9<(3[A=2[A+=3[A))++
5[A,7[A=1,3[A-=10;}}
with three superfluous newlines removed, it's 167 bytes and it prints the fibonacci sequence (a... |
Pickleball doubles is a game where only the serving side can score. The server calls the score as a triple of numbers, the serving side's score, the receiving side's score, and \$1\$ or \$2\$ to indicate whether the server is the first or second of their side to serve. If the server's side wins a point, their score i... |
Task
Given a non-empty list of positive digits, group them into sublists of equal sum. You may output any subset of solutions with maximal number of sublists (equivalently, minimal sum).
The input may contain repeat elements. There may not exist any solution but the singleton list containing the input itself. The outpu... |
The goal of this challenge is to generalise the bitwise XOR function to other bases. Given two non-negative integers \$ x \$ and \$ y \$, and another integer \$ b \$ such that \$ b \geq 2 \$, write a program/function which computes the generalised XOR, described the following algorithm:
First, find the base \$ b \$ re... |
Goal
Your task is to create a program taking no input that returns the link to your answer. You can find a link to your answer by clicking at the share button on your answer.
Rules
Standard loopholes apply except for searching for the answer online. In fact, you are expected to find the answer online.
You are allowed ... |
Introduction
How to prove that 1 = 2:
1 = 2
2 = 4 (*2)
-1 = 1 (-3)
1 = 1 (^2)
You can just multiply both sides by 0, but that's cheating. This is just bending the rules a little bit.
Your challenge:
Write a program/function that, when given two integers, outputs a "proof" that the two are equal.
Rules
Your program's... |
What tips do you have for code-golfing in the V lang? I have been trying to find ways to shorten codegolfs on there but can't find any resources on it. Do you guys have any?
Please suggest tips that are at least somewhat specific to the V programming language (e.g. "remove comments" isn't helpful).
Please post one tip ... |
Though there is a prime factorization challenge and it's here, this, I feel, will be a bit more interesting than that one.
To understand this, let's have an example; I will use 5,184 for this. \$5184 = 2^6 \times 3^4\$. However, for this challenge, such a factorization is insufficient - the reason is that 6 and 4 are c... |
Challenge
Write \$2 \le n \le 10\$ distinct, valid non-halting full programs in your language of choice. If all of them are concatenated in order, the resulting full program should be a valid halting program, but if any of them are left out, the result should still be a valid non-halting program.
More formally, write \... |
Given the equation of a non-parabolic conic section, output its characteristics.
Spec
Some info on conic sections:
for more info visit Wikipedia
From an equation of the form \$ax^2+bx+cy^2+dy+E=0\$, it is possible to derive the type of conic section using a combination of square completion and simple arithmetic.
For t... |
As the June 2021 Language of the Month is Red, what are some general tips for golfing in Red language?
Please suggest tips that are at least somewhat specific to Red (e.g. "remove comments" isn't a valid tip here).
Please one tip per answer!
|
Daylight saving time (DST), is the practice of advancing clocks (typically by one hour) during warmer months so that darkness falls at a later clock time. The typical implementation of DST is to set clocks forward by one hour in the spring ("spring forward") and set clocks back by one hour in autumn ("fall back") to re... |
* and don't have a word processor with top-left align support :D
Take several lines of input, with at least four unique characters of your choice including newline and space. The input can also be taken as a space-padded matrix of characters. Squash it upwards, then squash it left. Output this, with any amount of trail... |
Consider a n x n multiplication table and replace each item with its remainder of division by n. For example, here is a 6x6 table and its "modulo 6" structure: (The last column and row are ignored since both are null)
1 2 3 4 5 6 | 1 2 3 4 5
2 4 6 8 10 12 | 2 4 0 2 4
3 6 9 12 15 18 | 3 0 3 0 3... |
Take this array:
[1, 2, 6, 4, 4, 1, 0, 0, 2, 0, 4, 1, 4, 2, 4, 8, 1, 2, 4]
There are quite a few places where [1, ..., 2, ..., 4] appears, where ... is any number of items. These include [1, 2, 6, 4], [1, 0, 0, 2, 0, 4], [1, 0, 0, 2, 0, 4, 1, 4], and [1, 2, 4]. The shortest of these is simply [1, 2, 4].
Task:
Given t... |
Inspired by this Numberphile video.
What is planing?
In order to 'plane' a sequence of digits, you need to:
Identify the lengths of the 'runs' (adjacently repeated digits) in the sequence. Non-repeated digits count as runs of one.
Decrease the length of each run by one. Runs of length 1 become length 0.
Reconstruct t... |
If you convert a chemical formula to lower case, it may become ambiguous: co can be both CO or Co.
Given an input consisting of a-z0-9, where 0 can only stand behind 0-9. Check whether it's ambiguous, unambiguous, or impossible. Return 3 different values for them. Shortest code wins.
Examples:
co - ambiguous
2h83o6... |
Fluff
After taking a look at deadfish, I decided it sucked, so I came up with a new (and easier) variant of it: imnotdeadfish.
As with its predecessor, there are 4 commands and an accumulator which begins at 0:
+ # increment the accumulator
- # decrement the accumulator
s # square the accumulator
o # output the accumul... |
Why should you golf in Haskell? Find out here. In that answer, Zgarb defines a task:
Let's define a function f that splits a list at the second occurrence of the first element, e.g. [0,2,2,3,0,1,0,1] -> ([0,2,2,3],[0,1,0,1]):
Alright then, lets!
You are to take a non-empty list consisting of digits, and output a pair... |
Background
Combinatory logic is a system where a term is written using a finite set of combinators and function application between terms, and reduction rules are defined for each combinator. The well-known S and K combinators have the following reduction rules:
$$
\begin{aligned}
S\;x\;y\;z & \overset{S}{\implies} x\;... |
Challenge
Your goal is to find the furthest point on a graph (from a provided start node). Your code doesn't need to handle cycles in the graph properly, but it might pose a fun challenge. For this question, you can assume the graph is actually a tree.
Input data
Input can be provided in any suitable format for the lan... |
You have a bunch of cities on a grid which you wish to link up. Roads can be placed on any tile that doesn't contain a city, and connect to all roads or cities adjacent to them, vertically, horizontally or diagonally.
Roads can link up via cities, for example
C
\
C-C
is fully linked up.
However, there are some moun... |
Information
Create a diagonal line given its length (let’s call the variable, say, \$n\$ where \$n > 0\$)
The diagonal line starts from the top left and goes to the bottom right.
You must use the ASCII character \ for the line.
The input number can be given from STDIN or if your program doesn’t support that, use a har... |
Program the sequence \$R_k\$: all numbers that are sum of square roots of some(maybe one) natural numbers \$\left\{\sum_{i\in A}\sqrt i\middle|A\subset \mathbb{N}\right\}\$, in ascending order without duplication. Outputting zero is optional.
You should do one of:
Take an index k and output \$R_k\$, either 0 or 1 inde... |
Task
Given a non-negative number, check if it's odd or even. In case it's even, output that number. Otherwise, throw any exception/error that your language supports, and stop the program.
Example with Python
Input: 1
Output:
Traceback (most recent call last):
File ".code.tio", line 1, in <module>
IfYouWantThenThr... |
Introduction
Fischer random chess, also known as Chess960 for the 960 valid starting boards, is a variant of chess where each player's pieces are randomly shuffled at the start. As a reminder, each player gets 8 pawns, two rooks, two knights, two bishops, one queen, and one king. For this challenge, you don't need to k... |
The Prisoner's Dilemma, but with 3 choices, and the payoffs are random!
Each round, your bot recieves a 3x3 grid and chooses a row to play. The grid might be this:
4 5 7
3 1 9
9 9 0
Each number in the grid is between 0 and 10 (inclusive). Your score for the round is grid[your_play][their_play], and your oppone... |
Given a positive number \$n\$ we call another (not same as n) positive number \$m\$ good if we insert same digits in both n and m and the resulting fractional value is same.
$$m/n = m_{\text{transformed}}/n_{\text{transformed}}$$
$$or$$
$$m*n_{\text{transformed}} = m_{\text{transformed}}*n$$
Clarifications:
No leading... |
Picolisp has a feature called "super parentheses":
Brackets ('[' and ']') can be used as super parentheses. A closing bracket will match [all parentheses to and including] the innermost opening bracket, or [if there are no unmatched opening brackets] all currently open parentheses. src
Taking a string containing only... |
From Codidact with permission.
Description
APL trains are a series of functions, that get applied to an argument in this way:
(f g) x = f g x here f and g are prefix functions
(f g h) x = (f x) g (h x) here f and h are prefix functions, while g is an infix function
(a b c d e f) x = (a (b c (d e f))) x = a (b x) c (d x... |
Challenge
Choose any number of languages. Call this set L.
Write a program so that running it in any language in L produces an interpreter for a different language in L.
Each language in L must have exactly one interpreter for it. This is to prevent, for example, Nothing or Text being part of L and all interpreters be... |
Given infinite different integers, order them into a sequence \$a_1, a_2, a_3, ...\$ such that \$a_i>a_{i+1}\$ iff \$i\$ is even(or odd, as long as it's constant for all possible inputs and all \$i\$). In other word, make the sequence go alternately up and down (or down first, as long as it's constant).
Examples:
ℤ => ... |
Background
Combinatory logic is a system where a term is written using a finite set of combinators and function application between terms, and reduction rules are defined for each combinator. The well-known S and K combinators have the following reduction rules:
$$
\begin{aligned}
S\;x\;y\;z & \overset{S}{\implies} x\;... |
This is not just another challenge asking you to color random maps... In this challenge, you are asked to write a program that is actually used in the formal proof of the Four Color Theorem.
First I shall describe the challenge without any background or motivation, for the impatient.
A chromogram is a list made of the ... |
Challenge
Make a triangle of numbers like below.
How to?
Let say we get a numbers in the form of ab, for example 12. We then create a triangle like below:
Sorry for my bad drawing!
First we have 12, and we take sum of the two numbers 1 and 2, which is 3. In case the sum of two numbers are greater than 9, we just take ... |
Given an integer \$ n \$ \$ (n \ge 1) \$, return/output the total number of set bits between \$ 1 \$ and \$ n \$ inclusive. To make the problem more interesting, your solution must run with a time complexity of \$ \mathcal{O}((\log n)^k) \$ or better, for some constant \$ k \$ (AKA poly-logarithmic time complexity).
Th... |
Inspired by this video by Ben Eater. This challenge forms a pair with Encode USB packets.
The USB 2.0 protocol uses, at a low level, a line code called non-return-to-zero encoding (specifically, a variant called NRZI), in which a stream of bits is encoded into a stream of two electrical level states J and K. Decoding w... |
Lexicographic Ordering
For this challenge we will be talking about the lexicographic ordering of strings. If you know how to put words in alphabetical order you already understand the basic idea of lexicographic ordering.
Lexicographic ordering is a way of ordering strings of characters.
When comparing two strings lex... |
Take a line of input (function arguments or stdin, etc.).
Remove comments in it, where a comment starts and ends with ".
Do not remove comments in string literals, which start and end with '. String literals do not contain escapes, because smalltalk has nice, easily lexable syntax ;).
Output this string.
The number of... |
Given an integer \$1 < n < 10 \$ generate a table like below.
For \$n = 5\$,
1 2 3 4 5
2 2 3 4 5
3 3 3 4 5
4 4 4 4 5
5 5 5 5 5
For \$n = 8\$,
1 2 3 4 5 6 7 8
2 2 3 4 5 6 7 8
3 3 3 4 5 6 7 8
4 4 4 4 5 6 7 8
5 5 5 5 5 6 7 8
6 6 6 6 6 6 7 8
7 7 7 7 7 7 7 8
8 8 8 8 8 8 8 8
Shortest code wins! Trailing whitespace allowed
... |
But Is It Art? is an esolang created by ais523, where one step is break the program into orthogonally connected "tiles":
A BBBB
A B B
AA CC
A CC
Each separate letter shows a different tile. Interestingly, programs in But Is It Art? only rely on the orientations of the tiles themselves, not their placement. This means... |
You're a plumber working on a house, and there's some pipes that must be connected at weird angles. You have 8°, 11.25°, 22.5°, 45°, and 90° fittings at your disposal, and you want to use as few as possible to match the angle as closely as possible.
Goal
Match the desired angle as closely as possible, with as few fitt... |
Inspired by this video by Ben Eater. This challenge forms a pair with Decode USB packets.
The USB 2.0 protocol uses, at a low level, a line code called non-return-to-zero encoding (specifically, a variant called NRZI), in which a stream of bits is encoded into a stream of two electrical level states J and K. Encoding w... |
The Collatz sequence
Given a positive integer \$a_1\$, the Collatz sequence with starting value \$a_1\$ is defined as
\begin{equation}
a_{n+1} =
\begin{cases}
a_n/2 & \mathrm{if}\ a_n\ \mathrm{is}\ \mathrm{even} \\
3a_n+1 & \mathrm{if}\ a_n\ \mathrm{is}\ \mathrm{odd}.
\end{cases}
\end{equation}
It is conjectured that, ... |
5 Years ago, this happened, and then it became sort of a meme.
Challenge
The Challenge today is, to check if a "magic square" is a valid parker square.
What is a Real Magic square?
All the numbers must be natural or sometimes 0
The sum of rows, columns and diagonals must be same.
There must be no repeating numbers
Wh... |
Sandbox
Given a boolean matrix representing my grass field, sheep length \$n\$ and wool thickness \$k\$, you will have to count my sheep.
A sheep is a single independent unbroken line of sheep length \$n\$ and thickness \$k\$.
#|##|# | #
#| | #|#
are all valid sheep for \$n=2,k=1.\$
##|###|## | ##
##|###| ## | ## ... |
Background
The fixed-point combinator \$\textsf{fix}\$ is a higher-order function that computes the fixed point of the given function.
$$\textsf{fix}\ f = f\ (\textsf{fix}\ f)$$
In terms of programming, it is used to implement recursion in lambda calculus, where the function body does not normally have access to its ow... |
Risky is a new language of mine, which features an interesting form of tacit programming. In this challenge, you'll take a Risky program as input, and visualize the parsing.
No knowledge of Risky is needed for this challenge, but it's a pretty interesting language so I'd recommend trying it :p.
Task
Risky's parsing is ... |
Multi-dimensional chess is an extension of normal chess that is played on an 8x8x8x8... "board".
In normal 2D chess, a knight's move is a movement by a vector of \$ \begin{bmatrix} \pm 2 \\ \pm 1 \end{bmatrix} \$ or \$ \begin{bmatrix} \pm 1 \\ \pm 2 \end{bmatrix} \$, as long as it doesn't cause the knight to go outside... |
Task
Given a square array of 0s and 1s, determine whether or not there exists a path of 1s connecting the leftmost and rightmost columns. A path can take steps of one unit up, down, left or right, but not diagonally. Every symbol on the path must be a 1, and it must start somewhere in the first column and end somewhe... |
Intro
You like cats. Naturally, you like cat’s games in tic-tac-toe. So, you’ve come up with a little party trick.
You ask someone what square on the board they want you to make a move in. And you ask someone else on which turn they want you to make that move. You also let that person decide whether you play Xs or Os. ... |
Mr. Binary Counterman, son of Mr. Boolean Masker & Mrs. Even Oddify, follows in his parents’ footsteps and has a peculiar way of keeping track of the digits.
When given a list of booleans, he counts the 1s and 0s separately, numbering the 1s with the odds & the 0s with the evens.
For example, when he looks at 1 1 0 0 1... |
We'll call the consecutive distance rating of an integer sequence the sum of the distances between consecutive integers. Consider 2 9 3 6 8 1.
2 9 3 6 8 1
<----5---->
<-2->
<--3-->
\$2\$ and \$1\$ are consecutive integers, and their distance apart in the sequence is \$5\$.
\$2\$ and \$3\$ are consecutive integers, a... |
Consider a binary operator \$*\$ that operates on a set \$S\$. For simplicity's sake, we'll assume that \$*\$ is closed, meaning that its inputs and outputs are always members of \$S\$. This means that \$(*, S)\$ is a magma
Let's define some basic terms describing the properties of \$*\$. We can say that \$*\$ can have... |
Background
Binomial transform is a transform on a finite or infinite integer sequence, which yields another integer sequence. The binomial transform of a sequence \$\{a_n\}\$ is given by
$$s_n = \sum_{k=0}^{n}{(-1)^k \binom{n}{k} a_k}$$
It has an interesting property that applying the transform twice will yield the ori... |
Given a list of coordinate pairs, output the Trapezoidal Riemann Sum of the values given between the first and last x-coordinates.
You will be given a sorted list of coordinate pairs, like this:
[
[1,2],
[3,5],
[5,11]
]
Note that x-coordinates will always be in increasing order, ys may not.
My way to do this is ... |
Your challenge is to write a function/program that takes a matrix of integers m and a number n as input and:
Splits m into n by n chunks
Replaces each chunk with the most common value in that chunk (In case of a tie, any of the tied values is fine).
Outputs the resulting matrix.
Note: You can take either the size ... |
Task
Given a list of nodes representing a binary tree of positive integers serialized depth-first, return a list of nodes representing the same tree serialized breadth-first. To represent an absent child, you may use null, 0, 'X', Nothing, [], or any other value that is distinct from your representation of a node's val... |
Inspired by the problem with the same name on Puzzling SE by our very own Dmitry Kamenetsky.
You are to find the largest number that only uses every digit pair once, in a given base. For example, in ternary we have 2212011002.
Challenge: Given a base from 2-10, output the largest number in that base with no repeating d... |
Introduction
In a standard* (e.g. not 2020) tax year, estimated payments are due quarterly according to the schedule outlined in Publication 505.
Payment Period
Due Date
January 1 – March 31
April 15
April 1 – May 31
June 15
June 1 – August 31
September 15
September 1 – December 31
January 15
* Saturd... |
Inspired by Wzl
Determine if a given square binary matrix has exactly one row or column consisting of entirely 1s, and the rest of the matrix is 0s.
For example, these are all true:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 ... |
If you have ever looked at an objdump of a C++ program, you have likely seen something like this:
_ZN3foo3bar3bazI6sampleEE3quxvi3foo
This is a C++ mangled symbol, which encodes the namespaces, classes, and function/template arguments, using the Itanium ABI.
Specifically, it is for the following function:
void foo::ba... |
Background
So, nowadays the popular Prisoner's Dilemma variant is the Prisoner's Trilemma, where there are three options. I can easily see that being increased, so I figured
Why settle for three options, when we can have INFINITE options?
Therefore, I created the Floating Point Prisoner's ?Lemma.
Equations:
Each roun... |
Related: Counting polystrips
Background
Link-a-Pix is a puzzle on a rectangular grid, where the objective is to reveal the hidden pixel art by the following rules:
Connect two cells with number N with a line spanning N cells, so that the two cells are at the two ends of the line.
The number 1 is considered connected t... |
Print the following text and nothing else:
<html>
<body>
<p>HTML is kinda annoying</p>
</body>
</html>
I'm happy I'm not a web developer.
The catch? Your code must fit the template: print(<?>), where ? can be any group of characters. You can paste your completed code (with the print(<>) part) into this Scast... |
(Based on this closed challenge, related)
Given an integer n > 1, draw a grid composed of the characters: "-" "+" and "|". However, since I want the grid to look nice, the horizontal component should be 2 wide.
Trailing spaces for each line are not required.
Examples:
n = 2
|
--+--
|
n = 3
| |
--+--+--
| ... |
In November 2019, Alon Ran published a particularly lovely sequence in the OEIS, A329126:
\$a(n)\$ is the lexicographically earliest string of digits which yields a multiple of \$n\$ when read in any numeric base.
1, 110, 101010, 111100, 100010001000100010, 1111110, 10000010000010000010000010000010000010, 11111111000,... |
The Len(language,encoding) family of languages is a variety of Lenguage derivatives. To encode a program into a Len language, you replace every character with its representation in a certain encoding, then turn that into a giant integer.
Your challenge is to write a function or program that encodes your language into a... |
Sandbox
Inspired by a Codingame challenge I tried (and failed at) about a month ago.
Given a binary tree of words, say:
HELLO
/ \
WORLD EATING
/ / \
ARCH IDAHO GUARD
/
DOOZY
/
... |
This is an ascii-art challenge where you will draw ascii-art showing a person "jumping" off the top of a building.
The building
Input given will be a group of rectangular buildings. You may assume buildings are not "stacked on top of each other", hence only one row of buildings. This is the standard format of a buildi... |
Your challenge is to construct a proper quine using as few distinct characters as possible.
Scoring
Your score is equal to the number of distinct characters in your code, aiming to minimise this. Standard quine rules apply.
|
According to Wikipedia,
In mathematics, a natural number \$n\$ is a Blum integer if \$n = p \times q\$ is a semiprime for which \$p\$ and \$q\$ are distinct prime numbers congruent to \$3 \bmod 4\$. That is, \$p\$ and \$q\$ must be of the form \$4t + 3\$, for some integer \$t\$. Integers of this form are referred to a... |
There's only one question for machine-language golfing, and it's for the ia32 and amd64 architectures. Here's one for a predecessor of them: the Zilog Z80!
The ISA is available here.
As usual, if your tip is only applicable to a certain environment/calling convention, please indicate that in your answer.
Only one tip ... |
Given a positive integer \$n\$, output \$n\$ 2D bool images with the same width and height such that:
Each image should be 4-connected, i.e. for each two pixels that are true, you can start from one and go up, down, left and right for some times to the other pixel, only passing through true pixels.
Each image should h... |
Say I have a pile of boxes:
AAA
BBB
I can create it in two steps:
BBB
↓
(empty)
---
AAA
↓
BBB
But with this:
AB
BA
I need three steps:
A
↓
(empty pile)
---
BB
↓
A
---
A
↓
B
BA
Your challenge
Given a pile of boxes, output the minimum number of steps needed to create that pile.
A step consists of dropping a ro... |
Desmos is mainly used as an online graphing calculator, but its graphical and mathematical functionalities can also be applied in certain coding challenges.
I know not that many people use Desmos on this site, but for the people that do, what are some tips for golfing in Desmos?
As usual, please keep the tips somewhat ... |
The task is to provide code that evaluates to 0.5 numerically, i.e. the output must be recognized by your chosen language as a numeric value (Number, float, double, etc), not as a string. The catch, the characters 0 through to 9 cannot be used.
PLEASE NOTE: This IS NOT a golfing challenge, this is a popularity contest,... |
Background
Minkowski addition is a binary operation on two sets of points (usually geometric objects) in the Euclidean space. The Minkowski sum of two sets \$A\$ and \$B\$ is formally defined as follows:
$$ A+B = \{\mathbf{a}+\mathbf{b}\,|\,\mathbf{a} \in A,\ \mathbf{b} \in B\} $$
To say in plain English, given the ori... |
Think of cleave as the conceptual inverse of map. If map applies a function to each number in a list...
map([1, 2, 3], x -> x * 5) -> [5, 10, 15]
then cleave applies each function in a list to a number.
cleave(5, [x -> x * 2, x -> x - 1, x -> x * x]) -> [10, 4, 25]
More formally, given:
\$n\$, an integer, and
\$L\$, a... |
You are given a polynomial function, in the following format:
\$x = (c_0 * y^0) + (c_1 * y^1) + (c_2 * y^2) + ... + (c_n * y^n)\$
where \$c_n\$ stands for the coefficient of the \$n^{th}\$ power of \$y\$
You have to plot the equation on a \$10 * 10\$ ASCII matrix. The value must be floored to an integer before plotting... |
Recursively prime-encoded integers
Consider \$11681169775023850 = 2 \times 5 \times 5 \times 42239 \times 5530987843\$. This isn't a nice prime factorisation, as \$42239\$ and \$5530987843\$ make it difficult to store this factorisation in a small manner. Being primes, we can't then factorise them, but we can factorise... |
Write a program which takes two arrays of positive integers as input. One of them (your choice which) will have one item missing compared to the other. Your program must figure out what is missing.
Rules
You can choose which array has one missing: You can take ordinary then missing or vice versa.
Arrays may contain dup... |
I like my job, but sometimes it can get a bit tedious and boring. As motivation, I want to know how many hours of work are left before I finally get my two days of weekend and relaxation.
I work every day from Monday to Friday, totalling 38.5 hours, starting at 9am and ending at 6pm.
Every day - except Friday - I get ... |
Background
As far as we can tell from trying everything (besides cheating with ZWSPs), you can't type
`\
in Stack Exchange chat. However, you can type
\`
by doing
`\\``.
So, if you want to tell someone in chat how to type backslash-backtick, you'd need to type out
`\`\\`\``
to format
`\\``
into a codeblock.
Challenge
Y... |
Background
A checkered tiling of a rectangular grid is a tiling using some polyominoes, where each region can be colored either black or white so that no two polyominoes sharing an edge has the same color. In graph-theoretic terms, the chromatic number of the adjacency graph is 2.
Terminology adapted from a Fillomino v... |
The input for the continuous knapsack problem is as follows.
For each item 1...n we are given a positive weight and profit. Overall we are also given a positive capacity which is the maximum weight we can carry.
The goal is to pick items so that the profit is maximized without exceeding the capacity. This is hard if ... |
Given a string which is guaranteed to be either odd, even, square, cube, prime or composite, your program or function must return an integer \$100\le N\le 999\$ which meets this description.
Rules
Your code must be deterministic.
The choice of the integers is up to you. However, the six answers must be distinct. (For ... |
The setting
"Well I actually wrote the sql library they, the maintainers actually.."
"Right, but do you have any experience working with django?"
" ...no I don't use frameworks"
After the phone interview is over, you feel like you really need a coffee. While the brew is heating, you check your messages on BusinessBook.... |
Input a non-empty array with \$n\$ positive integers. Test if the input array contains every integer in \$1\cdots n\$.
In case you prefer 0-indexed numbers, you may choose to input an array of non-negative integers, and test if the input array contains every integer in \$0\cdots (n-1)\$ instead. All testcases and formu... |
Challenge
Create the image of a pride flag (rainbow flag), i.e. a six coloured striped flag (from top to bottom): red, orange, yellow, green, blue, and violet.
Output
Example (R)
barplot(rep(1, 6), horiz = TRUE, axes = FALSE, space = 0, border = NA, col = c("darkviolet", "blue", "darkgreen", "yellow", "orange", "red")... |
Your task is, to count how many pluses I have.
What Pluses?
The no plus: 0 Points
-
The naïve Plus: 1 Point
+
The double Plus: 2 Points
+
+++
+
The mega double plus: 3 Points
+
+++
+
+ + +
+++++++++
+ + +
+
+++
+
Pluses of higher order than 3 must be ignored.
Rules
Input will ... |
Given an array \$A\$ of size \$n\$.
You have to find the number of subsets such that their product is in the form of \$p_1 \times p_2 \times p_3 \dots\$
where \$p_1, p_2, p_3, \dots\$ are prime numbers. No prime number should appear more than once, i.e. the product is "squarefree".
Example:
Lets pick an array \$A\$ of ... |
Consider, for a given positive integer \$k\$, the sequence \$(a, a+1, a+2, ..., a+k)\$, where \$a\$ is some positive integer. Is there ever a pair \$a, k\$ such that for each element \$a+i\$ in the sequence, either \$\gcd(a, a+i)\$ or \$\gcd(a+i, a+k)\$ are greater than 1?
This was investigated by Alan R. Woods as part... |
Take an array of nonnegative integers, such as [1, 0, 0, 1, 2, 4, 2, 0]. Then, draw that as a mountain where the integers represent altitude:
x
x x
x x
xx x
You may use any printable non-whitespace character in place of x, and adding padding or whitespace after lines or the output is fine... |
This time, you are working on a regex. Your regex is meant to approximately full-match the base-10 representations of primes \$0 \le p < 1000\$, while ignoring any non-numeric string or composite in the range. You can full-match 2, 53 or 419, but not 0, 82 or example.
The approximately is important -- a minimum of 900 ... |
Most Unicode characters have full names, for example ” is "RIGHT DOUBLE QUOTATION MARK". You can find a useful reference here, just type in the character you want to find the full name of and look in the DESCRIPTION column.
Your challenge is to write a program or function that outputs itself as a string of these. You c... |
As some of you may remember, Peter, who was a picky eater is now puzzled Peter.
This time Peter got some puzzles as a present from his Aunt. He has tried a lot, but has failed to solve the puzzles. Peter needs your help to solve them.
Each one of the puzzle has 2 pieces. To solve the puzzle, you must tell the number of... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.