instruction stringlengths 34 53.1k |
|---|
What are some tips for code-golfing in Swift? Its focus on safety seems to make it difficult to golf in, but that makes little tips and even more useful. Are there any features in Swift that may help it excel in code-golf in certain applications?
Please post one tip per answer.
|
Your task is to build a natural number using the fewest number of ones and only the operators + or -. For example, the number seven can be written 1+1+1+1+1+1+1=7, but it can also be written as 11-1-1-1-1=7. The first one uses 7 ones, while the latter only uses 6. Your task is to return the minimum number of ones that ... |
Look at these photographs of natural scenes, with one of the RGB channels taken out of them:
Source (with red): https://en.wikipedia.org/wiki/File:Altja_j%C3%B5gi_Lahemaal.jpg
Source (with green): https://commons.wikimedia.org/wiki/File:2007_mather-lake_hg.jpg
Source (with blue): https://commons.wikimedia.org/wiki/F... |
Write a program or function, that given a success probability p, a number n and a number of trials m returns the chance of at least n successes out of m trials.
Your answer must be precise to at least 5 digits after the decimal.
Test cases:
0.1, 10, 100 -> 0.54871
0.2, 10, 100 -> 0.99767
0.5, 13, 20 -> 0.13159
0.5... |
An Indian legend tells the story of the alleged inventor of the chess game, who impressed the emperor of India with his game so much that he would get rewarded with anything asked.
The man said he wanted to be paid in rice. He wanted a grain of rice for the first square of the chessboard, two for the second, four for t... |
A palindromic number (in case you don't know) is a number which reads the same backwards and forwards (example, 11). The first 15 non-palindromic numbers are: 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26. This is A029742. I constantly need these numbers, but my sticky note pad is very small, so your code ... |
This was inspired by a Minecraft mini-game. The rules are pretty simple: you run and jump around, and every block you step on disappears once you've stepped on it. The goal is to be the last one left.
Your bot should be a complete program. It should accept input as a command line argument. The input will be a map of th... |
While doodling around on square-ruled paper the other day, I came up with the above negative-space font for digits. In case you haven't spotted it yet, the spaces between the above shapes yield the golden ratio 1.618033988749. In this challenge, your task is to take a number as input and render it exactly as the examp... |
Challenge: Read a string from user, print number of each vowel, then place all remaining chars in a line. Shortest answer wins!
Output must look like this:
Enter String: Input
Vowel Count: a: #, e: #, i: #, o: #, u: #
Remaining characters: Vowel-less Input
For example:
Enter String: LoremIpsumDolorSitAmetConsecuteurA... |
I am a very casual code golfer, and don't often see posts until they show up in the "Hot Network Questions" sidebar over on StackOverflow. Usually, I'm late to the game, and since the only language I know is Python, there is little point in me answering as there are already several Python answers. Your challenge is t... |
Gamma function is defined as
It is a well-known fact that for positive integers it coincides with a properly shifted factorial function: Γ(n) = (n - 1)!. However, a less famous fact is
Γ(1/2) = π1/2
Actually, the Gamma function can be evaluated for all half-integer arguments, and the result is a rational number mult... |
The task is to generate all the strings from 'a' to '999' including upper case characters like so:
'a', 'b', 'c' ... 'y', 'z', 'A', 'B', 'C' ... 'Y', 'Z', '0', '1', 2' ...
'8', '9', 'aa', 'ab', 'ac' ... 'az', 'aA', 'aB' ... 'aZ', 'a0' ... 'a9', 'ba'
and so on (filling in the gaps), optionally starting with the empty ... |
Your task is to write a program that will filter out some characters in a string, so that the remaining spells out (part of) the other string.
Let's say we received the string "123456781234567812345678", and the second string is "314159".
First, we put a pointer on the second string:
314159
^
So the pointer is now on ... |
Piano keys are 3 characters wide, and 7 characters tall. However, if every key was 3 charactes wide, there wouldn't be enough room for the black keys. That's why some of the white keys have parts of them cut out. There are 3 types of white keys.
Keys with the right half missing (R):
____
| |
| |
| |
| |
| |
|... |
K-means is a standard unsupervised clustering algorithm, which, given a set of "points" and a number of clusters K, will assign each "point" to one of K clusters.
Pseudo-Code of K-means
Note that there are many variants of K-means. You have to implement the algorithm I am describing below. You may have some variation o... |
Interpret DOGO
DOGO is a lesser known programming language. While the original DOGO (a joke language from a Usenet post) has never been implemented, a language resembling it has been created. The commands for the language are:
+===========+================================================================+
| Command | ... |
Coordinates in the flat-Earth world consist of latitude (x) and longitude (y), which are integers in the range 0...9999. Much like Gaussian integers, but they are always written using this notation:
411S 370E
That is, with S or N appended to the latitude, and E or W appended to the longitude, with space(s) between the... |
EDIT: The incorrect A rhomb substitution has been fixed. Apologies to anoyone who had started working on a solution.
Consider the following substitutions, where the substituted rhomb(us) is scaled up and shown in red:
EDIT: Note the anchor points (circle) created where a corner of each new rhomb touches the substituted... |
(Taken from https://en.wikipedia.org/wiki/File:Tangential_quadrilateral.svg)
A tangential quadrilateral (see example above) is a quadrilateral in which a circle can be inscribed.
Your task is to find the possible value of d given a, b, and c.
Specs
a, b, c will all be positive integers.
If no possible value of d exis... |
Your task is to build a bridge to connect two cliffs given an input d, the distance apart. d will always be even
However, the bridge needs columns to hold it up. Each column can hold a max of 6 spaces on each side.
For this example:
________ ________
| |
A | ... |
This challenge is about reading random lines from a potentially huge file without reading the whole file into memory.
Input
An integer n and the name of a text file.
Output
n lines of the text file chosen uniformly at random without replacement.
You can assume that n is in the range 1 to the number of lines in the f... |
You are given a string composed with the characters 0123456789+*(). You can assume that string is always a valid mathematical expression.
Your task is to remove the unnecessary parentheses, assuming multiplication has higher priority than addition.
The parentheses should be removed only when they are not needed structu... |
Intro (semi fictional)
I'm the solo developer of a game, I'm already struggling with character design as is. Hence I've thought of a smart solution, I'll just use images for regular monsters, outline them a bit and suddenly they are boss monsters! That will save me from thinking up new bosses yay.
However, I have appro... |
Given a list of N integers, each with N digits, output a number which differs from the first number because of the first digit, the second number because of the second digit, etc.
Example
Given this list:
1234
4815
1623
4211
The number 2932's first digit is different from the first number's first digit, its second dig... |
Introduction
The two most common trigonometric functions, sine and cosine (or sin and cos for short), can be extended to be matrix-valued functions. One way to compute the matrix-valued analogs is as follows:
Consider these two important trigonometric identities:
$$
e^{i x} = \cos(x) + i \sin(x) \\
\sin^2(x) + \cos^2(x... |
Challenge
Write a program P, taking no input, such that the proposition “the execution of P eventually terminates” is independent of Peano arithmetic.
Formal rules
(In case you are a mathematical logician who thinks the above description is too informal.)
One can, in principle, convert some Universal Turing machine U (... |
The continued fraction of a number n is a fraction of the following form:
which converges to n.
The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ..., an].
Your goal is to return the continued fraction of the given rational number (positive or negative), whether it is an:
integer x
frac... |
Background
I want to buy an plot of land and build my house on it.
My house should be rectangular, and as large as possible; however, the available plots have lots of rocky areas that I cannot build on, and I'm having trouble fitting a potential house on the plots.
I want you to write a program that analyzes the plots ... |
You have to write a function/program that will draw an ASCII art of a square made with numbers.
Challenge
This program will take one input n as a positive integer and draw a hollow square using this number. The inside must be filled with spaces. The borders also must have the same width. The width and height of the squ... |
Everyone knows what run-length encoding is. It has been the subject of many code-golf challenges already. We'll be looking at a certain variation.
Example
Normal: 11222222222222222222233333111111111112333322
Run-length: 112(19)3(5)1(11)2333322
The number in parentheses specifies the number of times the previous symbol... |
Important note: Because this challenge only applies to square matrices, any time I use the term "matrix", it is assumed that I am referring to a square matrix. I am leaving off the "square" description for brevity's sake.
Background
Many matrix-related operations, such as computing the determinant, solving a linear sys... |
Goal: Create the smallest possible code to open a separate window, in which there are 100 circles of random sizes and colors.
Rules: All circles must be visible to the unassisted, naked eye, so in other words more than 2 pixels across, the background must be black, at least 5 different colors must be recognizable, and ... |
What is the most frequent word?
Given a sentence, your program must make its way through it, counting the frequencies of each word, then output the most used word. Because a sentence has no fixed length, and so can get very long, your code must be as short as possible.
Rules/Requirements
Each submission should be eith... |
The Challenge
Implement amb and its sister statement require in whatever language you wish. See http://community.schemewiki.org/?amb for an example implementation in Scheme. You can rename them to a and r.
amb statements select a value passed to it arbitrarily, and require statements written after amb contain condition... |
Lower level languages, such as C and C++ actually have no concept of multidimensional arrays. (Other than vectors and dynamic arrays) When you create a multidimensional array with
int foo[5][10];
This is actually just syntactic sugar. What C really does is create a single contiguous array of 5 * 10 elements. This
foo[... |
The Laver tables provide examples of programs which have not been shown to terminate in the standard axiomatic system of mathematics ZFC but which do terminate when one assumes very large cardinal axioms.
Introduction
The classical Laver tables An are the unique finite algebras with underlying set {1,...,2n} and an ope... |
Brain-Flak (a cross between Brainf**k and Flak-Overstow) is a stack-based esoteric language. Since this challenge was posted, the language has evolved and updated, but this first revision of the language is known as "brain-flak classic".
You must write a program or function that takes a string of Brain-Flak classic cod... |
Inspired by this question over at Mathematics.
The Problem
Let n be a natural number ≥ 2. Take the biggest divisor of n – which is different from n itself – and subtract it from n. Repeat until you get 1.
The Question
How many steps does it take to reach 1 for a given number n ≥ 2.
Detailed Example
Let n = 30.
The... |
Given an integer N >= 2, produce an image showing a Sierpiński knot of degree N.
For example, here are knots of degree 2, 3, 4 and 5:
Click on the images to view full size (the higher the degree the larger the image).
Specification
A Sierpiński knot of degree N is drawn using the vertices of a Sierpiński triangle ... |
My electric garage door works like this:
There is just one push button to control the door
If the door is fully closed and I hit the button, the door starts to open. It takes 10 seconds to open fully
If the door is fully open and I hit the button, the door starts to close. It takes 10 seconds to close fully
If the d... |
A Latin square is a square that has no repeated symbols in either the X or Y columns. For example:
ABCD
DABC
CDAB
BCDA
is one such square. Notice how every column and row contains a permutation of the same 4 letters.
However, our Latin square has a problem: If I were to rotate the second row (DABC) 1 to the lef... |
This is somewhat similar to The centers of a triangle, but with a different point. The Fermat Point is the point P in triangle ABC such that the value of AP + BP + CP is minimized. There are two cases:
If there is an angle greater than 120 degrees, that vertex is the fermat point. Otherwise, draw equilateral triangles ... |
Introduction
Nodes in tree structures (e.g. headings in a long document, law paragraphs, etc.) are often created by assigning a specific header level (h1, h2, etc.) to each item, but outputted with additional node numbers for each level (1., 1.1., etc.), e.g.:
1. Intro (h1)
1.1. About this (h2)
1.2. Target audience (h2... |
Introduction
In this challenge, we will be dealing with a certain infinite undirected graph, which I call the high divisor graph.
Its nodes are the integers starting from 2.
There is an edge between two nodes a < b if a divides b and a2 ≥ b.
The subgraph formed by the range from 2 to 18 looks like this:
16-8 12 18
\|... |
What general tips are these for golfing in Lisp (any dialect)? Please post one tip per answer, and only answers that are specific to a dialect of Lisp (e.g. "remove comments" is not an answer).
Please post the dialect of Lisp your tip applies to with your tip.
|
I want to write 7 assembly instructions (28 bytes) that runs a logical equivalent of this C snippet:
c = a + b + 6;
while (c > 5) {
c = c - a;
b = b + 1;
}
However, there are restrictions to the allowed instructions:
add, addi, sub, subi, slt, slti, bne
a, b, and c are located in registers $t0, $t1, and $s0 respe... |
Background
Actually (the successor to Seriously) is a stack-based imperative golfing language I created in November of 2015. Like many other golfing languages, it has one-byte commands that perform different functions based on the contents of the stack. One of its specialties is mathematics - it has a wide variety of m... |
Based on a recent question in StackOverflow
Write a program/function that takes in one ARRAY/list and returns the number of pair-values which sums up to a given TOTAL.
Explaining
TOTAL=4, ARRAY=[1,3,7,1,-3] => RESULT=2
The result was 2 because 1 + 3 and 7 + -3 are valid pairs which sums up to TOTAL=4.
When one pair i... |
Given the coordinates of the upper left corners of two squares and their side lengths, determine whether the squares overlap. A square includes the top and left lines, but not the bottom and right lines. That is, a point (a,b) is inside a square with side length k that starts at (x,y) if and only if x <= a < x+k and y ... |
Write a program or function that finds the number of zeroes at the end of n! in base 10, where n is an input number (in any desired format).
It can be assumed that n is a positive integer, meaning that n! is also an integer. There are no zeroes after a decimal point in n!. Also, it can be assumed that your programming ... |
Create a bootloader that executes given Brainfuck program. This is code-golf, so the program with least bytes wins. Being a bootloader, the size of the program is counted in non-zero bytes in the compiled code.
Brainfuck
30000 8-bit overflowing cells. Pointer wraps over.
Some notes about operations:
Input must be read... |
Koronkorko is the Finnish word for compound interest. We don't want compound interest in our strings, so let's find the shortest possible regular expression to exclude it.
Given a string consisting only of the uppercase alphabetic characters A-Z, determine the shortest possible regular expression that matches the strin... |
Introduction
Turns out, aliens love memes just as much as we do. Every alien race we've encountered so far has their own version of 2spooky4me (see the following question) and equivalent, though, with some variation. The inhabitants of planet CUTE1f can't handle a lot of spook, so their preferred spook is 1spooky2me, w... |
Columnar Transposition Cipher
While I have plenty of programs I have written for more advanced ciphers, I just realised I don't actually have one for one of the simplest: Columnar Transposition. The cipher, in case you don't know, works as follows:
First, you take the key, and write it as numbers. The numbers are made... |
Fix my Basic Orthography
While I am excellent at following the English capitalisation rules when writing, when I am typing I have a habit a capitalising almost everything (as you will see from the titles of my challenges). I need a program to fix that, but because I use so many capitals, and capitals are big letters, y... |
You can decompose a number greater than 0 as a unique sum of positive Fibonacci numbers. In this question we do this by repeatedly subtracting the largest possible positive Fibonacci number. E.g.:
1 = 1
2 = 2
3 = 3
4 = 3 + 1
12 = 8 + 3 + 1
13 = 13
100 = 89 + 8 + 3
Now, I call a Fibonacci product the same lists as abov... |
If elected president, Donald Trump plans to implement a system of four income tax brackets (full details can be found on his website here). Your job is to take two inputs, annual income and filing status (single, married, or head of household), and output the income tax that must be paid.
Income Tax Brackets
(We are o... |
Inspired by this site, this question could potentially be a doozie. People on StackOverflow often overuse jQuery as an answer. Therefore, we need a way to recognize programmatically if a code snippet uses jQuery.
Given a string (which may or may not contain new lines,) of valid Javascript, determine if jQuery is used.... |
Your job is to write a program that rewrites and makes itself longer on each run of the program.
Challenge
The program will print Hello, World!\n (\n denotes a newline). Then, it will modify its own file so that the new program length is exactly 2x the length at runtime. This modified file when run, will print Hello, W... |
Adam7 is an interlacing algorithm for raster images, such as PNG. It is called the "Adam7" algorithm because it was invented by Adam M. Costello, and it is generated by following a certain pattern 7 times. One of the cool things about the Adam7 algorithm that makes it really fun for code golf, is that the pattern can b... |
There's been challenges for the shortest cat program, but as far as I know, there hasn't been any for the longest one.
A cat program is a program that copies its input to its output. Here's an example:
Input: Hello
Output: Hello
Input: cat
Output: cat
So, the rules are simple:
The program has to copy its input to it... |
This challenge is inspired by a picture that often roams on Facebook that looks like this. Except our base square will look more like this:
┌─┬───┬─┐
├─┼─┬─┼─┤
├─┼─┴─┼─┤
├─┼─┬─┼─┤
└─┴─┴─┴─┘
The square is made out of n x m 1x1 square, you have to count how many sub-squares (1x1, 2x2, 3x3, 4x4, 5x5, etc.) can fit within... |
I'm trying to read 4 ints in C in a golfing challenge and I'm bothered by the length of the code that I need to solve it:
scanf("%d%d%d%d",&w,&x,&y,&z)
that's 29 chars, which is huge considering that my total code size is 101 chars. I can rid of the first int since I don't really need it, so I get this code:
scanf("%*... |
Does anybody have tips for golfing in Erlang? I'm looking for specific things that can be applied to Erlang, not any language. I know we already have tips for Elixir, but that is different.
As usual, please post separate tips in separate answers.
|
Introduction
Let's observe the following square, consisting only of the digits 0 - 9:
1034
4167
8414
3542
The outer shell of this square is:
1034
4 7
8 4
3542
It contains zeros, so we need to peel off the outer shell, leaving:
16
41
The outer shell of this square is:
16
41
It does not contain any zeros and is the... |
Give credit to whom credit is due.
Objective Given an integer N > 0, out the smallest integers A, B, and C so that:
All of A, B, and C are strictly greater than N;
2 divides A;
3 divides B;
and 4 divides C.
This is a code-golf, so the shortest answer in bytes wins.
Test cases
N => A, B, C
1 => 2, 3, 4
4 => 6, 6, 8
43... |
Given two non empty lists of integers, your submission should calculate and return the discrete convolution of the two. Interestingly, if you consider the list elements as coefficients of polynomials, the convolution of the two lists represents the coefficients of the product of the two polynomials.
Definition
Given th... |
A pangram is a sentence or excerpt which contains all twenty-six letters of the alphabet, as is demonstrated in this code golf challenge. However, a pangrammatic window is a pangram in the form of some segment of text, which may end or begin halfway through a word, found somewhere within a larger work. These naturally ... |
This is a quine variation.
Introduction
We all write short code, because some obscure reasons, but whatever we do, the'll take up at least 144 pixels/byte (with a 12px font). But what would happen, if we would encode our code in images? This is your task today.
Challenge
You task is to read in your own source code (non... |
I have a list, l and a function f. f is not strictly increasing or decreasing. How can I find the item in the list whose f(item) is the smallest? For example, let's say the list is:
l = [1, 2, 3, 4]
and list(f(x)for x in l) is:
[2, 9, 0, 3]
f(3) is smaller than f of any of the other ones, so it should print "3". What... |
This is my friend Thomas. He is half tree, half emoticon.
| |
| :D |
| |
He is lonely. Let's make him some friends!
Given a text-based emoticon as input (e.g. ಠ_ಠ, :P, >_>, not , , or ), output the corresponding treemote.
A treemote's length is how many characters it is lon (basically most builtin length functi... |
My local ACM chapter gives out door prizes to people who come to the meetings. You get an increased chance of winning if you solve the programming puzzle, however (but I always solve that puzzle). Thus, some people have 1 entry, while others have 2. But wait! The way the raffle program works is not by adding in another... |
Given three dice rolls (integer values from 1-6) in sorted order (so as to be indistinguishable), convert them to the sum of two fair dice with an identical distribution.
The answer for three to one is summing them all, modulo 6. The end-result is a perfectly flat distribution, where each of the six numbers are equall... |
In this challenge, your task is to create a program which takes in a nested array and returns a single-dimensional flattened array. For Example [10,20,[30,[40]],50] should output [10,20,30,40,50].
Input
The input will be a nested array (eg. [10,20,[[[10]]]]). It will contain only Integers (both negative and positive),... |
You teach a class of students with interesting preferences for how their chairs are arranged. There are 3 very specific requirements they have for how the chairs are arranged:
They most be arranged in a rectangle, even if it means some chairs go empty.
There must be as few empty chairs as possible.
They must be as "... |
Introduction
The arithmetic mean is defined as being equal to the sum of the numerical values of each and every observation divided by the total number of observations. Symbolically, if we have a data set containing the values a1,…,an. The arithmetic mean A is defined by the formula
Objective
The challenge here is, gi... |
TetraVex is a tile-based edge-matching game that was originally coded by Scott Ferguson for the Microsoft Entertainment Pack 3 back in 1990. The game consists of a grid upon which square tiles are placed. The tiles have numbers or letters on each edge, and the goal is to place all tiles in the grid, with each pair of e... |
Steiner Chains are a set of N circles where each circle is tangent to 2 other non-intersecting circles as well as the the previous and next circles of the chain, as seen in the below images:
In this challenge, you will write a program/function that draws Steiner chains recursively, that is, circles of a given chain ... |
Write some code that acts as a cat program. That is, to input a string and output it as is. But the normal reversion of your code must output the normal reversion of the input string. And the visual reversion of your code must output the visual reversion of the input string.
The normal reversion is the reversed charact... |
Based on my SO question, but more specifically:
Find a RegEx such that, given a text where paragraphs end with an empty line (or $ at the very end), match the up to twenty last characters of a paragraph excluding the \r or $ but no more than three complete "words" including the "separators" in between and the punctuati... |
A laser shoots a straight beam in one of the four orthogonal directions, indicated by <>^v. Determine whether it will hit the target O on a rectangular grid.
Each of these will hit (True):
.....
...O.
.....
...^.
.....
>O.
...
v....
O....
...........
...........
O.........<
...........
These will miss (False):
...... |
Let's play code golf... by playing golf.
Input
Your input will be a string consisting of #'s, an o, an @, and .'s. For example:
......@..
.....##..
.........
......o..
. - playable golf course (all shots must end on one of these)
# - a barrier (shots cannot go through this)
o - the starting position of your golf ball
... |
Challenge
Joe the rapper is struggling with rhyming words in his lyrics. He needs your help.
For this situation, we will use rhymes where the last syllable in a word is the same as the other word (spelled the same).
When Joe inputs a word, the program will read a list of words from a file and output those that rhyme wi... |
The challenge is to assign people to tasks randomly~.
From stdin you get 2 lines. Line one is a comma-separated list of names. Line 2 is a comma-separated list of jobs.
The output required is one line per task person combo.
The line should be formatted as Name:task.
If there are not enough people for jobs or vice verse... |
Your task is to write a RegEx that matches everything inside strings.
A string is defined as everything surrounded by (but not including) two unescaped ".
A " can be escaped by \, which can also be escaped again.
Testcases
string: ab\c"defg\\\"hi"jkl"mn\\\\"opqrst""
matches: ^^^^^^^^^^ ^^^^^^ ^ (the em... |
The challenge involve simply toggling a string within another string.
Explanation
If the toggle string is a substring of the main string, remove all instances of the toggle string from the main string; otherwise, append the toggle string at the end of the main string.
Rules
All string are composed of printable ASCII... |
Find the shortest function/algorithm to translate these numbers to the ones after the dash:
0 - 0
1 - 10
2 - 20
3 - 30
4 - 40
5 - 50
6 - 60
7 - 70
8 - 80
9 - 90
10 - 100
11 - 115
12 - 130
13 - 150
14 - 175
15 - 200
16 - 230
17 - 260
18 - 300
19 - 350
20 - 400
Every integer higher than 20 is calculated by subtracting 1... |
History
My company sends out a weekly newsletter to everyone within the company. Included in these newsletters is a riddle, along with a shoutout to whomever in the company was the first to email/provide a solution to last week's riddle. Most of these riddles are quite trivial, and honestly pretty dull for a tech compa... |
The title is pretty self-explanatory, isn't it?
Your task is to output the alphabet (the string "abcdefghijklmnopqrstuvwxyz") to STDOUT, using each and every letter of the alphabet in your program once and only once.
Oh, and for a bit of extra fun?
The letters "g", "o", "l" and "f" must be in order (just for the code t... |
In chemistry class, we were learning about titrations, and attempting one as a lab. We were using phenolphthalein as the indicator for the titration, so on top of grading the lab normally, my teacher held a little contest to see who had the lightest shade of pink, and thus the most accurate transition.
Your task is to ... |
Credit goes where credit is due
Given two digits, x, and y, calculate the shortest number of horizontal or vertical jumps to get from x to y on a standard numpad, e.g.
789
456
123
00
You can safely assume that all inputs will be 0-9, and you do not have to handle invalid inputs. The input may be the same number twice... |
Given two words and a list as input, your program must (in as few characters as possible, of course) find the shortest way to "chain" the first word to the last using the ones in the list. Two words are "chained" if their first and last letters are the same, e.g. "Food" and "Door".
Your program will take input as a str... |
In this challenge, your task is to write a program that takes in an image and returns the most dominant color in it. Dominant color here means the color with which most of the image is covered (see the test cases for a better understanding).
Input
An image's path. You'll have to load that image in your program. You ca... |
This question will be a twist on finding the nth prime number.
Challenge
You must write a program that will take one input n, and output the nth prime number whose decimal representation contains the decimal representation of n as a subtring.
Confused? Here are some examples.
n=1
Primes: 2, 3, 5, 7, 11
... |
Create a program that outputs "Hi, Hello!" in k bytes. By altering n bytes, the code should output all odd numbers in the range 5 <= x <= 25.
Changing another m bytes should result in a code that prints the following frame in ASCII-art:
+-+
| |
+-+
Change another o bytes, and print Hello, bye!.
m, n and o are calculat... |
In Keep Talking and Nobody Explodes, players are tasked with defusing bombs based on information from their "experts" (other people with a manual). Each bomb is made up of modules, one of which can be passwords, where the expert is given this list of possible passwords, all five letters long:
about after again b... |
A divisor of a number n is any number that evenly divides n, including 1 and n itself. The number of divisors d(n) is how many divisors a number has. Here's d(n) for the first couple n:
n divisors d(n)
1 1 1
2 1, 2 2
3 1, 3 2
4 1, 2, 4 3
5 1, 5 2
6 1, 2, 3, 6 ... |
related and inspired by -- Finding sum-free partitions
A set A is defined here as being distinctly sum-free if
1) it consists of at least three elements, |A| ≥ 3, and
2) its distinct self-sum A + A = { x + y | x, y in A} (with x,y distinct, i.e., x≠y) has no elements in common with A.
(Obsolete - do not use this goi... |
Introduction
I stumbled across this (useless) pattern the other day while I was watching TV.
I named it "the 9 pattern" because the first number to use it was 9.
The gist of it is, you enter a number (let's say x), and then you get back:
x
x + (x / 3) [let's call this y]
two-thirds of y [let's call this z]
z + 1 ... |
As a kid, I used to play the card game "golf" a lot. Your challenge, should you choose to accept it, is to calculate the score of a golf hand. Since there are over 9000 variations on this card game1, we will go with the rules I remember playing.
Rules (of the game)
You end a round with 6 cards, and you want as few poi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.