instruction stringlengths 34 53.1k |
|---|
In 1984, Michael Crichton wrote a security program in BASIC that was published in Creative Computing magazine. The program would ask the user to type a phrase of their choice, record the intervals between the keystrokes, then ask them to retype the phrase. If the timings differed by too much, the program would identify... |
Task
The task is to tile polygons, given a vertex configuration.
Scoring
Your score is equal to the "complexity level" your submission reaches. Complexity levels are cumulative, meaning that to reach #3 you must also support #1 & #2.
Submissions at an equal complexity level are distinguished by byte count; lowest wins... |
Notice: Following popular demand I have slightly relaxed the rules:
The maximum regex size grows by 1 byte every 5 answers. Answer N may use up to 29 + ⌈N/5⌉ bytes.
The score of each answer will be (M/(30+N/5))N
In regex golf, you're given two sets of strings, and are asked to create the shortest regex which match... |
Introduction
You are stranded on a deserted island with some servants and are hunting for treasure. The longer one searches, the more treasure one finds. The fewer people searching, the more each person finds.
Due to limited supplies, the leader has decided that a few people, up to a quarter of the group, shall be left... |
This challenge's concept is pretty simple. All you have to do is write a program that will compile as both valid C and valid C++! Well, there are some catches. The program must behave differently when compiled in each language. The program must have different output for each language in order to be considered "behaving... |
Your job is to write a program (or two separate programs) in any language that:
Can take a completed Sudoku board as input (in any logical format) and compress it into a string of characters
Can take the compressed string as input and decompress it to get the exact same completed Sudoku board (output in any logical fo... |
Digesting a polygon is a process in which you take an input polygon, and create another polygon that can contain the entirety of the input polygon, while having one side less than it.
The goal of this challenge is to generate the optimal polygon digest- a polygon digest that has the minimum area possible.
Your challeng... |
This is supposed to be a code golf challenge on the simpler end of the spectrum. But I figured it could be nice to bring out some micro-optimisation here.
There are three basic types of DVI connectors: DVI-A (analog), DVI-D (digital) and DVI-I (integrated). Furthermore, there are single-link and dual-link versions of t... |
You are given integers N and M, 1 <= N,M <= 10^6 and indexes i and j. Your job is to find the integer at position [i][j]. The sequence looks like this (for N=M=5, i=1, j=3 the result is 23):
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
Shortest code wins. Good luck!
|
Sequences
You are given four number sequences, numbered 1 through 4.
OEIS The location of 0's when the natural numbers are listed in binary. Here's an example of how to calculate the sequence:
0,1,10,11,100,101,110,111
^ ^ ^^ ^ ^
0 3 78 10 14
The start of the sequence goes like this: 0, 3, 7, ... |
Let's say you have a list of words and you want to be able to use letter cards to spell each word. For example, to spell cat, you would use three cards labelled C, A, T.
Assuming each card is double-sided, submit a program to define a minimum number of cards that can be used to spell the entire list of words.
Input is ... |
This is a challenge of practicing golf optimization in Python -- reusable tricks and shortcuts to shave off a few characters. Many will be familiar to Python golfers and use common ideas from the Python Tips. Some of these use Python-specific features that you might not know exist unless you've seen them, so do take a ... |
The shortest C# code that generates an uncatchable ExecutionEngineException wins. You are not allowed to call FailFast directly or indirectly.
|
The aim of this challenge is to write a program that satisfies the following conditions:
The program is not palindromic, or essentially palindromic (meaning that it is possible to remove characters to make it a palindrome without changing the effects of the program).
The program is not an involution (meaning that it d... |
As we all should know, there's a HTTP status code 418: I'm a teapot.
Your mission, should you choose to accept it, is to use your creativitea and write the smallest possible server that responds with the above status code to any and every HTTP request made to it.
Standard loopholes apply, including
Fetching the desire... |
Today, your task is to write a program (or a function) that accepts a string and outputs (or returns) four integers.
Input
The input string is a CSS3 selector, and can contain basically any Unicode character.
Output
The output represents the CSS specificity of this selector.
The first number is always 0 (because it'... |
Consider the function Remove(n, startIndex, count) that removes count digits from the number n starting from the digit at position startIndex. Examples:
Remove(1234, 1, 1) = 234
Remove(123456, 2, 3) = 156
Remove(1507, 1, 2) = 07 = 7
Remove(1234, 1, 4) = 0
We will call the prime number X fragile if every possible Remov... |
The goal is to find a way better than the current best known way of encoding the index of a child HTML element, so that encoded indices have the following property.
if (index_i >= index_p) {
assert(encoding(index_i).indexOf(encoding(index_p)) == 0);
}
if (index_i < index_p) {
assert(encoding(index_i).indexOf(enco... |
Your task is to create a program which outputs a completed tournament bracket given a list of entrants, their seeds, and their scores in each game; in the fewest characters possible.
Input
Your entrants will have the following data. You can organize your data in whatever form you like, but you cannot pre-sort your arra... |
You just invited a liberal arts major to your house and you're telling him/her
"You know, I am a great programmer and I can do x and y and z..."
S/he quickly gets bored and asks you:
"If you really are a great programmer, can you make a programme to let me draw, I just need to draw lines on the screen by using the
... |
Choose your favorite famous computer scientist or computer science pioneer who was born in 1942 or earlier (as 1943 marks the start of the creation of the 'first' computer). They should have a Wikipedia page or other site that lists their birth year and tells how their accomplishments relate to computer science. You ma... |
The Challenge
In as few characters as possible, find the value of \$i^n\$, given \$n\$, a positive integer greater than 0. This should be outputted as a String.
For those that don't know, \$i\$ is defined such that \$i^2=-1\$. So:
\$i^1=i\$
\$i^2=-1\$
\$i^3=-i\$
\$i^4=1\$
This then repeats..
Rules
If your language s... |
I just discovered this website and was amazed. Somehow this challenge popped into my mind:
Provided a very long list of words; Write or describe an algorithm which finds a regex to match them all.
Ex.: A very long list of Dates, model-numbers, CD-Codes, ISBNs et cetera.
I hope it's not too big or does not belong here. ... |
Credits for the challenge idea go to @AndrewPiliser. His original proposal in the sandbox was abandoned and since he has not been active here for several months, I have taken over the challenge.
Balanced ternary is a non-standard numeral system. It is like ternary in that the digits increase in value by a factor of 3 a... |
Cyclic Equivalence
Let L be a list of pairs of letters, for example [(a,b), (a,c)]. We call L a list of commutators. Two words are cyclically equivalent over L, if one can be transformed into the other using the following operations:
Cyclic shift: pop a letter from the beginning, and push it to the end.
Commutator swa... |
Create a bidirectional Gematria calculator, for any given sequence of Unicode characters as the alphabet.
Gematri-What?
Gematria is a system of assigning numerical values to symbols, developed by ancient Greeks and adopted by ancient Jews. It is in a way like ASCII or Unicode, it's just non-linear... See the following ... |
A perfect square is a number that is the square of an integer.
However, let's define something called a Magical Square, which is a perfect square with the following restriction:
The perfect square must be the sum of the numbers 1...N for some natural number N. Write a program that calculates the first X magical squar... |
Leaderboard - JIT Compiled (Lower is better)
es1024 - 81.2 points (including a working compiler!)
Kieth Randall - 116 points
Ell - 121 points
Leaderboard - Interpreted (Lower is better)
Martin Büttner - 706654 points (somewhere around 2 hours).
criptych - 30379 points (97 seconds)
Your mission, should you choos... |
Objective:
The objective is to calculate e^N for some real or imaginary N (e.g. 2, -3i, 0.7, 2.5i, but not 3+2i). This is code golf, so, shortest code (in bytes) wins.
So, for example:
N = 3, e^N = 20.0855392
N = -2i, e^N = -0.416146837 - 0.9092974268i
The letter i shouldn't be capitalized (since in math it is lower... |
The best solution I've found so far for a golf code puzzle I'm working on includes two rather fat-looking invocations of range. I'm very new at code golf, especially in Python, so I could use a few tips.
The relevant fragment is this
[x for x in range(n+1,7**6)if`x`==`x`[::-1]*all(x%i for i in range(2,x))]
The upper ... |
Background
Imagine, you have a big array A, which is mostly zeroes, but contains a short subarray B which has only strictly positive entries. For instance:
| A |
[0 0 0 0 1 2 3 0]
| B |
Now say, we split the array A into consecutive subarrays of length d ... |
ESL gaming, where you can challenge players to play games. I've provided some steps you can take manually to challenge a player. Note that you have to signup for an account and have to be logged in to perform these steps. (Important: you have to sign-up for the ladder before you can challenge on that ladder too. Finall... |
You have to take 2 string inputs and output the sum of these two strings without converting them to int or using any numeric data type.
ex.
string one = "123";
string two = "456";
string sum = "579";
Assume the strings won't be larger than 10 digits.
This is code golf and shortest answer in characters wins. An ed... |
Challenge
On each of the 12 days of Christmas, output the appropriate verse of "12 days of Christmas", according to the date, otherwise output the chorus of "I Wish It Could Be Christmas Everyday".
Leading and/or trailing newlines (\n) and trailing spaces are permitted. You may not read from any external sources.
Basic... |
What general tips do you have for golfing in Go? I'm new to Code Golfing and looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Go.
Please keep to one tip per answer.
|
One of the games of the French TV show Des chiffres et des lettres, called Le compte est bon ('The total is right'), consists of the following :
You get a number A between 101 and 999 as well as six numbers E1,..,E6 chosen randomly, with possible repetitions, from {1,2,3,4,5,6,7,8,9,10,25,50,75,100}
The goal is to get ... |
NOTE: This question was migrated from https://stackoverflow.com/q/27134588/1442685
PHP QUESTION
Almost purely out of curiousity, how can I take an array like this:
array( 'fruit' => 'banana', 'drink' => 'milk')
And convert it to an array like this:
array( 'fruit=banana', 'drink=milk')
Requirements
Cannot use anonymo... |
The challenge
Get familiar with the Ulam spiral:
The aim is to print the spiral like in the picture above!
Rules
Write a function ulam(n)
where n is a odd positive integer and describes the size of the grid to print.
All non-primes numbers should be replaced with | horizontal and - vertical as in the picture above foll... |
First, study this puzzle to get a feel for what you will be producing.
Your challenge is to write a program or function which will output a circular graphic like the ones from the puzzle, given a (base 10) number between 1 and 100 (inclusive). This is similar to this challenge, except that you will be producing a graph... |
My friend and I were working on a lab in our AP Computer Science class and decided to code golf one one the problems since we still had half the class free after we finished. Here is the question:
Given a number n, is n divisible by each of its digits?
For example, 128 will pass this test- it is divisible by 1,2, and... |
Your job is to convert decimals back into the sum of the square roots of integers. The result has to have an accuracy of at least 6 significant decimal digits.
Input:
A number indicating the number of square roots and a decimal indicating the number to approximate.
Example input:
2 3.414213562373095
Output:
Integers s... |
You should all be familiar with the Conway sequence (a.k.a. 'look-and-say'-sequence) by now:
1
11
21
1211
111221
312211
etc
You can also start by any arbitrary number as starting point. Let f(s) be the next element of the sequence. Now for every given swe can find f(s). The reverse is not as trivial: it... |
Your goal is to write a perfect player for the game of Wythoff's Nim.
Rules of Wythoff's Nim
Wythoff's Nim is a deterministic two-player game played with two piles of identical counters. Players alternate turns, in which they do one of these:
Remove one or more counters from the first pile
Remove one or more counters ... |
Your goal is to implement Möbius inversion, a linear operation on a sequence of numbers that is used in combinatorics and number theory. Fewest bytes wins.
What is Möbius inversion?
Given a (finite) integer sequence f_1, f_2, ..., f_N, we can compute its divisor-partial-sum g, whose nth element g_n is the sum of all te... |
Consider a square of printable ASCII characters (code points 0x20 to 0x7E) for side length N, like the following (here, N = 6):
=\
g \
7
m+y "g
L ~
e> PHq
We also require each row and each column to contain at least 1 space and 1 non-space character. (The above example satisfies this.)
We define the neg... |
RNA, like DNA, is a molecule found in cells encoding genetic information. It consists of nucleotides, which are represented by the bases adenine (A), cytosine (C), guanine (G) and uracil (U).* A codon is a sequence of three nucleotides.
Proteins are large molecules which perform a vast array of functions, such as kerat... |
The Challenge
Create a program that brute-force* decodes the MD5-hashed string, given here:
92a7c9116fa52eb83cf4c2919599c24a which translates to code-golf
The Rules
You may not use any built-in functions that decode the hash for you if
the language you choose has such.
You may not use an online service to decode the ... |
Strings with Context
For the purposes of this challenge, a string with context is a triple of strings, called the left context, the data part, and the right context. It represents a substring of a longer string. We use the vertical pipe | as a separator, so an example of a string with context is cod|e-go|lf, where the ... |
Building a golfed rot13 encryptor is too easy because the letters are all the same order in the ASCII character space. Let's try a rot32 engine instead.
Your task is to build a function that takes a Base64 string as input and returns the same string but with each letter rotated 32 symbols from its original (in essence,... |
The minmod function is a variant of the familiar min, which appears in slope-limiting high-resolution schemes for partial differential equations. Given a number of slopes, it picks out the flattest slope, while taking care of relative signs between the slopes.
The function takes an arbitrary number of parameters. Then ... |
Semordnilaps (also known as heteropalindromes, semi-palindromes, half-palindromes, reversgrams, mynoretehs, reversible anagrams, word reversals, or anadromes) are words which are also words when spelled backwards. A few examples are:
Ward <=> Draw
Mined <=> Denim
Parts <=> Strap
Given a positive integer N (via functi... |
This was inspired by Print a Negative of your Code and Golf a mutual quine.
Consider a rectangle of characters, that meet the following restrictions:
Consists solely of printable ASCII characters
Dimensions both greater than 1
Each row and each column contains at least one space.
Each row and each column contains at ... |
Format
The format is a 64 bit value x representing a IEEE-754 double-precision binary floating-point number (a.k.a "a double"). x is assumed to represent a real number (not a NaN or Infinity).
Goal
The goal is to print/output the shortest string containing a decimal representation for which x is the closest IEEE 754 re... |
It's winter, and the time of year has come for it to start getting cold (and for strange colorful headcloths to start appearing... soon). Let's write some code to make avatar pictures and other images frozen over, to fit the theme!
Input
The input to submissions to this challenge should be an image (the image to m... |
Based on the "binary, but with twos" notation mentioned in this numberphile video, write a function that takes a single number as input and outputs all variations of that number in a "binary" system where twos are allowed.
Rules
Code must only be a function/method, not a full program
Input is an integer passed as the ... |
Objective
Find the most expensive path from the top-left of a square grid to the bottom-right such that its total cost is below a given threshold.
Scenario
You are given a square NxN grid.
You are given a maximum cost.
Every cell in the grid has a cost. The top-left cell has cost 0.
The cost of a path is the sum of th... |
Write a program or function that takes two numbers - x>3 and n>0 - as input, and finds all possible bases b where the digit 3 appears at least n times in (x in base b).
Input and output may be through command line or function arguments, stdin/stdout, graphical input/output, error messages, function returns, etc.
The co... |
Background
Consider a (closed) chain of rods, each of which has integer length. How many distinct hole-free polyominoes can you form with a given chain? Or in other words, how many different non-self-intersecting polygons with axis-aligned sides can you form with a given chain?
Let's look at an example. Consider a part... |
As you may know, in DNA there are four bases — adenine (A), cytosine (C), guanine (G) and thymine (T). Typically A bonds with T and C bonds with G, forming the "rungs" of the DNA double helix structure.
We define the complement of a base to be the base it bonds to — i.e. the complement of A is T, the complement of T is... |
The problem
Through a terrible procastination accident you are reborn as Scrooge McDuck for a day. To make the most out of the situation you decide to give away food to the poor. Since you also are a mathematician you store the food in a vector v(1,2,3).
You want to give each family approximately the same food. To mak... |
For the purpose of this challenge, we say that a regex pattern matches a string if the entire string is matched by the pattern, not just a substring.
Given two regex patterns A and B, we say that A is more specialized than B if every string that is matched by A is also matched by B but not the other way around.
We sa... |
You are to write a very small program within 100 characters. Your program must distinguish between masculine and feminine french nouns. The output should be un if it is masculine and une if it is feminine. Often, there are certain statistical rules you can follow (e.g. if it ends in an "e" it is more likely feminine th... |
CONGRATULATIONS to @kuroineko. Wins the bounty for excellent speed (672 moves) on the Gauntlet track.
LEADER:* Nimi scoring a lightweight 2129. Other entries are larger but showing some serious speed.
*Leader may change due to later entries.
Your task is to write a small program that can drive a racing car fast.
Rules
... |
You're given a true colour image. Your task is to generate a version of this image, which looks like it was painted using paint-by-numbers (the children's activity, not nonograms). Along with the image, you're given two parameters: P, the maximum size of the colour palette (i.e. the maximum number of distinct colours t... |
Your challenge today is to implement a t9-like functionality.
You will implement a function that will only have 2 parameters.
You will receive 1 phone number in a string and the content of a text file with a list of words (don't assume a specific newline style).
You can use the link https://raw.githubusercontent.com/en... |
Challenge
You are given the following function:- which is the same as:-
with the base cases q(r, b, L) = 1 whenever r ≤ L, q(r, 0, L) = 0, if r > L and q(r, 0, L) = 1, if r ≤ L.
Your task is to code a program that takes r as input, and outputs the value of q(r, r - L, L) for all L taking integer values from 1 to (r-... |
After spending a while on Stack Exchange, I can recognise most sites in the Hot Network Questions by their little icon (which is also their favicon), but certainly not all of them. Let's write a program which can! You're to write code which determines the site, given one of the (currently) 132 favicons, including Stack... |
The Hilbert curves are a class of space-filling fractal curves where every bend in the path is at a right angle and the curve as a whole fills up a square, with the property that sequences of consecutive segments are always displayed as contiguous blocks.
Traditionally, the curve is drawn as a series of very squiggly l... |
We define whitespace to be any of the three characters, tab (0x09), newline (0x0A) or space (0x20).
For this challenge, you're to write two programs or functions in the same programming language, which perform the following tasks:
Count the whitespace characters in a given string. For instance, the input
123 -_- a... |
The challenge is make a digital clock that exhibits ascii numbers in a 24-hour format like:
_ _ _ _
|_| |_| . |_| |_|
|_| |_| . |_| |_|
or
_ _ _
_| _| . |_| |_
|_ _| . | _|
and updates the screen every 1 minute (or every 1 second, for praticity reasons). It must reset to 00:00 after 23:5... |
Your task is to take an string containing an isotope of an element as input, encoded like the following example with the atomic number followed by a space and the IUPAC chemical symbol for the element:
162 Dy
and return the number of neutrons in an atom of that isotope.
In the above example, dysprosium-162 has 96 neut... |
James Bond is about to start a new mission and you are his computer scientist friend. As Tic Tac Toe is becoming more and more popular you decide that nothing would be more underhanded than a Tic Tac Toe encoder/decoder™.
For each line the decoder will follow the following steps:
Convert from 'O','X' and ' ' [space] ... |
I can have a large if/else condition for each 30 minutes but I'm looking for more math and Unicode based solution.
Here are clock emojis:
. If you lack proper rendering support, you can see them below (they're not in the same order and they may look different to what you see) or at the Unicode chart, page 4. They corre... |
This challenge is partly an algorithms challenge, involves some math and is partly simply a fastest code challenge.
For some positive integer n, consider a uniformly random string of 1s and 0s of length n and call it A. Now also consider a second uniformly chosen random string of length n whose values are -1, 0, or 1... |
Challenge
Write the shortest code that can sum all the time durations that appear in the stdin. The program must only consider the strings that match with one of the following patterns and ignore the rest.
HH:MM:SS (it will be interpreted as HH hours, MM minutes and SS seconds)
H:MM:SS (it will... |
I was working on a math question with a friend of mine, and we decided to write a script that finds the answer. The original question is as follows:
The difference of two natural numbers is 2010 and their greatest common denominator is 2014 times smaller than their lowest common multiply. Find all the possible solutio... |
Your goal is to check whether a completed Minesweeper board is valid. This means that each number is a correct count of mines in cells adjacent to it, including diagonals. The board does not wrap around.
As usual, you should give a function or program, and shortest code in bytes wins.
See also past challenges to genera... |
What better problem for PCG.SE than to implement PCG, A Better Random Number Generator? This new paper claims to present a fast, hard-to-predict, small, statistically optimal random number generator.
Its minimal C implementation is just about nine lines:
// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / pcg-rand... |
You need to produce the word codegolf
Rules:
None of the characters of the word codegolf (i.e. 'c', 'o', 'd', 'e', 'g', 'o', 'l' and 'f') in either case can exist anywhere in the code.
Case of the word must be one of three:
All Upcase (CODEGOLF)
All Downcase (codegolf)
Capitalized (Codegolf)
You only need to produ... |
You have been hired by the government of North Dakota to encrypt the state's communications. Write two programs, one to encrypt a message and one to decrypt that message.
The government is not really tech-savvy, so the encryption algorithm does not need to be sophisticated; just make sure the result doesn't look simila... |
Winter Bash 2014 is on its prime and don't we all love the hats? Especially the secret hats!
So why not draw one of secret hats?
The challenge
Your task is to draw the Warm Welcome Hat in proportion, in a language of your choice and having an exact construction as appearing on this page.
As always, you can render the h... |
Imagine a bunch of rectangles drawn in the plane, each rectangle with its vertices at integer coordinates and its sides parallel to the axes:
The rectangles partition the plane into a number of disjoint regions, coloured red and blue below:
Your goal is to find the number of such regions which are perfect squares. In... |
F# solutions known inside 140 chars, and this is a Rosetta Code problem.
Required result on stdout or in a string variable for input year 2014:
2014-01-26 2014-02-23 2014-03-30 2014-04-27 2014-05-25 2014-06-29 2014-07-27 2014-08-31 2014-09-28 2014-10-26 2014-11-30 2014-12-28
As it was requested, for 1900:
1900-01-28 ... |
Challenge:
Draw Sri Yantra.
How to:
There are different ways to draw it. All include many steps. If you think you can draw it without following the linked steps scroll below for the elements you must have in your drawing.
Complete steps can be found here:
http://www.saralhindi.com/Shri_Yantra/makingsky14steps_eng.htm
(... |
The Caesar Cypher is a very simple substitution cypher where each letter is shifted by a fixed offset (looping around Z to A). Similarly, we can also a Caesar cypher for the set of printable ASCII characters. These are the 95 characters from code points 0x20 to 0x7E. For a given offset d, we map the code point C to
(C ... |
yes, from coreutils, is 91 lines long. Many of them are comments, but that is still WAY too long.
Edit from September 2019: the source file grew over the past five years and is now 126 lines long.
Write a program that imitates yes:
outputting to stdout an infinite stream of "y\n"'s
there must be an option to stop it o... |
In this meta-challenge, you will score your own atomic-code-golf submissions. More precisely, you will need to write a program P in language L such that the atomic-score of P is produced by P.
Score
The idea behind atomic-code-golf is to count language tokens instead of bytes. However, in practice, it is hard to defin... |
This question asks for a T9 dictionary matching functionality which is a very interesting problem. But T9 has another way of typing and that is typing character-by-character. You would NOT need a dictionary to implement this keyboard.
Here is key-map of a T9 keyboard if you forgot:
+-------+-------+-------+
| 1 | ... |
Joe lives at the Bahamas. It is winter. His children are disappointed that there is no snow. Joe needs to make snow for his children. Fortunately, he has a 3-d printer. He plans to make snowflakes with it. Unfortunately he has no idea how a snowflake would look like. In fact, he has never seen a snowflake! Let us help ... |
I've heard that your code can run faster if you indent it in reverse, so that the compiler can process it like a tree design pattern from the very top of the "branches" down. This helps because gravity will speed up the time it takes for your code to be compiled, and the data structure efficiency is improved. Here's a... |
The game Waving Hands is somewhere between a pen-and-paper Magic: the Gathering and a very elaborate Rock Paper Scissors. Each turn you write down one of eight gestures for each hand:
wiggled Fingers
proffered Palm
Snap
Wave
Digit pointing
Clap
staB
Nothing
There are few important rules that take precedence over the ... |
The difficulty with sharing pizza with friends is that it is hard to make sure that everyone gets the same amount of pepperoni on their slice. So, your task is to decide how to fairly slice a pizza so that everyone is happy.
Directions
Write a program that, given a list of the positions of pepperonis on a circular pizz... |
Write a snippet to calculate the mode (most common number) of a list of positive integers.
For example, the mode of
d = [4,3,1,0,6,1,6,4,4,0,3,1,7,7,3,4,1,1,2,8]
is 1, because it occurs the maximum of 5 times.
You may assume that the list is stored in a variable such as d and has a unique mode.
e.g.: Python, 49
max((... |
Challenge
Your task in this question is to write a program or a named function which takes a positive integer n (greater than 0) as input via STDIN, ARGV or function arguments and outputs an array via STDOUT or function returned value.
Sounds simple enough ? Now here are the rules
The array will only contain integers ... |
Challenge
You task for this question is to split an input array of integers on the second occurrence of every integer in that array.
Not clear enough ? Here is an example to help
Input array:
[2 1 1 2 3 2 2 4 5 6 7 3 7 0 5]
Output:
[[2 1] [] [3 2 2 4 5 6 7] [] [0] []]
Explanation:
Here is the array with just the seco... |
The Challenge
Consider the 3x3 king grid, as shown in the following ASCII graphic:
A--B--C
|\/|\/|
|/\|/\|
D--E--F
|\/|\/|
|/\|/\|
G--H--I
You are given as input a length-9 list of integers that represent a labeling of the nodes. For example, the input [0,1,1,2,1,0,5,5,1] represents the following labeling:
0--1--1
|\/... |
You have an input array of size m*n. Each cell in the array is populated with either P or T. The only operation you can do on the array is flip columns. When you flip a column, the letters in all the cells of that column switch (P becomes T and viceversa). If you have 'x' number of rows with same letter (e.g. PPPP) the... |
Write a program that when given five integers as input, outputs the value given by the following integral:
Input is five integers (in any reasonable format) in the order a b c d e where each number corresponds to the variables in the image above.
No built in integral functions allowed.
Output must be a base ten float... |
Your goal is to display ASCII art of a formation in ten-pin bowling where only some of the pins remain. Fewest bytes wins.
The tens pins are in a triangular formation:
O O O O
O O O
O O
O
Pins are labelled from 1 to 10 as:
7 8 9 10
4 5 6
2 3
1
Drawing pins as O and missing pins as ., the formation 1 3 5 6... |
Input
A list of nonnegative integers.
Output
The largest nonnegative integer h such that at least h of the numbers in the list are greater than or equal to h.
Test Cases
[0,0,0,0] -> 0
[12,312,33,12] -> 4
[1,2,3,4,5,6,7] -> 4
[22,33,1,2,4] -> 3
[1000,2,2,2] -> 2
[23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.