instruction stringlengths 34 53.1k |
|---|
Your challenge is to, given a matrix of nonnegative integers, remove all rows and columns that contain a 0.
For example, with this matrix:
[[5, 3, 2, 4, 1],
[3, 2, 0, 4, 7],
[7, 1, 9, 8, 2],
[3, 2, 1, 5, 7],
[6, 4, 6, 1, 2],
[9, 3, 2, 4, 0]]
Columns 3 and 5, along with rows 2 and 6 (in bold), contain a 0, so they... |
Challenge
The primitive circle problem is the problem of determining how many coprime integer lattice points \$x,y\$ there are in a circle centered at the origin and with radius \$r \in \mathbb{Z}^+
\$ such that \$x^2+y^2 \le r^2 \$. It's a generalization of Code-Golf: Lattice Points inside a Circle.
Input
Radius \$r... |
Background
Often, when storing a number in binary with some maximum, we simply round the maximum to the next power of two then allocate the number of bits nececairy to store the whole range. Lets call the result of this method \$S(x, m)\$ where x is the number and m is the maximum.
While not bad, the naive has a few bi... |
Challenge
Generate two \$16 \times 16\$ grids, each initially filled with "@" symbols and spaces. Each cell in the grids should be independently filled with an "@" or a space, with each character having an equal probability (\$50\%\$) of being chosen for each cell. This ensures that both grids start off identically, wi... |
Chess960, a.k.a. Fisher random chess, is a variation of the game of chess.
In classic chess the starting positions are always the same. In chess960 they vary.
Before each game of chess960 one random number from 0 to 959 is drawn. Both players then arrange their pieces in the same way according to this number from a loo... |
Even though the concept of phat-fingered-lights-out number should be pretty self-explanatory here is a definition:
Given a nonnegative integer in binary representation a phat-fingered double-bit-flip or phatflip for short replaces a pair of adjacent, equal bits with their complement.
For example given the number 0b1110... |
Problem:
Given a string representing a mathematical expression with constants (pi, e, psi, i), basic arithmetic operations (+, -, *, /), parentheses, fractions, and exponentiation, write a program or function to convert a string to its equivalent LaTeX code. The input string will only contain digits, arithmetic operato... |
Recall from this challenge that a phat-fingered double-bit flip or phatflip is defined as follows:
Given a nonnegative integer in binary representation a phat-fingered
double-bit-flip or phatflip for short replaces a pair of
adjacent, equal bits with their complement.
For example given the number 0b111010010000101
0b1... |
Consider an arbitrary set of letters \$L\$. It may either be \$\{A, B, C\}\$, \$\{M, N, O, P\}\$, \$\{N, F, K, D\}\$, or even contain all the 26 letters. Given an instance of \$L\$ and a positive integer \$n\$, how many \$n\$-letter words can we build from \$L\$ such that no adjacent letters are the same (so for exampl... |
Given a non‑empty string containing only printable ASCII (codepoints 0x20 to 0x7E), write the shortest program or function that swaps the cases of A-Z and a-z.
If a character is in [A-Z], convert it to its lowercase version.
If a character is in [a-z], convert it to its uppercase version.
Otherwise, leave the characte... |
Input: You are given two numbers n and m.
Create the snail: Given an n >= 3, fill an n * n grid with the numbers from 1 to n * n, starting at the top left, going clockwise to the middle like this (for n = 5):
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
Calculate the sum of the neightbour... |
When you leave, my challenges fade to grey, 0A0AE16, 0A0A0AE16...
A while ago, I made this programming language (https://esolangs.org/wiki/Dragostea_din_tei) which uses an interesting number system. It is base two for integers, but for decimals it divides a base two integer by a power of ten.
The input should be a floa... |
Challenge:
Given a 2D array (8x8) of characters, is the enemy king in check?
The program should return true if and only if the king is currently in check.
Standard chess rules apply.
Specifications:
The game is provided using a 2D array,
where blank space means there is not a piece on that square.
You may assume that t... |
Background
As noted in this question, for all positive integers \$n>2\$ there exists at least one Egyptian fraction representation (EFR) of \$n\$ distinct positive integers \$a_{1} < a_{2} < \dots < a_{n}\$ such that $$ \sum_{k=1}^{n} \frac{1}{a_{k}} = 1. \tag{1} \label{1} $$
When \$n=3\$, for instance, we have $$ \fra... |
Given a ragged array, find the length of the largest subarray that contains the depth of that subarray. The base array layer has a depth of 0.
Here is an example:
[1, 2, [3, 4, [2, 5]], 0]
Here, the subarray [2, 5] contains its own depth 2 and has a length of 2 as well.
But in the outermost subarray is a 0, its depth.... |
Introduction
Tensor contraction is an operation that can be performed on a tensor. It is a generalization of the idea of the trace of a matrix. For example, if we have a rank-2 tensor (a matrix) and we contract along both of its axes, we take the sum of each entry in which the indices of these axes are equal. In this c... |
Given a directed graph on the nodes 0, 1, ..n, where each edge has two non-negative integer costs, return the set of all possible Pareto Optimal path costs between node 0 and node n.
These are the costs of paths for which you cannot decrease the first component of the cost without increasing the second component, and c... |
The tetration operation consists of repeated exponentiation, and it is written ↑↑. For instance,
3↑↑3 =3 ^(3^3) = 3^27 = 7,625,597,484,987
A tetrate of two is an integer that is equal to 2↑↑n for some nonnegative integer n. As an edge case, we say that 2↑↑0=1.
In this challenge, you will be given a positive integer as... |
Challenge
The goal of this challenge is to generate and output a \$16 \times 32\$ (height \$\times\$ width) grid where all cells contain a decoy
character, except for a random single cell that contains the target character. The input will be a pair of ASCII (32-126) characters: [target,decoy], where target is the chara... |
Background
This challenge is based on a personal project I did, UnitDC. This challenge is a super-miniaturized version of UnitDC.
Challenge
Please write a simple unit-aware calculator that evaluates a sequence of positive integers, units and operators in RPN (postfix) notation, while checking whether the units are comp... |
A list \$[a_1,a_2,a_3 \cdots a_n]\$ can be uniquely represented as an unordered list of its prefixes - \$ [[a_1],[a_1, a_2], [a_1,a_2,a_3] \cdots [a_1,a_2,a_3 \cdots a_n]] \$. This can be in any order - for example, \$[1, 2, 3]\$ could be represented by any of \$[[1],[1,2],[1,2,3]]\$, \$[[3,2,1],[2,1],[1]]\$, or \$[[2,... |
emanresu A posted a challenge to reconstruct an ordered list of integers from its unordered set of unordered prefixes. Many users (beginning with xnor's answer) noticed that summing each unordered prefix led to a very short solution. Well, let's cruelly take that possibility away by using data that isn't integers!
A fe... |
You work in a kitchen which has a peculiar rule. When you mix something into a pot you must always add at least one new ingredient.
So you can add pasta, oil, salt then pesto, but not pasta, pesto, salt and oil since pesto already contains salt and oil. You only have one pot per dish, so you can't mix ingredients in on... |
Consider a finite, one-dimensional grid where each cell is marked with one of two symbols (I will use the symbols < and >, but you can use other symbols).
When a pinball is placed on one of the cells, it moves according to the following rules:
If the pinball is on a cell that is marked with <, the pinball moves one ce... |
Consider the problem of N queen on an (NxN) chessboard. Two queens are said to attack each other if they are on the same row, column,
or diagonal. Implements backtracking algorithm to solve the problem i.e. place N non-attacking queens on the board.
|
This will be a bit of a different challenge. Back in 2023, I developed a 2D esolang called Electra, and looking back at my hello world program, (which is 582 bytes by the way) I see a lot of room for golfing. There are some topics that aren't covered in the spec, e.g. in which order the currents are generated/interpret... |
I'm currently converting a Float32Array to an Int32Array for input to a real-time audio raw PCM to MP3 recording application.
new Int32Array([...new Float32Array(b)].map(f=>f<0?f*32768:f*32767)
The examples in the wild I've seen convert each float individually to avoid static, gaps, glitches when the audio recording i... |
Consider an \$(n+1) \times (n+1) \$ grid of points places at non-negative integer coordinates. Given two points in the grid at \$(a, b)\$ and \$(c, d)\$, we know that the distance of the first point to the origin at \$(0, 0)\$ is \$x = \sqrt{a^2 + b^2}\$ and the distance of the second point to the origin is \$y = \sqr... |
Imagine you have a positive integer number \$n\$. Let \$m\$ be the number obtained by reversing \$n\$'s digits. If \$m\$ is a whole multiple of \$n\$, then \$n\$ is said to be a reverse divisible number. If neither are a palindrome, \$m\$ is called a palintiple.
For example, \$1089 \cdot 9 = 9801\$, so \$9801\$ is a pa... |
Objective
Given a nonempty unordered list of positive integers, decide whether they can be added, negated, or multiplied to yield a single zero. Each given number must be used exactly once.
There is a taboo. Do not multiply zero to anything. Adding zero to anything is OK.
Examples
Truthy
List, Solution
[1,1], 1-1
[1,1,... |
Challenge
Create a program that outputs a square grid showing visible and non-visible points \$(x, y)\$ from the origin based on their greatest common divisor (GCD).
A point \$(x, y)\$ is considered visible from the origin \$(0, 0)\$ if the \$\gcd(x, y) = 1\$. Otherwise, it's non-visible.
Input
An integer \$n\$, repre... |
You are given an array A of length N and an array B of length N-1.
You need to output array where items alternates:
A[0], B[0], A[1], B[1], ..., B[N-2], A[N-1]
Restrictions:
N>0
Type of items is not specified, but code should work at least for unsigned integers.
Sample input:
A = [1,2,3,4]
B = [7,8,9]
Sample output:... |
Challenge
In this challenge, we will use a language that is very similar to Brainfuck but slightly different.
This variant of BF does not have any input and output commands; instead, it simply takes a tape as input and modifies it until it halts. The final state of the tape is considered the output of the program.
The... |
Background
The newest version of the C standard, C23, adds preprocessor macros like INT_WIDTH, ULONG_WIDTH, and SIZE_WIDTH that tell you the bit width of various integer types (here, int, unsigned long, and size_t, respectively). However, while the majority of us are stuck with pre-C23 compilers/standard libraries, it... |
Challenge
Given ASCII-encoded text input of any size, detect numbers between -1,000,000,000,000,000,000 and 1,000,000,000,000,000,000 exclusive and rewrite them with thousands separators. Use commas only and ignore leading zeroes. Leave the rest of the input unchanged.
Test cases
Input
Output
Description
123
123... |
If I want to type the string aaa, the least keystrokes I can type it in is 3: a a a. But if I want to type the string aaaaaa, I can do it in 5: a a a ctrl-c ctrl-v, where the ctrl-c refers to copying aaa and the ctrl-v refers to pasting it.
Specifically, starting with an empty "buffer" and an empty "clipboard":
The ke... |
In the poker game there are 1277 unique 'High Card' ranks. It's 1287 (13 over 5) if we include all straights.
The challenge is to write a function which returns an integer value corresponding to the rank of each 'High Card' poker combination including all straights. Possible cards are(in ascending order): '23456789TJQK... |
Objective
Given an expression involving ternary values, evaluate it into a ternary value.
Ternary Values
The three truth values in question are the values of Haskell's Ordering, namely LT, EQ, and GT. They stand for "less-than", "equal-to", and "greater-than", respectively. Furthermore, they themselves have an order; L... |
Recursion is actually quite powerful, sometimes its doesn't look like that child problem of itself exist, but recursion is just helpful.
One case per answer.
|
This is the cop's thread, where one should post the scrambled code. Here is the robbers' thread where the cracked source should be posted and linked to the cop's answer.
Task: Write the shortest safe program that given two inputs \$x,y\$, outputs \$\arg(x+iy)\$, where \$\arg(z)\$ is defined as the angle between the po... |
V1.1: Added criterion to help with tiebreakers, a bit overkill but still.
Task: Crack the scrambled code for calculating the argument of a complex number \$z=x+iy\$ given two inputs.
You must post a comment in the cops’ thread with a link to your working source, mentioning clearly that you have cracked it. In your ans... |
Given a collection of coloured laces, what would be the probability, \$P\$, that Alice won't create any loops if, until impossible, they tie two uniformly chosen, free lace ends of differing colours together?
For the avoidance of doubt:
Each lace will be of only one colour and will have precisely two ends.
Alice does ... |
Introduction:
A typical cartoonish cactus usually looks like this:
One big stem in the middle, with some L-shaped branches sticking out.
We'll use this general shape for this challenge.
Challenge:
Given a pair of words, create an ASCII-art cactus with two upside down alphabets as stem. The first word is the left branc... |
"nimi ale lon toki pona" is a song by YouTuber jan Misali which lists 137 common words in the constructed language Toki Pona. This challenge is not a duplicate of "How high can you count?" or "Alphabet printing challenge" because instead of numbers or single characters, it outputs random (to many programming languages)... |
We will say a string \$x\$ is cyclic maximal if there is no way to cycle its elements to get a lexicographically larger string. In other words there is no \$a\$ and \$b\$ such that \$a \oplus b = x\$ and \$b \oplus a > x\$, where \$\oplus\$ is concatenation.
For example [3,2,3,3] is not cyclic maximal because you can c... |
I recently found this game and have been enjoying it. Basically, there is a grid of colored tiles and you act by clicking on empty spaces. When you click an empty space, the first tile (if any) in each of the four axis-aligned directions is selected. If any color appears more than once, all tiles of that color are dest... |
Objective
Given an integer \$n\$ interpreted as two's complement binary, output two integers, namely the integer consisting of \$n\$'s bits at places of \$2^0, 2^2, 2^4, \cdots\$, and the integer consisting of \$n\$'s bits at places of \$2^1, 2^3, 2^5, \cdots\$.
Note that the input may be negative. Since \$n\$ is inter... |
The game is played on a 1x8 board with the following setup:
KNR..rnk
White's pieces are on the left, while black's pieces are on the right.
The king (K) can move 1 space in any direction.
The knight (N) can jump 2 spaces in any direction, regardless of bordering pieces.
The rook (R) can move any number of spaces in an... |
For the purpose of this challenge, arguments are things you pass to a function at the call site, while parameters are what the function uses in its implementation. Or, more succinctly: arguments = external, parameters = internal.
While there are several modern languages that have support for argument labels for func... |
Given a non-empty string containing only printable ASCII (codepoints 0x20 to 0x7E), write the shortest program or function that map the key to its value. Inside the string the key will always have a value and vice-versa.
How the key is made:
Start with an opening parenthesis (
Contains letters and/or numbers [a-zA-Z0-... |
The Rockstar programming language has "poetic number literals", allowing you to assign nonnegative, finite (at least one Rockstar interpreter supports infinity) numbers to variables without typing a single digit: just type words with length equal to each digit, modulo 10. For example,
This is a challenge
sets the vari... |
This is Weekly Challenge #1. Theme: Audio Processing
Your task is to write a program, which writes an audio file to disc (in a format of your choice), which contains the Morse code for 2015, i.e.
..--- ----- .---- .....
You are free to choose any sort of sound for the segments, like a single-frequency sine wave, a cho... |
Let's play a one-player game called jump the array. To play, you only need an array of integers, say a. You start at some position i, and on each turn, you jump to a new position. On turn n,
if n is even, you jump to the absolute position a[i] mod length(a),
if n is odd, you jump to the relative position (i + a[i]) mo... |
In the game of Freecell, you are tasked with building four foundation piles in suit from ace to king, on a layout where you build downward in alternating colours. However, you can only build one card at a time, so you are given four "free cells" each of which can contain one card to help you move entire sequences. The ... |
For example, in traditional web hexadecimal, a certain base-16 number represents an RGB value. For example, 45A19C equals (69,161,156) in RGB.
You'll be converting from that number to RGB value, however, instead you'll be given that number in base-10 rather than base 16.
So in the example used above, 45A19C would equa... |
The most recognizable sliding puzzle is the fifteen puzzle. It has a 4 by 4 grid, 15 tiles, and one empty grid space. The tiles can only move into the empty space and must always be in line with the grid.
Let's define a generalized sliding puzzle as a two-dimensional W wide by H high grid (W, H both positive integers) ... |
Background
In this challenge, a partition of a set S means a collection of nonempty subsets of S, which are mutually disjoint and whose union is S. We say that a partition p is finer than another partition q (and q is coarser than p), if it can be obtained from q by splitting some of its sets into smaller pieces. The j... |
As the band's roadie, you have to pack the truck. Your program will place the packages so that they fit in the smallest height.
A badly packed truck
Rules
Packages may be rotated through multiples of 90 degrees. Packages may touch but must not overlap.
The output is the repacked image (to file or stdout). Your program... |
Introduction
You are a friend of a curator for an art museum, who has had the recent delight of getting modern art from four artists (some of which may give the curator zero pieces of art, young scoundrels). As this is modern art, all of any given artist's pieces look exactly the same. Your friend wants to use a comp... |
Objective
You are to write a program that receives an integer n as input (from the command line), and embeds itself (the program) n directories down the directory tree. Example with n=5:
The folder names may be whatever you wish. The only requirements are that the depth is correct, and that the program can then be ran... |
In a puzzle in an old book of mine, a game is defined in which two players choose sequences of coin flips that they believe will appear first when a coin is repeatedly flipped. (It was actually odd and even dice rolls, but this little detail doesn't matter in terms of problem equivalence.)
It is noted that if player 1 ... |
The Puzzle
You have to write a program or function p(n) that returns the square of what is entered into it and you may assume that the input is a non-negative integer. Put in simpler terms, return n2.
Rules
You are not allowed to use * or / (or any other power or square root operator, such as POW or SQRT, if your lang... |
Challenge
Your challenge is to design an interpreter for a lisp-like language, which will from hence forth be coined: GLisp. The program code for GLisp will consist of an arbitrary amount of nested expressions denoted by brackets, in the following form:
(func arg1 arg2 ...)
Note that the interpreter must allow for ext... |
The task is simple. Get me some 1000, 500 and 100 notes.
How ? you might ask. Don't worry, no need of robbing a bank as there is an ATM nearby which accepts your credit card. But your credit limit is just enough for the task so you have to be careful with the withdrawals.
Challenge
Given the number of 1000, 500 and 100... |
The paint on the walls in my room has a random, almost fractal-like, 3-dimensional texture:
In this challenge you will write a program that generates random images that look like they could be part of my walls.
Below I've collected 10 images of different spots on my walls. All have roughly the same lighting and all we... |
Stroustrup has recently posted a series of posts debunking popular myths about C++. The fifth myth is: “C++ is for large, complicated, programs only”. To debunk it, he wrote a simple C++ program downloading a web page and extracting links from it. Here it is:
#include <string>
#include <set>
#include <iostream>
#includ... |
This is the reverse of Music: what's in this chord?, which is to print the notes in a given chord. This time the input is a list of notes in a chord, and your task is to output which chord it is.
Your program should support the following triadic chords. Examples are given with root C. Chords with other roots are the sa... |
You are sick of all of the codegolf challenges. Hence you decide to write a program that will automatically golf some Python code for you. There are 3 test cases:
print quickSort([0,7,3,-1,8,10,57,2])
def quickSort(arr):
less = []
pivotList = []
more = []
if len(arr) <= 1:
return arr
else:... |
Nontransitive dice are nice little toys that defy our intuition in probability theory. We'll need a few definitions for this challenge:
Consider two dice A and B which are thrown at the same time. We say that A beats B if the probability of A showing a larger number than B is strictly greater than the probability of B ... |
Write program or function which will take left and right value of dice as integers (1-6) and return value on top.
Dice layout:
+---+
| 1 |
+---+---+---+---+
| 2 | 3 | 5 | 4 |
+---+---+---+---+
| 6 |
+---+
,^.
<´ 5 `> <-- Top value
|`._,´|
.6 | 4, <-- Side values
`.|,´
So inputting 6 4 will return... |
Consider an array of bits, say
1 1 1 0 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0
We call a contiguous subarray of length ≥ 5 a phase if at least 85% of the bits are the same and the first/last bits are both equal to the majority bit. Furthermore, we call a phase maximal if it is not a strict subarray of some other phase.
Here a... |
This question is inspired by retrograde music. Retrograde music is a piece of music that can both be played normally (from the beginning to the end) as reversed (from the end the beginning). A similar thing exists in literature, this is called a semi-palindrome, e.g. "roma" and "amor".
Your task is to write a retrograd... |
You are Desmond Hume. For the last 3 years, you and your partner, Kelvin, have been slave to a computer that requires a very specific sequence to be entered into it every 108 minutes to save the world.
4 8 15 16 23 42
Your partner died 40 days ago (due to an unfortunate accident involving Kelvin's head and a big rock)... |
In this contest you have to write a program, that accepts a black and white pixel image, and tries to alter it, such that the white shape forms star domain, with as few changes as possible.
Allowed changes are turning white pixels into black ones and turning black pixels into white ones.
The output must again consist o... |
This is Weekly Challenge #2. Theme: Translation
Write a program or function that takes in source code for a program in Prelude and outputs code for an equivalent program in Befunge-93. For the program to be equivalent, it should, for any given input, produce the same output as the Prelude program, and halt if and only ... |
Is it possible to make this C code smaller? It prints out all primes from 0 to 1000.
C, 89 chars
int i,p,c;for(i=2;i<1e3;i++){c=0;for(p=2;p<i;p++)if(i%p==0)c++;if(c==0)printf("%u\n",i);}
|
Program your robots to deliver packages in a warehouse infested with destroyer
drones. Avoid the drones and get your packages to the right place as fast as you
can.
Delivery Robots
There are packages labeled a-z in a warehouse.
Packages must be delivered to a matching chute A-Z.
A robot cannot move to a square that co... |
A little context:
Book has 411 Pages
Read a random number of pages on the first day which is unknown
Number of pages to read next day is the square of the sum of the digits of the page currently on
I.e. on Page 36: read 81 pages next day
On day 6 The square answer directly adds to current page number to make 411
Fini... |
Your task is to take the following simple C code and make a program which will interpret this code and produce a correct output, and be able to handle small modifications to the original code. The C code is
int x = 4;
int y = 5;
int z;
z = x * y;
if(z>10)
{
printf("%d is bigger than 10!",z);
}
Or as one line of ... |
Background
In this challenge, a base-b representation of an integer n is an expression of n as a sum of powers of b, where each term occurs at most b-1 times. For example, the base-4 representation of 2015 is
4^5 + 3*4^4 + 3*4^3 + 4^2 + 3*4 + 3
Now, the hereditary base-b representation of n is obtained by converting t... |
Your challenge is, given a series of notes, print the fingerings that minimize the amount of movements you need to make (explained below).
My not standard way of transforming fingerings to text:
The | line separates the left and right hand. Use 1 for the index finger, 2 for the middle finger and 3 for the ring finger. ... |
Our new bank needs a teller transaction system but there is a problem. There is
only a few hundred bytes of space left on our server, so you will have to write
very compact code.
Database
Thankfully our database is very simple (it was built by the schoolboy son of our
bank president), and we only have a few customers s... |
In many image-processing challenges, the post contains images, which must be saved to a file in order to be able to work on the problem. This is an especially tedious manual task. We programmers should not have to be subjected to such drudgery. Your task is to automatically download all the images contained in a Code ... |
I want to try a new form of code golf here. Similar to bonuses, not all parts of the challenge have to be completed, but each answer has to implement a subset of certain size (and there is a core that every answer has to implement). So besides the golfing this challenge also involves choosing a set of features that go ... |
Introduction
The game takes place in a small world with different towns. The rulers of the towns hate each other and would like to rule the world. The people are divided into two groups, warriors and lowborns. However, lowborns can raise to warriors. You are the ruler of three of these towns.
Gameplay
When the game beg... |
In this challenge, your job is to find the straightest path from point A to point B in a two-dimensional maze. This is very similar to finding the shortest path, which has been done to death, but instead of minimizing the length of the path, you minimize the number of turns (or angles or corners, whatever you want to c... |
Background
Alice and Bob play a game called construct a binary word. To play the game, you fix a length n >= 0, a set G of length-n binary words called the goal set, and a length-n string t containing the letters A and B, called the turn order. The game lasts for n turns, and on turn i, the player defined by t[i] selec... |
All good coders know some good sorting algorithms like quicksort or merge sort. There is also slow sorting algorithms, e.g. bubble sort and insertion sort.
But those are such easy to implement and so, so efficient. Too efficient. Your task is to create very slow sorting algorithm.
Please attach the Big O notation of y... |
Consider a piece of string (as in "rope", not as in "a bunch of characters"), which is folded back and forth on the real line. We can describe the shape of the string with a list of points it passes through (in order). For simplicity, we'll assume all of those points are integers.
Take as an example [-1, 3, 1, -2, 5, ... |
Challenge
You must, in the least bytes possible, implement the Binary Heap data structure and each of the following methods that operate on it:
A function which takes no arguments and returns an empty Heap
A function which takes a list of arguments with an arbitrary length and returns a Heap containing the elements
A ... |
Background
You have just learned what combinatory logic is. Intrigued by the various combinators you spend quite a bit of time learning about them. You finally stumble upon this particular expression:
(S I I (S I I))
You notice that when trying to reduce it to its normal form, it reduces to itself after three steps:
(... |
Cops' Thread
In this challenge, your goal is to write a function that accepts a integer N, and that function will return the first N primes. However, you must do this in the most characters possible.
You may use any method you wish to produce the primes.
You are not allowed to modify your code after posting.
Only pri... |
Robbers' Thread
In this challenge, your goal is to crack some code written by the Cops (their code is here) by modifying it. You have cracked their code if:
Your modified code has a maximum levenshtein-distance of 10 from theirs, and has fewer characters
The function, given the same valid input, will produce the same... |
Each character in this 64 by 64 block of text has been chosen randomly and uniformly from the 95 printable ASCII characters.
/rq$:Zy5*g'$DeGXX2o8y "{@Cg:FR9qih}xh >5$DsF1Fs5Ao~smFp;.RJbV )U
c4\(|Sx*V$10G9xO:NjHKasem%,\9[pPm@&kTaN~HC[;9`lgqlAH(7dt0a-5}LJ[
&sifw9V-.PLRoD~F'dJYA^Q)L#h>$9h!B4b&ceKp8~HndzDm#1/ySydrf5T8[Y%4
... |
Directions
Write a program that, given an input integer n (n >= 0), outputs the smallest positive integer m where:
n = a[1]^b[1] + a[2]^b[2] + a[3]^b[3] + ... + a[k]^b[k]
a and b are finite sequences of the same length
all elements of a are less than m
all elements of b are less than m
all elements of a are different ... |
Programmers are often obsessed with drawing fractals. I think we need a new computer based medium.
The H tree is a fairly simple type of fractal made of horizontal and vertical lines. Here it is at it's tenth iteration (courtesy Wikipedia):
Now, imagine each of the lines in the image is a directory (folder) in a stand... |
Input
Your input in this challenge is a list of integer pairs. They represent the southwest corners of unit squares on the plane, and the list represents their union as a subset of the plane. For example, the list
[(0,0),(1,0),(0,1),(1,1),(2,1),(1,2),(2,2)]
represents the red-colored set in this picture:
Output
Yor o... |
Notes
This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.
This is no longer a popularity-contest, nor are snippet lengths limited by the vote ... |
This is my first experiment with an asymptotic complexity challenge although I am happy with answers entirely in code as long as they come with an explanation of their time complexity.
I have the following problem.
Consider tasks T_1, ... T_n and procs M_1, ... , M_m. Each task takes a certain amount of time to perfor... |
tl;dr [True] Billy got a Stack Overflow pen from Tim Post. Billy was stupid enough to use the pen, knowing that he was not worthy. Billy's friend took the pen apart, so Billy put the pen in a drawer at his house, hoping he would eventually fix it. A year later, Billy can only find half of the pen's pieces, and not the ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.