instruction stringlengths 34 53.1k |
|---|
As a big fan of the Lost TV series, I always got intrigued by the sequence of numbers that repetitively appears on the episodes. These numbers are:
\$ 4, 8, 15, 16, 23, 42\$ (A104101)
Using any programming language, write a code that outputs these numbers.
Scoring:
Shortest answer wins
The output must not contain any ... |
Imagine we get a slice of some mountainous region, this would result in a shape similar to this:
4 _
3 _ _ __/ \
2 / \__/ \ _/ \_ /
1 / \ / \_/
0 \/
12322223210012233343221112
As we can see, we can represent this (to a certain degree) with a sequence o... |
Given a positive integer \$N >= 4\$, output an RSA key pair (both the private and the public key) whose key length is \$N\$ bits.
The RSA key generation algorithm is as follows:
Choose an \$N\$-bit semiprime \$n\$. Let the prime factors of \$n\$ be \$p\$ and \$q\$.
Compute \$\lambda(n) = LCM(p-1, q-1)\$.
Choose an int... |
For functions \$f, g: \{0,1\}^n \rightarrow \{0,1\} \$, we say \$f \sim g\$ if there's a permutation of \$1,2,3,...,n\$ called \$i_1,i_2,i_3,...,i_n\$ so that \$f(x_1,x_2,x_3,...,x_n) = g(x_{i_1},x_{i_2},x_{i_3},...,x_{i_n})\$. Therefore, all such functions are divided in several sets such that, for any two functions \... |
The robber's thread is here
The cops task is to write a function or program that, when given an input of itself, outputs a finite deterministic string. If the program is given a different input, it should return a different output.
Rules:
Submissions consist of
Language name
If any flags are used, they should be r... |
The cop's thread is here
The robber's task is to find a program of size equal to or less than the cop's program, which, when given an itself as input, produces the same output as the cop's program.
Additionally, even if a cop's answer is provisionally marked Safe and has been revealed, you can still crack it by finding... |
A simplistic version of English numeral calculator
Task
Write a program that takes a string as input and outputs the result of the expression.
Rules
The input string will be worded and not numeral.
There will be no parentheses.
Order of calculation will be divide,multiply,subtract then add.
For same operations, the cal... |
Challenge Taken from here and also here
An n parentheses sequence consists of n (s and n )s.
A valid parentheses sequence is defined as the following:
You can find a way to repeat erasing adjacent pair of parentheses "()" until it becomes empty.
For example, (()) is a valid parentheses, you can erase the pair on the 2... |
This challenge is about finding the smallest disk that contains some given points. This is made somewhat trickier, however, by the fact that in this challenge, the disk's coordinates and radius must both be integers.
Your input will be a list of points with integer coordinates x and y. You can take this as a list of tu... |
Given an input integer n > 1, output an ASCII-art octagon with side lengths composed of n characters. See examples below:
n=2
##
# #
# #
##
n=3
###
# #
# #
# #
# #
# #
###
n=4
####
# #
# #
# #
# #
# #
# #
# #
# #
####
n=5
#####
... |
The 5-card magic trick involves a magician whose assistant gives them 4 shown cards and a hidden one, in this order, and the magician must guess the hidden one.
WARNING: Solution below! Leave now or get spoiled with it.
The solution
The trick here is that the five cards are given in a specific order!
\$c_1,...,c_5\$ a... |
This is a follow up to Count arrays that make unique sets . The significant difference is the definition of uniqueness.
Consider an array A of length n. The array contains only positive integers. For example A = (1,1,2,2). Let us define f(A) as the set of sums of all the non-empty contiguous subarrays of A. In this c... |
https://www.youtube.com/watch?v=6vAhPeqlODg
Ok—jig's up—this one's only related to smash in name, but it'll give you something to burn your time with while you wait 'til December 7th
Given a color string s of form #rgb(in hex, so #000000 to #ffffff, dont worry about the three digit ones: #123) you must average the rgb ... |
Given two integers, output the two integers, and then the range between them (excluding both).
The order of the range must be the same as the input.
Examples:
Input Output
0, 5 -> [0, 5, 1, 2, 3, 4]
-3, 8 -> [-3, 8, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
4, 4 -> [4, 4]
4, 5 -> [4, 5]
8, 2 ->... |
Sandbox
The major scale (or Ionian scale) is one of the most commonly used musical scales, especially in Western music. It is one of the diatonic scales. Like many musical scales, it is made up of seven notes: the eighth duplicates the first at double its frequency so that it is called a higher octave of the same note.... |
Consider an array A of length n. The array contains only integers in the range 1 to s. For example take s = 6, n = 5 and A = (2, 5, 6, 3, 1). Let us define g(A) as the collection of sums of all the non-empty contiguous subarrays of A. In this case g(A) = [2,5,6,3,1,7,11,9,4,13,14,10,16,15,17]. The steps to produce g(A... |
This is similar to this question.
However, I have a different goal in mind:
Reduce the wordlist to words that could appear.
The easy part is to delete hyphens and similar.
The hard part, however: Remove words containing more than seven letters.
So, the problem:
Given a set of words containing only lowercase (or upperca... |
For more MtG-goodness: Magic: The Gathering Combat with Abilities
Premise:
In Magic: the Gathering, you cast spells by paying their mana cost by tapping lands for the required amount. These lands can produce one of the five colors which are:
White (W)
Blue (U)
Black (B)
Red (R)
Green (G)
The cost is made up of two... |
Scratch is a visual programming language. For the sake of counting bytes, Scratch is usually written in scratchblocks2 syntax.
Post tips that specifically apply to Scratch or scratchblocks2.
|
Dart is an object oriented programming language borrowing from both Java and Javascript. What general tips do you have for golfing in Dart? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Dart (e.g. "remove comments" is not an answer). Please post one ti... |
Introduction:
In general we usually speak of four dimensions: three space dimensions for x, y, and z; and one time dimension. For the sake of this challenge however, we'll split the time dimension into three as well: past, present, and future.
Input:
Two input-lists. One containing integer x,y,z coordinates, and one co... |
The below pattern will form the basis of this challenge.
/\
\/
/\
/ \
/ \
/\/ \/\
\/\ /\/
\ /
\ /
\/
/\
\/
Given an input width and height, each >=1, output the above ASCII art pattern repeated that many times, joining (and overlapping) at the small diamond... |
Dina loves most numbers. In fact, she loves every number that is not a multiple of n (she really hates the number n). For her friends’ birthdays this year, Dina has decided to draw each of them a sequence of n−1 flowers. Each of the flowers will contain between 1 and n−1 flower petals (inclusive). Because of her hatred... |
Use any programming language to display numbers between 1 and 99 (including both) in such a way, so that:
the numbers are separated by single space,
if a number is divisible by 3, it should be in parentheses,
if a number is divisible by 4, it should be in square brackets,
if a number is divisible by both 3 and 4, it s... |
Note: This is an attempt at recycling guest271314's permutation question(s)
There's an interesting pattern that forms when you find the differences between lexographically sorted permutations of base 10 numbers with ascending unique digits. For example, 123 has permutations:
123 132 213 231 312 321
When you find the d... |
For the purposes of the current challenge to "outline" a word means to surround it successively with its own letters, starting with the last one, and finally to replace the original word in the center with spaces:
oooooo
onnnno
on -> on no
onnnno
oooooo
Task:
Given a list of words, con... |
Challenge
Take an input string \$s\$, and split it into words \$w_1, w_2, ..., w_n\$. If the amount of words is odd, then return \$s\$. Otherwise, for each word: Take the second last letter, and swap it with the first letter keeping capitalization positions. So GolF becomes LogF.
Now check if the amount of words is a m... |
Given a positive integer, write it as the sum of numbers, where each of them is in \$\{kt|k\in{1,9,81},t\in{1,2,3,...,64}\}\$. How many numbers at least are used? Shortest code win.
Samples:
Input Output Method
1 1 1
2 1 2
64 1 64
65 2 64+1
72 1 72
343 2 342+1
576... |
Matlab has a useful command for visualizing data: plot. It draws data points using "markers" in 2-D space, connecting them with lines; however, for this challenge, let's ignore the lines and use only markers. In fact, only one marker.
Input: one of Matlab's marker symbols: . o x + * s d v ^ < > p h
Output: correspondin... |
Given a non-empty rectangular array of integers from 0 to 9, output the amount of cells that are 8 and do not have a neighbour that is 8. Neighbouring is here understood in the Moore sense, that is, including diagonals. So each cell has 8 neighbours, except for cells at the edges of the array.
For example, given the in... |
Introduction
In Android Studio and other IDEs there are code completions to assist efficient code insertion (especially when the names of the classes or methods are so verbose), like the one in the image below.
There are slightly different logics used between IDEs to determine what classes, methods and variables to su... |
I have just tried a game called Couch 2048.
(Note: You should have a look to better understand this question.)
Since it wasn't very exciting for me, I've been asking myself 'How much more till 2048!?'
That inspired me to post a challenge, because calculating this in not as easy as I thought.
Your goal:
Given a list of ... |
CHALLENGE STATUS: OPEN
Comment, open a PR, or otherwise yell at me if I'm missing your bot.
Prisoner's dilemma ... with three choices. Crazy, huh?
Here's our payoff matrix. Player A on the left, B on the top
A,B| C | N | D
---|---|---|---
C |3,3|4,1|0,5
N |1,4|2,2|3,2
D |5,0|2,3|1,1
The payoff matrix is engineered... |
Let \$A\$ be a positive integer consisting of \$n\$ decimal digits \$d_1,d_2,...,d_n\$. Let \$B\$ be another positive integer.
For the purpose of this challenge, we call \$A\$ a copycat of \$B\$ if there exists at least one list of positive integers \$p_1,p_2,...,p_n\$ such that:
$$\sum_{i=1}^{n}{{d_i}^{p_i}}=B$$
\$A\$... |
Task
Given is a square matrix of any dimension and any integer n.
Output all possible matrices(without duplicates) by removing columns and rows from the input matrix such that the determinant of these new matrices is n.
Rules
Output should include original if determinant of original is n.
Output should be all the chopp... |
Introduction
The EKG sequence begins with 1 and 2, then the rule is that the next term is the smallest positive integer not already in the sequence and whose common factor with the last term is greater than 1 (they are not coprimes).
The first terms are:
1, 2, 4, 6, 3, 9, 12, 8, 10, 5, 15, ...
It's called EKG because... |
Unfortunately one of the greatest comic book writers passed away yesterday afternoon. Lots of Hollywood stars, musicians, actors, and many other people are paying tribute to this awesome writer, so we must do something as well.
Challenge
Print The Avengers Logo
Note: You may use any other character in place of # othe... |
Do you know Icy Tower ? Here is a gameplay example of what i'm talking about
The game concept is simple : you play as Harold the Homeboy, and your goal is to jump from floors to floors to go as high as possible without falling and getting off-screen ( the camera goes higher following you or at a speed that gets faster ... |
FreeChat Online
It is 1985, and you are a humble Russian potato farmer. Sadly, your glorious homeland is going through a time of crisis and it needs your help! The KGB, with the "assistance" of your wife and children, has convinced you to build their up-and-coming government FreeChat Online service for high ranking sov... |
This is similar to the alignment used in word.
Task
3 inputs: A 1 line string, a positive integer k, and direction (left or middle or right)
Your job is to insert new lines(\n) and spaces in the string such that every line has k characters in it and aligned to the direction given.
Rules
The words must not be split(unle... |
May this challenge serve as (another) tribute to Stan Lee, who passed away aged 95.
Stan Lee has left us an invaluable legacy and a peculiar catch word: Excelsior. So here's a small challenge based on what he said it was its meaning:
Finally, what does “Excelsior” mean? “Upward and onward to greater glory!” That’s wh... |
Shorter version of Skyscrapers Challenge
Task
Given an array of building heights and a positive integer k, find all the permutations(without duplicates) of the heights such that exactly k buildings are visible.
Any building will hide all shorter or equal height buildings behind it.
Any format for input and output is va... |
Challenge:
Given a list of integer, sort descending by their single largest digit(s). The order for numbers with the same largest digit are then sorted by second largest digit, etc.
We ignore duplicated digits in numbers. And if all digits in a number are the same, the order of those numbers in the list can be in any w... |
Task
Given an array of non-negative numbers, output the largest and smallest possible number that can be formed by joining them.
Rules
Input,Output can be in any convenient format.
The array may have at most 1 decimal number.
Examples
input:[22,33,44,55.55,33]
output:4433332255.55,55.5522333344
input:[34,900,3,11,9]
o... |
Challenge
Calculate the strange sum of two natural numbers (also known as lunar addition):
Given \$A=...a_2 a_1 a_0\$ and \$B=... b_2 b_1 b_0\$ two natural numbers written in the decimal base, the strange sum is defined, based on the maximum operation, as:
\$A+B=... \max(a_2,b_2) \max(a_1,b_1) \max(a_0,b_0)\$
... ... |
This challenge is for the largest finite number you can get BrainFuck programs of given lengths to contain in memory.
We must use one of the BF versions that uses big integers for the cells rather than byte values as not to be capped at 255. Do not use negative positions and values in memory. Do not use the BF instruct... |
Introduction
Busy Beavers are programs (specifically Turing Machine programs) that aim to output the most ones as possible, while having the least states as possible and halting.
Challenge
Your challenge is to make a busy beaver, which outputs as many ones as possible, but also outputs a second busy beaver. That secon... |
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
Output how many letters would be used if all the numbers from 1 to 1000 (one thousand) inclusive were written out in words.
NOTE: Do not count spaces or hyphens. For example, 342 (th... |
Background
Quaternion is a number system that extends complex numbers. A quaternion has the following form
$$ a + bi + cj + dk $$
where \$ a,b,c,d \$ are real numbers and \$ i,j,k \$ are three fundamental quaternion units. The units have the following properties:
$$ i^2 = j^2 = k^2 = -1 $$
$$ ij = k, jk = i, ki = j $$
... |
Pyth is perhaps the most successful general-purpose golfing language. Though it is somewhat in decline as a result of newer languages, from 2014 to 2016 Pyth's concise syntax, constant updates, overloading, and (for its era) many builtins made it a favorite for the majority of questions.
Pyth code is often difficult to... |
A lexicographically increasing number is an integer whose digits are in strictly increasing order. Print all lexicographically increasing numbers under 10000.
Here are lines of the expected output:
0
1
2
3
4
5
6
7
8
9
12
13
14
15
16
17
18
19
23
24
25
26
27
28
29
34
35
36
37
38
39
45
46
47
48
49
56
57
58
59
67
68
69
78... |
The Dirichlet convolution is a special kind of convolution that appears as a very useful tool in number theory. It operates on the set of arithmetic functions.
Challenge
Given two arithmetic functions \$f,g\$ (i.e. functions \$f,g: \mathbb N \to \mathbb R\$) compute the Dirichlet convolution \$(f * g): \mathbb N \to \m... |
In mathematics, a cyclic quadrilateral is one whose vertices all lie on the same circle. In other words, every vertex is on the circumcircle of the other three. For more information, see the MathWorld article.
Examples
These quadrilaterals are cyclic:
This trapezoid is not cyclic.
(Images from Wikipedia)
Objective
Gi... |
As with most APL symbols, ⍉ has different meanings when called with one argument (transpose) versus two arguments (dyadic transpose / reorder dimensions). This challenge concerns the latter, which acts similarly to numpy.moveaxis in Python or permute in MATLAB, but is more powerful.
order ⍉ A when order has distinct en... |
Introduction
In geometry, the Peano curve is the first example of a space-filling curve to be discovered, by Giuseppe Peano in 1890. Peano's curve is a surjective, continuous function from the unit interval onto the unit square, however it is not injective. Peano was motivated by an earlier result of Georg Cantor that ... |
Given a sequence of integers or to be more specific a permutation of 0..N
transform this sequence as following:
output[x] = reverse(input[input[x]])
repeat
For example: [2,1,0] becomes [0,1,2] and reversed is [2,1,0]. [0,2,1] becomes [0,1,2] and reversed [2,1,0].
Example 1
In: 0 1 2
S#1: 2 1 0
S#2: 2 1 0
Output:... |
Task
Suppose that p pepole have to split a bill; each of them is identified by a triple (Name, n, k) made up of:
Name: the name;
n: the amount she/he has to pay;
k: the amount she/he actually paid.
The challenge here is to find out how much who owes whom.
Assumptions
Input and output can be in any convenient format.... |
A hill number is a number that has the same digit in the first & the last, but that's not all. In a hill number the first digits are strictly increasing until the largest digit, and after the largest digit, the last digits are strictly decreasing. The largest digit can be repeated but consecutively only, meaning no gap... |
You have been given the charge to calculate the current balance as of the day that you perform the calculation for 330,000 individuals who worked for an average of 30 years spanning 300 years where the initial principal was 1 with an addition of 1 per day and interest rate set at 3%.
You initially tried to use online ... |
Sixteen piles of cheese are put on a 4x4 square. They're labeled from \$1\$ to \$16\$. The smallest pile is \$1\$ and the biggest one is \$16\$.
The Hungry Mouse is so hungry that it always goes straight to the biggest pile (i.e. \$16\$) and eats it right away.
After that, it goes to the biggest neighboring pile and qu... |
An arithmetico-geometric sequence is the elementwise product of an arithmetic sequence and a geometric sequence. For example, 1 -4 12 -32 is the product of the arithmetic sequence 1 2 3 4 and the geometric sequence 1 -2 4 -8. The nth term of an integer arithmetico-geometric sequence can be expressed as
$$a_n = r^n \cdo... |
Randomness is fun. Challenges with no point are fun.
Write a function that, given integer input n, will output a set (unordered, unique) of exactly n random integers between 1 and n^2 (inclusive) such that the sum of all integers is equal to n^2.
Randomness does not have to be uniform, provided each valid set has a non... |
Given an array A of integers, there exists at least one positive integer p such that A[i] == A[j] for all i and j for which i % p == j % p == 0. Find the smallest p.
Examples:
Input array: [1, _, 1, _, 1, _, 1, _, 1]. Output: 2
Input array: [1, _, _, 1, _, _, 1, _, _]. Output: 3.
Input array: [1, _, _, _, 1, _, _, _, ... |
Given integer n, calculate a set of n random unique integers in range 1..n^2 (inclusive) such that the sum of the set is equal to n^2
Random, in this case, means uniformly random between valid outputs. Each valid output for a given n must have a uniform chance of being generated.
For example, n=3 should have a 1/3 chan... |
Premise:
For those in networking, you've most likely sent a ping to or from some device to make sure everything's properly connected. Cisco, a popular company in networking[citation needed], has a command for it in their IOS that looks like this:
(Image source)
Your challenge is to graphically recreate a portion of t... |
This is a restricted-source, kolmogorov-complexity, code-golf challenge to produce a fixed output with no input.
The output format, however, is flexible - it may be printed to standard out, printed to standard error, returned as a list of characters, returned as a list of bytes, or returned as a list of integers. If yo... |
Task
Write a function or a program to find the number of rotations required by a wheel to travel a given distance, given its radius.
Rules
Input can be 2 positive rational numbers and can be taken in any convenient format.
Both inputs are of same unit.
There must not be any digits 0-9 in your code.
The output will be a... |
Here are the annual returns for a hypothetical S&P 500 stock index fund for each calendar year from 1928 to 2017, expressed as a multiplier. So in 1928 you might say "the index went up by 37.88%" which I've represented here by 1.3788.
1.3788, 0.8809, 0.7152, 0.5293, 0.8485, 1.4659, 0.9406, 1.4137, 1.2792, 0.6141, 1.25... |
For nandgame fans: Please try out DPD to decimal in logic gates too!
Background
Densely packed decimal (DPD) is a way to efficiently store decimal digits in binary. It stores three decimal digits (000 to 999) in 10 bits, which is much more efficient than naive BCD (which stores one digit in 4 bits).
Notations
The lo... |
Write a program to generate a rectangular word-search of size 6x9. Words may go downwards, rightwards and diagonally (downwards and to the right), they may also overlap on the board.
The challenge is to include as many different English words as possible from https://www.ef.co.uk/english-resources/english-vocabulary/to... |
Don't you hate it when you're trying to roughly sort a list based on user data, but you have to poll the user for thousands of comparisons?
Hate no more, because the answers to this challenge are (going to be) here!
Method
The sorted-ness of a list is defined by how many possible comparisons it has which are correct.
L... |
The task
Given the set
$$S = \left[{1,2,3,4,5,6,7,8}\right]$$
and an integer
$$0 \leq N < 2^{|S|}$$
find the Nth subset.
Input/Output
N is given as an unsigned integer on stdin. You must print the Nth subset in a format suitable for your language (this may include [1,2,3],{1,2,3},[1, 2, 3],1 2 3,1,2,3 etc. for as long... |
Create quine variant such that the program prints its first character, then the first two, then three and so on until the whole program is printed.
Example
Suppose your code is @@@@@2 in some language. Then the output should be
@
@@
@@@
@@@@
@@@@@
@@@@@2
in that order, each line separated by a newline.
The winner is t... |
Peg solitaire is a popular game usually played alone. The game consists of some number of pegs and a board which is divided into a grid - usually the board is not rectangular but for this challenge we will assume so.
Each valid move allows one to remove a single peg and the goal is to play in a way, such that there is ... |
My parents have an home theater device. The remote is broken making it incredibly difficult to navigate rightwards in a menu. Most the time it doesn't work but when it does it moves rightwards incredibly quickly.
This is obviously frustrating but it is most frustrating when you want to enter a movie title which requi... |
Make a quine. Simple enough, except it has to be a palindrome and accept input.
Now, any side of a palindromic quine is one half of it. For example, one side of the hypothetical quine AAAA is AA. One side of AAAAA is AA (the center symbol is ignored).
Your job is to make a quine like this that accepts input. If the inp... |
An H tree is a fractal tree structure that starts with a line. In each iteration, T branches are added to all endpoints. In this challenge, you have to create an ASCII representation of every second H tree level.
The first level simply contains three hyphen-minus characters:
---
The next levels are constructed recursi... |
How to
Given an integer n start with n ones (i.e. 4 -> 1 1 1 1). Then sum up the
last n numbers, and repeat.
For n = 4 this looks like this:
Start with 1 1 1 1, sum up the last 4 numbers resulting in 1 1 1 1 4, then
sum up the last 4 numbers resulting in 1 1 1 1 4 7, then sum up the last 4 numbers resulting in 1 1 1 ... |
Inspired by recent popularity of nandgame on TNB, and my own previous challenge.
Background
Densely packed decimal (DPD) is a way to efficiently store decimal digits in binary. It stores three decimal digits (000 to 999) in 10 bits, which is much more efficient than naive BCD (which stores one digit in 4 bits).
Convers... |
Let A be an m by n rectangular matrix of positive integers, where m and n are also positive integers.
We are interested in RoD ('Right-or-Down') paths from the upper-left cell of A to the lower right cell; in an RoD path, each successive cell of the path is either one cell to the Right of or one cell Down from the prev... |
Given two different positions on a chess board and the type of piece, output the minimum number of moves it will take for that piece to go from one position to another.
Rules
The given piece can be King,Queen,Rook,Knight and Bishop. (This input can be taken as any 5 unique characters)
The 2 positions can be taken in an... |
Summary
A teacher was told to prepare word problems for the students. She is given a list of equations and told to write them as the corresponding word problem. However, she is very lazy, so she doesn't put much creativity into it. Instead, she simply writes it literally. For example, when she reads 1+1, she writes one... |
Goal
The goal of this challenge is to produce a function of n which computes the number of ways to partition the n X 1 grid into triangles where all of the vertices of the triangles are on grid points.
Example
For example, there are 14 ways to partition the 2 x 1 grid, so f(2) = 14 via the following partitions
where t... |
Given a non-negative integer Excel-style date code, return the corresponding "date" in any reasonable form that clearly shows year, month, and "day".
Trivial, you may think. Did you notice the "scare quotes"? I used those because Excel has some quirks. Excel counts days with number 1 for January 1st, 1900, but as if 19... |
So this is my first challenge on this site.
The challenge is to take in an input integer \$n\$, which will be positive, and print, in ascending order (\$1\$ to \$n\$, including n), the output of \$i^{(n-i)}\$ (where \$i\$ is the current integer).
Example
Given the input 5, the program will print:
1
8
9
4
1
... |
Consider a sequence of natural numbers for which N appears as a substring in N^2. A018834
Output the nth element of this sequence.
Rules
Program takes only n as input and outputs just one number - N.
The sequence can be 0-indexed or 1-indexed.
Sequence: 1 5 6 10 25 50 60 76 100 250 376 500 600 625 760 ...
Squares: 1 2... |
Given integer n, output the smallest exponent e greater than 1 such that n^e contains n as a substring.
For example, for 25, the answer should be 2, as 25 ^ 2 = 625, which contains 25 as a substring, but the answer for 13 should be 10, as 13 ^ 10 = 137858491849, so 10 is the lowest exponent for which the result contain... |
Challenge
Mark is a student who receives his N marks in a concatenated way in a one single line.
The challenge is to separate his marks, knowing that each mark can only be 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 10.
Input
N natural number and one line.
Output
A set of natural numbers.
Example
N, One line-----... |
Print this text:
_________
| |
| |
| |
|_________|
Shortest code wins. Notice the space at the start of the first line.
|
This is sequence A054261.
The \$n\$th prime containment number is the lowest number which contains the first \$n\$ prime numbers as substrings. For example, the number \$235\$ is the lowest number which contains the first 3 primes as substrings, making it the 3rd prime containment number.
It is trivial to figure out t... |
This is sequence A054261
The \$n\$th prime containment number is the lowest number which contains the first \$n\$ prime numbers as substrings. For example, the number \$235\$ is the lowest number which contains the first 3 primes as substrings, making it the 3rd prime containment number.
It is trivial to figure out th... |
In @Adám's Dyalog APL Extended, the ⍢ (under) operator means conjugation: apply one function, then a second function, then the inverse of the first. It's fun to think of real-life actions in terms of conjugation:
A problem is transformed by g into another domain where it more
readily solved by f , and then transfor... |
(Note: This is my first ever code golf question, but as far as I can tell, nobody else has done exactly this, so I should be good.)
Your task is to make a program or function that takes in a string s and an integer n, and returns or outputs that text wrapped into multiple lines. Each word must be wholly on a line; i.e.... |
You are a Computer Science professor teaching the C programming language. One principle you seek to impart to the students is modularity. Unfortunately, past classes have tended not to get the message, submitting assignments with the entire program inside main(). Therefore, for this semester you have issued strict modu... |
Introduction:
I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post al... |
Given an input n, write a program or function that outputs/returns the sum of the digital sums of n for all the bases 1 to n.
$$n + \sum_{b=2}^n \sum_{i=0}^\infty \left\lfloor \frac{n}{b^i} \right\rfloor \bmod b$$
Example:
n = 5
Create the range [1...n]: [1,2,3,4,5]
For each element x, get an array of the base-x digi... |
As a follow up to Shortest terminating program whose output size exceeds Graham's number and Golf a number bigger than TREE(3), I present a new challenge.
Loader's number is a very large number, that is kind of hard to explain (since it was itself the result of a code golfing exercise with a flexible goal). There is a ... |
Write a program that prints the RGB color of a given pixel on the screen.
The program should read a line from stdin in the format x,y, where x and y are unsigned integers. The pixel (0,0) is the top left pixel in the screen.
The program should then output a line to stdout in the format RRR,GGG,BBB, which represents the... |
You'll be given the name of one of the 20 biggest objects in the Solar System. Your task is to return an approximation of its radius, expressed in kilometers.
This is a code-challenge where your score consists of the length of your code (in bytes) multiplied by a penalty ratio \$\ge 1\$, based on your worst approximati... |
Write a program that, given a string of capital letters, output all possible phrases that could have been written originally, using any variant of the Oxford English Dictionary.
Input
There are two inputs:
A string \$s\$ of A-Z capital letters that is a phrase with certain letters removed. Example: THSSANEAMPLE
Anoth... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.