instruction stringlengths 34 53.1k |
|---|
Your task is when given a chemical formula as input, output the total number of atoms in the formula.
Input
A chemical formula in any reasonable format. Each chemical formula has the following:
A leading coefficient, which is a number \$N > 1\$.
At least 0 groupings of elements surrounded by parentheses.
Groupings ca... |
Jelly has an "untruth" atom: Ṭ. This takes a non-empty array of positive integers and returns a Boolean array with 1s at the indexes in the input. For example:
[1,3,5,6]Ṭ ⁼ [1,0,1,0,1,1]
[5]Ṭ ⁼ [0,0,0,0,1]
[2,1,1,2]Ṭ ⁼ [1,1]
[5,4,3]Ṭ ⁼ [0,0,1,1,1]
[1]Ṭ ⁼ [1]
Try it online!
Note that Jelly uses 1-indexing... |
Strobogrammatic Numbers
Definition
A number which is rotationally symmetrical, i.e., it'll appear the same when rotated by 180 deg in the plane of your screen. The following figure illustrates it better,
(source: w3resource.com)
Task
Given a number as the input, determine if it's strobogrammatic or not.
Examples
Tr... |
Codidact post, CGCC Sandbox, Codidact Sandbox
Given three positive integers as input, animate an ascii-art polygonal loading symbol on the screen.
Intro
You will be given three inputs, \$n\$, \$l\$, and \$d\$...
\$n\$ (one of \$3\$, \$4\$, \$6\$, or \$8\$), is the number of sides of a polygon:
... |
This is a repost of this challenge, intended to revamp it for looser I/O formats and updated rules
You are to write a program which takes an integer polynomial in \$t\$ as input and outputs the Laplace transform of this polynomial. Some definitions and properties:
The Laplace transform of a given function \$f(t)\$ is
... |
Input
A string S of length between 10 and 16 inclusive. The characters are taken from the 95 printable ASCII characters, byte values 32 (0x20) to 126 (0x7E) ( to ~)
Output
Your code must compute and output all strings within Levenshtein distance 2 of S. You can have duplicates as long as you also have all the differen... |
The picture:
Sick of the same old grid where the answer is simply a square pyramidal number?
Accept the challenge and write a program that given a positive integer \$n\$ counts how many squares are in the \$n^{\text{th}}\$ iteration of the Harter-Heighway dragon!
The sequence of squares of size 1 is A003230
Your cod... |
I don't like curry. Help me reverse the effects of this evil question - Make me some curry - by uncurrying functions.
Task
Given a blackbox curried function, output its uncurried equivalent.
The curried function will take a single argument and output either another curried function or a value of another type.
The uncu... |
A palindromic number, as a refresher, is any number which reads the same forward as backwards. However, what about palindromes in other bases?
Input
Any integer b where b > 1.
Output
All integer base 10 numbers from 0 to 1000 inclusive that are palindromes in base b. The output can either be a list of integers, or inte... |
\$\newcommand{T}[1]{\text{Ta}(#1)} \newcommand{Ta}[3]{\text{Ta}_{#2}^{#3}(#1)} \T n\$ is a function which returns the smallest positive integer which can be expressed as the sum of 2 positive integer cubes in \$n\$ different ways. For example, \$\T 1 = 2 = 1^3 + 1^3\$ and \$\T 2 = 1729 = 1^3 + 12^3 = 9^3 + 10^3\$ (the ... |
Inspired by this challenge, as well as a problem I've been working on
Problem:
Given a non-empty set of points in 3D space, find the diameter of the smallest sphere that encloses them all. The problem is trivial if the number of points is three or fewer so, for the sake of this challenge, the number of points shall be ... |
The Goal
The goal of this question is to put a twist on this question. Your answer should be able to convert an array of words associated with integers into those integers. As an extra challenge, allow support for , +, -, and _ in between numbers such as sixty seven, sixty+seven, sixty-seven, or sixty_seven.
Examples
... |
Task
Given a positive integer number and a threshold, split into every possible way without generating any numbers above the threshold.
Examples
Input: 15008
Threshold: 400
Valid Output:
[[1, 5, 0, 0, 8], [15, 0, 0, 8] [1, 50, 0, 8], [150, 0, 8]]
Invalid outputs:
[[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 500... |
Task
You are playing Hangman, and your opponent uses a simple but effective strategy: Each turn, from the remaining letters, they guess the letter that appears most frequently across all possible words. When multiple letters appear with the same maximum frequency, your opponent selects randomly among them.
That is, yo... |
The Kempner series is a series that sums the inverse of all positive integers that don't contain a "9" in their base-10 representations (i.e., \$\frac{1}{1} + \frac{1}{2} + \frac{1}{3} + .. + \frac{1}{8} + \frac{1}{10} + ...\$).
It can be shown that, unlike the Harmonic series, the Kempner series converges (to a value ... |
What do you get when you cross Pascal's Triangle and the Fibonacci sequence? Well, that's what you have to find out!
Task
Create a triangle that looks like this:
1
1 1
2 2 2
3 5 5 3
5 10 14 10 5
8 20 32 32 20 8
Basically, instead of each cell being the sum of the cells ... |
Background
The Python code
((((((((n%35)^11)*195)|53)&181)+n)%168)*n)+83
produces 74 distinct primes for \$0 \le n \le 73\$. This code also works in Java. The operators are as follows:
+ is addition
* is multiplication
% is modulus
& is bitwise AND
| is bitwise OR
^ is bitwise XOR
The produced primes are: 83, 97, 11... |
A sign sequence is an infinite sequence consisting entirely of \$1\$ and \$-1\$. These can be constructed a number of ways, for example:
Alternating signs: \$1, -1, 1, -1, ...\$
\$-1\$ for primes, \$1\$ for non-primes: \$1, -1, -1, 1, -1, 1, -1, ...\$
All \$1\$s: \$1, 1, 1, ...\$
Your task is to write a piece of code... |
Your goal is to make a function that takes the coordinates of a cell in 2D space and a distance \$r\$ and returns the coordinates of all cells in the input coordinate's von Neumann neighborhood of radius \$r\$. That is, all cells at most \$r\$ away in Manhattan distance.
For example, given the following cell coordinat... |
A marquee is a low-tech board that allows customizable letters. For example, here is a marquee:
SALE ON SNEAKERS
However, someone might come along and vandalize it by removing letters to send a different message:
S N AKE
Given two non-empty string inputs, an original message and a new message, determine whethe... |
I thought it'd be interesting to turn AoC day 3 puzzle into a Golfing Challenge, so here it is.
Task
Find the number of # you'd encounter in an 11x11 grid (consisting of # and .) that repeats itself (to the right side), starting at the top left corner, which is always a .. You will need to check the position that is \$... |
Halley's Comet is the only comet that may appear (i.e. become visible to the naked eye on Earth) twice in a human lifetime. The orbital period of Halley's Comet is not constant: it has varied between 75 to 79 Earth years since the first definite apparition was recorded in 240 BCE. This variability is mainly driven by g... |
Related: Ellipse circumference
Introduction
An ellipsoid (Wikipedia / MathWorld) is a 3D object analogous to an ellipse on 2D. Its shape is defined by three principal semi-axes \$a,b,c\$:
$$ \frac{x^2}{a^2} + \frac{y^2}{b^2} + \frac{z^2}{c^2} = 1 $$
Just like an ellipse, the volume of an ellipsoid is easy, but its surf... |
Given a binary sequence of finite length, find the starting position where this sequence first appears in the binary digits of π (after the decimal). You can assume that an answer exists for any input sequence.
The binary digits of π start with
11.001001000011111101101010100010001000010110100011...
and digits will be ... |
Interval notation is a way to write complicated range bounds more conveniently and concisely than writing an inequality. The challenge, should you choose to accept it, is to write a program or function that interprets a subset of interval notation. In this subset, intervals are a comma-separated pair of integers delimi... |
Inspired by a recent challenge involving Fibonacci numbers in which OEIS was mentioned, I would like to present a challenge of creating a function that generates a wide array of different linear integer sequences, depending on user input.
Specifically, the user should provide three inputs:
the kernel (a representation... |
Stack Exchange doesn't know how to transpose tables. Let's help.
Given a markdown table, transpose it.
Input assumptions:
There will be at least two rows (including header) and two columns
Either all cells have no leading space or all cells have exactly one leading space (you must handle both)
If the cells have a lead... |
Given a positive integer \$n\$ output an ASCII hexagon with diagonal side length \$n\$, as pictured (note there are \$2n\$ _ characters on the top edge)
Examples:
\$n = 1\$
__
/ \
\__/
\$n = 2\$
____
/ \
/ \
\ /
\____/
\$n = 5\$
__________
/ \
/ \
/ \
... |
Challenge
The goal of this challenge is to make a function that takes an input string, a start keyword and a end keyword. The output extracted result is from (but excluded) the given start keyword to (but excluded) end keyword. The output sub-string follows the rules as below.
In all cases, the leading/trailing spaces... |
Your program should take two lists, where each entry (a positive integer) represents the number of members of some group, as input. These lists will have the same sum but may have different lengths.
Your mission, should you choose to accept it, will be to pair up members of the first list with members of the second, ou... |
Do you know the game Battleship? Well, I want to play with my little brother, but before we can begin we need to set up our ships on the board. This is your input.
Now, we need to check that the ships that we set up are valid. This is where you come in to help. Your task is to write a program or function which checks w... |
This problem will have you analyzing circles drawn on the grid, with the gridlines drawn at integer values of \$x\$ and \$y\$.
Let \$\varepsilon\$ be a very small number (think, \$\varepsilon = 0.0001\$). If we paint a filled-in circle of radius \$\varepsilon\$ centered at the origin, it will require paint to be in \$4... |
Win a K vs KQ endgame
Summary
The goal of this challenge is to create a program or function which will win a Chess game with a King and Queen against a lone King. The user will specify three squares, representing the locations of the computer's King, the computer's Queen, and the user's King. The computer will then a o... |
Input
Your program will take in the integer coefficients of the equation \$ax^3+bx^2+cx+d=0\$ as inputs (a, b, c, and d).
Output
All real solutions of the input equation, with an accuracy of at least the thousandths place, sorted from smallest to largest.
Rules
Built-in equation solver are not allowed
Native math ... |
Write a program or function which takes three positive integers \$a, b, c\$ and returns/outputs one value if there is, and a different value if there isn't, a triangle on the square lattice, whose sides' lengths are \$\sqrt{a}, \sqrt{b}, \sqrt{c}\$. By "on the square lattice" I mean that its vertices are in the \$xy\$ ... |
JavaScript has no direct support for keyword arguments, but it supports argument object destructuring. It is standard to use a destructed final argument for keyword arguments. Here is an example:
function f(x, { a = 7, b = 2}){
return [x, a, b];
}
You would then call this function like:
f(9, {}); // ==> [9, 7, 2]
... |
I'm not sure if this kind of golf is allowed, but here it is.
Your objective is to create an image containing one pixel of every possible RGB color. The image with the smallest file size wins.
Rules:
The image must be a PNG.
The image must contain exactly one of every possible RGB color.
Acceptable image dimensions ar... |
Let S be a set of sets, for example S = {{A},{B},{A,B}}. A maximal subset, Max, is an element of S such that no other set in S strictly includes Max. So in this example, {A,B} is a maximal subset as none of the other sets strictly contain {A,B}.
A minimal subset, Min, is an element of S such that no other set in S is s... |
Related: Landau's function (OEIS A000793)
Background
Landau's function \$g(n)\$ is defined as the largest order of permutation of \$n\$ elements, which is equal to \$\max(\operatorname{lcm}(a_1,a_2,\cdots,a_i))\$ where \$a_1,a_2,\cdots,a_i\$ is an integer partition of \$n\$.
We can extend this to define "iterations" of... |
Here’s the picture of the first published picture of the Mandelbrot set.
Use the fewest bytes possible to write a program or function that outputs the following.
A trailing new line is permitted. Character * cannot be replaced by any other character.
Useful information: Center is \$(-0.75, 0)\$, \$\Delta x = 0.035\$, ... |
Robber Thread here
The Challenge
Choose any numeric* formula, algorithm, or code challenge. Implement it in such a way that the math is correct, but at least one answer is wildly** wrong due to some defect in how computers/programs operate, e.g. floating point errors, uninitialized/corrupted memory, environment bugs, c... |
Challenge
The cops created code challenges which result in certain wildly incorrect answers despite correct math. Choose an uncracked, not safe formula from the cop thread.
Your task is to find an incorrect answer and describe its underlying cause. The challenge author has the responsibility to confirm whether the expl... |
Your task: Print or return a conversion table with every byte from 00 to ff's value as an unsigned integer, to its value as a signed one (using two's complement).
For example:
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
1... |
From the subreddit r/SpeedOfLobsters:
Edit the text of an image to create a new phrase
This meme format/style is pretty self-explanatory. Simply have a browse through the subreddit if you need more examples. However, when coming up with ideas, it can be quite difficult to decide exactly which letters to keep and whic... |
EDIT (Jan 19, 2022, 18:00 UTC): This challenge is now over. The winner is Citty with this Pyth answer. Congratulations!
This is an answer-chaining challenge where each answer must take an integer \$N\$ as input and return the 1-indexed ID of the answer which was written by the user whose ID is \$N\$.
You may want to s... |
The goal is to raise the error message with the most bytes! The error message may not be generated by the program itself, such as Python's raise. errors that do not terminate the program are not allowed unless they do not show an error message.
Here is an example in python that raises 243041 bytes of error code:
def a(... |
Background
A little while ago, someone posted an interesting puzzle on Math.SE:
What is the smallest digraph (directed graph) G where the following eight graphs are all distinct:
G, the original graph
Reflexive closure of G
Symmetric closure of G
Transitive closure of G
Reflexive symmetric closure of G
Symmetric tran... |
Challenge
The goal of this challenge is to make a function that takes two paragraphs and output a concatenated result with removing the duplicated overlapped lines due to redundancy (but a single copy of the part of overlapped lines should be kept to avoid information loss). Each input paragraph is with the follows spe... |
When one performs a search query using Google, one of the first things you see is an approximation of how many results were found. Today, you'll be simulating this in as few bytes as possible.
Input
A short string of length at most 10 with characters from a-z.
Output
The approx count that Google reports for the number ... |
Write a program or a function to print the following cube (if you allow me to call it so) in different sizes:
^L^L^L^L^L^L^L^L^L^L^L
//^L^L^L^L^L^L^L^L^L^L^L
////^L^L^L^L^L^L^L^L^L^L^L
//////^L^L^L^L^L^L^L^L^L^L^L
////////^L^L^L^L^L^L^L^L^L^L^L
//////////^L^L^L^L^L^L^L^L^L^L... |
Edit (Jan 24/2021): The original specification for the challenge had a few problems. Underneath the original text, I have added alternate conditions that were suggested by @caird-coinheringaahing (thanks for the tips).
There is a gameshow in the UK called "Countdown", and a parody called "8 out of 10 Cats does Countdow... |
Introduction
A "lobster number", by my own designation, is a number that contains within itself all of its prime factors. The "lobster" description was inspired by the recent question "Speed of Lobsters". The basic idea is that each prime factor can be made by lobsters munching away digits of the number until you are... |
In this challenge, bots (consisting of JS functions) move around an infinite factory (playing field), collecting characters. These characters can be used to build worker bots, or dropped for other bots to pick up.
This challenge is a modified redo of Bot Factory KoTH, which was broken by a mistake in the spec.
Results
... |
zipwith is a functional construct that takes three arguments: one binary function and two lists of the same length, and returns a single list where each element is constructed by applying the binary function to each pair of elements from the two lists:
zipwith (a+b) [1,2,3] [4,5,6] = [5,7,9]
You are to take a black-bo... |
Input:
Ten unique integer coordinates, between (0,0) and (100,100).
Output:
The coordinates arranged in the order/an order such that a path drawn between the coordinates in that order is the shortest path possible.
This is code golf so the shortest code wins!
|
Background
An L-shape is defined as a polyomino which can be made by extending two rectangular legs in orthogonal directions from a full square (called a pivot). The size of the square should be at least 1, and the lengths of the two legs should also be at least 1.
These are some examples of L-shapes:
Pivot size 1, two... |
Here is the problem, for which I can only think of an iterative solution and have not found a closed formula:
You need to paint a house with R rooms.
For each room there are four walls and one ceiling, which all have the same dimensions and need C coats of paint.
You can't paint the next coat until the previous one ha... |
Peano numbers represent nonnegative integers as zero or successors of other Peano numbers. For example, 1 would be represented as Succ(Zero) and 3 would be Succ(Succ(Succ(Zero))).
Task
Implement the following operations on Peano numbers, at compile time:
Addition
Subtraction - You will never be required to subtract a ... |
Heavily based on this closed challenge.
Codidact post, Sandbox
Description
A Sumac sequence starts with two non-zero integers \$t_1\$ and \$t_2.\$
The next term, \$t_3 = t_1 - t_2\$
More generally, \$t_n = t_{n-2} - t_{n-1}\$
The sequence ends when \$t_n ≤ 0\$. All values in the sequence must be positive.
Challenge
Gi... |
You are to write a program which generates random integers between \$0\$ and \$99\$ inclusive, outputting each integer in turn, until \$0\$ is generated. You may choose which single-order random distribution (uniform, binomial, Poisson etc.) you use so long as each integer has a non-zero chance of being generated and i... |
Introduction
A quine is a program that outputs its own source code. For example, a well-known Python quine is _='_=%r;print(end=_%%_)';print(end=_%_). Running it outputs _='_=%r;print(end=_%%_)';print(end=_%_), therefore it is a valid quine. An error quine is similar to a regular quine, however it must output to STDERR... |
Sandbox, Codidact
A rewrite of this question with a simpler input format and guidelines.
Challenge
Deadfish uses a single accumulator, on which all commands are to be performed.
It has the following commands:
Command
Description
i
increment the accumulator
d
decrement the accumulator
s
square the value of t... |
Challenge
The goal is to output Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.
Context. (Maybe another interesting challenge could be printing all of the other examples? This would probably use similar logic but involve either a function or just a for loop.)
Rule(s)
You cannot output anything other t... |
My stovetop has 10 (0 through 9) different settings of heat and a very odd way of cycling through them.
It always starts at 0
When I hit plus it increments the number, unless the number is 9 in which case it becomes 0, or the number is 0 in which case it becomes 9.
When I hit minus it decrements the number, unless t... |
Based on the "Pretty Ugly" poem.
Input consists of a number of stanzas (positive integer), and four arrays/lists of strings, called the "negatives", "negations", "positives", and "filler" sentences.
You must output a "pretty ugly" poem with the specified number of stanzas. A stanza consists of a negative, negation, pos... |
I made this because, although we have a bunch of other questions involving smiley faces, there is nothing for just printing an ASCII smiley face with as little code as possible.
Anyway, print this exactly (Trailing spaces allowed):
**********
******************
**********************
******* ****** ***... |
Challenge:
Given a list of non-negative integers, determine by how much you should increase each item to create the closest binary box with the resulting integer-list.
What is a binary box?
A binary box is where the first and last rows consists of 1-bits; the first and last columns consist of 1-bits; and everything els... |
Background
Fibonacci trees \$T_n\$ are a sequence of rooted binary trees of height \$n-1\$. They are defined as follows:
\$T_0\$ has no nodes.
\$T_1\$ has a single node (the root).
The root node of \$T_{n+2}\$ has \$T_{n+1}\$ as its left subtree and \$T_n\$ as its right subtree.
T0 T1 T2 T3 T4
O ... |
Given a rod of length n inches and a list of prices that contains prices of all pieces of size smaller than n. Determine the maximum value obtainable by cutting up the rod and selling the pieces. For example, if length of the rod is 8 and the values of different pieces are given as following, then the maximum obtainabl... |
Challenge
The challenge is to implement the bottom encoding (only encoding, not decoding). There is a wide variety of existing implementations in the bottom-software-foundation org.
Bottom is a text encoding where each character is separated into multiple emoji.
Unicode escape(s)
Character
Value
U+1FAC2
200
... |
What is Permutation Coefficient
Permutation refers to the process of arranging all the members of a given set to form a sequence. The number of permutations on a set of n elements is given by n! , where “!” represents factorial.
The Permutation Coefficient represented by P(n, k) is used to represent the number of ways ... |
Originally sandboxed by @xnor
Left-or-right is a very simple language @xnor made up. Its expressions are made of arrows < (left), > (right), and parentheses. The goal is to evaluate an expression to either < or >.
An expression A<B picks the left item A, while A>B picks the right one B. Think of < and > as arrows point... |
Challenge
Create a function or program that, when given an integer size, behaves the following way:
If size is equal to 1, output
┌┐
└┘
If size is greater than 1, apply the following substitutions :
Source
Target
┌
┌┐└┌
┐
┌┐┐┘
└
┌└└┘
┘
┘┐└┘
Note: this is basically a Unicode box-drawing version of the... |
Given a BF program consisting of only the characters +-[]<>., with the property that there's an equal number of < and > between every matching pair of [].
You have to find the shortest program that can be achieved with the optimal memory layout (by rearranging the cells on the tape).
If there are multiple such programs... |
Given an array of integers, find "the next to the middle".
The next to the middle is the smallest integer greater than the smallest among mean, median and mode of the given numbers, that is neither the mean, median or mode and is also contained in the array.
For example, in the following array
[ 7, 5, 2, 8, 0, 2, 9, ... |
Output this 1364-digit base-10 number:
10346063175382775954983214965288942351853612536382034663905935101461222060548195774084941504127779027795484711048746289269095513027910438498906751225648197766590064457965461314130149942152545074712074006545797623075756579902190433531325851645586375231773037880535184421903026638874... |
Whispers is February 2021's Language of the Month, so what tips do you have for golfing in it? Tips do not have to be specific to code-golf, so long as they apply to other types of challenges on the site. Tips should be at least somewhat specific to Whispers (e.g. "remove ignored code" is not an answer). Please post on... |
Introduction
git diff is a great way to export patches of the source code, and its outputs are colorized if you don't pass extra arguments to it.
However, when you want to review the exported file with colored output, it would be pretty hard. colordiff is an option, but it acts like the diff program itself, also, it is... |
One thing that is constantly frustrating when golfing ARM Thumb-2 code is generating constants.
Since Thumb only has 16-bit and 32-bit instructions, it is impossible to encode every immediate 32-bit value into a single instruction.
Additionally, since it is a variable length instruction set, some methods of generating ... |
Repost and improvement of this challenge from 2011
A vampire number is a positive integer \$v\$ with an even number of digits that can be split into 2 smaller integers \$x, y\$ consisting of the digits of \$v\$ such that \$v = xy\$. For example:
$$1260 = 21 \times 60$$
so \$1260\$ is a vampire number. Note that the dig... |
When I was posting answers for the Husk Language of The Month thread, I realized it took more time to enter them in the thread than it took to actually write the answers. So, why not automate it?
Write a program/function which inputs a language name, and displays all answers in that language during the current month so... |
In the MMORPG Final Fantasy XIV, the Ninja class has the ability to use combinations of up to three handsigns (Ten, Chi and Jin) to perform a variety of ninjutsu skills.
The skill you cast depends on the last sign used, and using two or more of the same sign makes the ninjutsu skill fail and puts a little bunny on your... |
An unrooted binary tree is an unrooted tree (a graph that has single connected component and contains no cycles) where each vertex has exactly one or three neighbors. It is used in bioinformatics to show evolutionary relationships between species.
If such a tree has \$n\$ internal nodes, it necessarily has \$n+2\$ leav... |
In my previous bioinformatics challenge, I asked you to mutate a DNA sequence. This time, I'd like you to evaluate how likely a mutation, or a series of mutations, is.
The two types of substitutions are transitions and transversions, and due to the chemical structure of DNA bases, transitions are more likely to occur t... |
The challenge: compute the day of the week from a MM-DD representation of a day in this year (2021).
However, you have to write your program in the following subset of Python: (I chose Python because it's popular and easy to understand even to the people who doesn't know the language. Obviously you can use another prog... |
Given two strings a and b, count how many times b occurs as a substring in a, but only when it overlaps with another instance of b.
(This means that 1 will never be a valid output, because in order for the substring to be strictly overlapping, there must be at least one other instance for it to overlap with.)
Test case... |
Given the following Python "reference implementation" of non-terminating FizzBuzz:
i=1
while True:
if i%15 == 0:
print("FizzBuzz")
elif i%3 == 0:
print("Fizz")
elif i%5 == 0:
print("Buzz")
else:
print(i)
i += 1
We can represent its output as an infinite array of char... |
Given a 2-dimensional jagged array and a fill value, pad the array in both dimensions with the fill value to ensure that it is square and not jagged (i.e., all rows are the same length, and that length is the same as the number of rows).
The fill values should always be added to the "edges", which may be the start or t... |
You are given an integer n as input, and, regardless of the current date, must return the calendar year (Gregorian calendar, other calendars not allowed) taking place n seconds from now.
Rules
You may not assume that the current year is 2021. In other words, imagine a user testing your solution in five years.
Standard... |
You will need to evaluate the definite integral (bounded by \$a\$ and \$b\$) of a certain polynomial function that takes the form of:
$$\int_a^b \left( k_n x^n + k_{n-1} x^{n-1} + \cdots + k_2x^2 + k_1x + k_0 \: \right) dx$$
Normally, this can be done using the fundamental theorem of calculus and power rules. For examp... |
Background
Elias omega coding is a universal code which can encode positive integers of any size into a stream of bits.
Given a positive integer \$N\$, the encoding algorithm is as follows:
Start with a single zero in the output.
If \$N=1\$, stop.
Prepend the binary digits of \$N\$ to the current output.
Let \$N\$ be ... |
The program should start out with 2 separate files, here named "a" and "b". "a" and "b" should be what I am calling inverse quines: "a", when run, should output "b"'s source code, and "b", when run, should output "a"'s source code, for example:
./a
#source code of b, optionally followed by newlines
./b
#source code of ... |
Left in sandbox for at least 3 days.
I want to verify if this inequality is true:
for \$n\geq4\$, if \$a_1,a_2,a_3,\dots,a_n\in R_+\cup\{0\}\$ and \$\sum_{i=1}^na_i=1\$, then \$a_1a_2+a_2a_3+a_3a_4+\dots+a_{n-1}a_n+a_na_1\leq\frac{1}{4}\$.
Challenge
Write a piece of program which takes an integer n as input. It does th... |
Background
This is loosely based on the now closed Kaomoji question asked a few hours ago.
Kaomojis are sequences of characters designed to express a given emotion. In this code-challenge, you'll be writing a program that takes a Kaomoji as input, and must output the emotion expressed by the Kaomoji.
Input
A Kaomoji. I... |
You have to print out your username, by only using the characters in your username.
Standard loopholes are forbidden
This is not code-golf, so shortest does not win
Don't modify your username please
And each language be used one time
|
Introduction
Book cipher
A Book cipher is a very unique method of a encipher. Here's how's it done:
You have a book / a document or a article (something full of text, the more pages of text the better).
You have a message to convey (a secret, of some sort)
You simply-put read trough the text and the secret message (ma... |
Challenge
I've checked that there is a question Compute the Discrete Cosine Transform which is a competition for implementing a shortest solution to compute the one dimensional discrete cosine transform.
The goal of this challenge is to implement a program to calculate three dimensional discrete cosine transform which ... |
Looking at the following hackerrank problem:
https://www.hackerrank.com/challenges/flatland-space-stations
You are given a number n where cities can be at indices 0 to n-1 and also given an unsorted list of indices of cities where there are stations. The goal is to find the maximum distance from a city to a station. Fo... |
Challenge
In this simple challenge, you have to print the public IP address of google.com.
Rules
You have to output either the IPv6 or IPv4 address, and do it by somehow using internet.
Output does not strictly need to be the IP address, your answer will be valid if the correct IP address is somewhere in the output, ... |
Inspired from Is this site down or is it just me?
Challenge
You have to print if a website server is online or not, for you.
Input
The domain name, like codegolf.stackexchange.com
Output
1/True if online
0/False if offline
Rules
Any kind of web access is allowed
URL shorteners allowed
Except 2 no. Rule, all standa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.