instruction stringlengths 34 53.1k |
|---|
Inspired by a polyglot on the Stack Overflow 404 page:
Goal
Your goal is simple, to create a polyglot that outputs the number 404, and then terminate, in as many languages as possible.
Restrictions
Here's the twist, there's a restriction to make it harder:
You have to write N programs and pick N languages in a particu... |
Background
Many people visit webpages, which require special browsers because of lack of compatibility. So you have to write a script (client sided or server sided), which just prints the name of the browser. Because not everyone has fast internet, the script has to be as short as possible. (This is a joke xD)
Rules
Y... |
Recently I had the pleasure of writing a Haskell program that could detect if the NegativeLiterals extension was engaged. I came up with the following:
data B=B{u::Integer}
instance Num B where{fromInteger=B;negate _=B 1}
main=print$1==u(-1)
Try it online!
This will print True normally and False otherwise.
Now I had ... |
Inspired by this Math.SE question.
Background
The Fibonacci Sequence (called F) is the sequence, starting 0, 1 such that each number (F(n)) (after the first two) is the sum of the two before it (F(n) = F(n-1) + F(n-2)).
A Fibonacci Sequence mod K (called M) is the sequence of the Fibonacci numbers mod K (M(n) = F(n) % ... |
The sequence contains the decimal representation of the binary numbers of the form: 10101..., where the n-th term has n bits.
The sequence is probably easiest to explain by just showing the relationships between the binary and decimal representations of the numbers:
0 -> 0
1 -> 1
10 -> 2
101 -> ... |
Challenge:
Given an index integer n, either output the n'th item in this sequence, or output the sequence up to and including index n:
25,25,7,28,29,20,21,22,23,14,35,26,7,28,29,20,16,29,12,15,28,21,14,17,30,13,16,29,12,15,28,21,10,6,12,18,15,11,7,13,19,17,13,9,15,21,18,14,10,16,22,19,15,11,17,23,20,16,12,18,24,21,17,1... |
Given two different lists of non-negative integers, return the list that has the highest maximum (e.g. [4, 2], [3, 3, 1] -> [4, 2]).
If they both have the same maximum, return the list that contains more instances of this maximum (e.g. [4, 2, 4], [4, 3, 3, 3, 1, 3] -> [4, 2, 4]).
If, after these comparisons, they are e... |
Inspired by the fourth problem from BMO2 2009.
Given a positive integer n as input or a parameter, return the number of positive integers whose binary representations occur as blocks in the binary expansion of n.
For example, 13 -> 6 because 13 in binary is 1101 and it has substrings 1101, 110, 101, 11, 10, 1. We do no... |
Given a list of hole yardages, green sizes, a slice angle and a max distance, compute a golf score.
Assumptions
Earth is flat
All greens are circular
Slice angle will be between -45 and 45 degrees and will be given in degrees
All distances in the same metric (yards or meters, doesn't matter)
No out of bounds, obstruct... |
This question asking us to make a "Cyclic Levenquine" has gone unanswered. So today we will ask a slightly simpler version. In this challenge we will define a K-Levenquine to be a program whose output is Levenshtein distance K from its source.
Task
Your goal in this challenge is to write a program with some output dif... |
Your challenge is to translate a Cubically cube-dump to the format specified in this challenge.
Input
The input will represent a Rubik's Cube, formatted how Cubically prints its memory cube at the end of every program.
This is a solved cube:
000
000
000
111222333444
111222333444
111222333444
555
555
5... |
Sometimes to fall asleep, I'll count as high as I can, whilst skipping numbers that are not square-free. I get a little thrill when I get to skip over several numbers in a row - for example, 48,49,50 are all NOT square-free (48 is divisible by 2^2, 49 by 7^2, and 50 by 5^2).
This led me to wondering about the earliest ... |
Your challenge is simple. Write two programs that share no characters which output each other.
Example
Two programs P and Q are mutually exclusive quines if:
P outputs Q
Q outputs P
There is no character c which belongs to both P and Q
Each program P and Q are proper quines
This counts empty quines and quines that re... |
Inspiration.
Given (by any means):
A two-argument (or single argument consisting of a two-element list) black box function, f: ℤ+ × ℤ+ → ℤ+ (input and output are 1, 2, 3,…)
A strictly positive integer matrix with at least two rows and two columns
return the matrix's function trace.
What is a function trace?
A normal ... |
Challenge
The challenge is to write a program that takes the coefficients of any n-degree polynomial equation as input and returns the integral values of x for which the equation holds true. The coefficients will be provided as input in the order of decreasing or increasing power. You can assume all the coefficients to... |
UBASIC is a freeware basic interpreter written by Yuji Kida at Rikkyo University in Japan, specialized for mathematical computing. It is considered to be a "ready-to-run" language that and is capable of running on DOS and Windows.
What general tips do you have for golfing in uBasic? Any ideas that can be applied to cod... |
What general tips do you have for golfing in Clean? Please post only ideas that can be applied to code golf problems in general, and are at least somewhat specific to Clean.
If you've never heard of Clean, you can find out more here.
Or, you can join the chat room.
|
Challenge:
Input: Three integers: bottom-edge length; starting amount of grains of sand; index
Output: Output the state of the bottom part of an hourglass at the given index, based on the given bottom-edge length and amount of grains of sand.
Challenge rules:
We simulate the grains of sand with digits 1-9
We put the c... |
Try to create a simple ASCII art scissors animation!
Challenge
All inputs will be integers -31 through 31.
The output will be an animation (To be outputted somewhere, as long as the previous frame is replaced. GIFs are allowed.), separated by (approximately) 1 quarter of a second.
If the input (n) is positive:
The ani... |
Introduction
Try to convert words to two different unicode fonts.
Challenge
Your task is to transform your input string into the and unicode characters.
All uppercase words should become lowercase words.
For Example: WORD ->
All lowercase words should become words
For example: other words ->
All mixed ... |
Introduction
Output all the numbers in specific base that would appear in an adapted version of the game of seven.
Challenge
Your task is to output all the numbers in a given base in a given range, skipping the ones matching certain conditions.
You will be given four inputs: base elim start and end. The roles of the f... |
Specification
This challenge is simple to state: your input is a non-empty array of nonnegative integers, and your task is to partition it into as few substrings as possible, such that each substring is a permutation of a consecutive integer range.
More formally, if the input array is A, then the output is minimum numb... |
Input is an r by c matrix of non-negative integers (you may input r and c as other parameters if this helps with golf). This may be inputted as a 2D array or, if you prefer, a 1D array (though taking in r this time is necessary). Strings separated by spaces to distinguish rows and newlines to distinguish columns are al... |
Story
So I have a book that I want to separate from my table with nothing but other books. I want to know how many books do I need to achieve this with \$n\$ book lengths.
Here's a visualization that my friend at Wolfram drew for me:
More information about the topic in Wolfram and Wikipedia.
Challenge
Given an integer... |
Introduction
Suppose you have a list of lists of integers (or any objects really, but let's stick to integers for simplicity).
The lists may be of different lengths, and some of them may be empty.
Let's write the lists in a tabular format:
[[ 1, 2, 3, 4, 5],
[ 6, 7],
[ 8, 9, 10, 11],
[],
[12, 13, 14... |
Introduction
Your goal is to find the least number of ones you need to add or multiply together to get the input value, this is A005245.
Input
One positive integer N.
Output
The smallest number of ones that must be added/multiplied to get N.
Sample Input
7
Sample Output
6
Explanation
(1 + 1 + 1) * (1 + 1) + 1 = 7
... |
Hexcells is a game based off of Minesweeper played on hexagons. (Full disclosure: I have nothing to do with Hexcells. In fact I don't really like the game.) Most of Hexcells rules can be pretty easily expressed in Generalized Minesweeper (Minesweeper played on an arbitrary graph). The one that is most difficult is th... |
Introduction
The Boids Algorithm is a relatively simple demonstration of emergent behavior in a group. It has three main rules, as described by its creator, Craig Reynolds:
The basic flocking model consists of three simple steering behaviors which describe how an individual boid maneuvers based on the positions and ve... |
A radiation-hardened program is a program where, if any character of the code is removed, the program will still function the same. For this question, we'll be writing a program that detects when it is irradiated.
Write a program or function that, when any single byte is removed, the resulting program will output that ... |
A positive integer can be diluted by inserting a 0 between two bits in its binary expansion. This means that an n-bit number has n-1 dilutions, which are not necessarily all distinct.
For example, for 12 (or 1100 in binary), the dilutions are
11000 = 24
^
11000 = 24
^
10100 = 20
^
In this challenge, we're goin... |
Introduction
Write a solver for the Hitori puzzles using least bytes.
Challenge
Your task is write a solver for the Hitori (ひとり, the word for "alone" in Japanese; the meaning of the game name is "Leave me alone") logical puzzles. The rules are as follows:
You are presented with a n-by-n grid of cells, each cell contai... |
Introduction
Given a set of text-based "screenshots" consisting of printable ASCII chars merge them so that all of them form one long screenshot so that nobody has to do it themselves when reading it.
Challenge
Take input as a list of strings (referred to as "screenshots"). Each screenshot consists of several lines of ... |
Given a string as input find the longest contiguous substring that does not have any character twice or more. If there are multiple such substrings you may output either. You may assume that the input is on the printable ASCII range if you wish.
Scoring
Answers will first be ranked by the length of their own longest ... |
Introduction
This challenge is similar to Project Euler problems. I came up with it because I was playing a deceivingly simple board game and couldn't come up with an efficient solution to answer a simple question about its mechanics.
Quarto is a fun variant of 4 in a row. It is played on a 4 by 4 board with 16 unique ... |
Challenge
Write a program that compresses and decompresses ASCII text losslessly. It should be specialized to work well with palindromes, including case-insensitive and punctuation-insensitive palindromes. The best compression with the smallest source wins.
Scoring
total_bytes_saved / sqrt(program_size) - Highest score... |
Your challenge is to expand some brackets in a program's input as shown:
Find a string s between two matching brackets [ and ], with a single digit n after the closing bracket.
Remove the brackets.
Replace s with itself repeated n times. (If n is 0, simply remove s.)
Go to step 1 until there are no more matching brack... |
Input:
A matrix containing integers in the range [0 - 9].
Challenge:
Determine if all non-zero elements are connected to each other vertically and/or horizontally.
Output:
A truthy value if all are connected, and a falsy value if there are non-zero elements/groups that aren't connected to other elements/groups.
Test ca... |
This challenge is from an admission test to a closed number cyber security course. Anyway it doesn't have to do with cyber security, it's just to test the students logical and coding skills.
Task
Write a program that removes entries from an array so that the remaining values are sorted in a strictly decreasing order an... |
Apparently yes! In three easy steps.
Step 1
Let f(n) denote the prime-counting function (number of primes less than or equal to n).
Define the integer sequence s(n) as follows. For each positive integer n,
Initiallize t to n.
As long as t is neither prime nor 1, replace t by f(t) and iterate.
The number of iterations ... |
As computer scientists, you're probably all familiar with the basic list operations of pop and push. These are simple operations that modify a list of elements. However, have you ever heard of the operation flop? (as in flip-flop)? It's pretty simple. Given a number n, reverse the first n elements of the list. Here's a... |
Definition
The maxima and minima of a given function are the largest and smallest values of the function either within a given range or otherwise within the entire domain of the function.
Challenge
The challenge is to find the local maxima and minima of a given polynomial function using any method you may like. Don't w... |
As we saw in this question complex logical statements can be expressed in terms of the simple connectives of generalized Minesweeper. However Generalized minesweeper still has redundancies.
In order to avoid these redundancies we define a new game called "Generalized-1 Minesweeper".
Generalized-1 Minesweeper is a vers... |
Your task is to model the effects of batter on pieces of food. Please add three layers of crust.
[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0], // in
[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0],
[0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0],
[0,0,0,0,0,0,0,0... |
Task
Given a list of integers L and another integer s, the goal is to compute the column-wise sums of all s-length (potentially overlapping) slices of L, while pertaining their positions relative to L (see below).
Definitions
The s-length (overlapping) slices of the list L are all the contiguous subsequences (without w... |
Notice: I'm willing to give a bounty to any answer that I find interesting.
Your challenge is to design a Turing-complete one instruction set computer (OISC):
An OISC is an abstract machine that uses only one instruction – obviating the need for a machine language opcode. With a judicious choice for the single instruc... |
A Russian nesting doll, more commonly known as a Matryoshka doll, is a doll which contains a smaller version of itself, which then contains another smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself... - until fi... |
Your assignment is to write a program of even length, that prints an ASCII-art square (described below), that increases its side length by 1 unit each time the original source code is pasted in the middle of the current code.
It is quite hard for me to define this task very well, so I'll give you an example:
Let's sa... |
Weather forecasting: Wrong too often to rely on, right too often to ignore.
Given a high and low temperature and one of four weather conditions per day, output an ASCII-art graphical five day weather forecast. The structure of the four graphical indicators are shown below.
\ /
-O- Sunny
/ \
\ /
-O(==) ... |
We are doing a PCG challenge at work, and I'm submitting answers in C#. This is a modification of the "M'Kay" challenge. My solution has been deemed correct by the requirements, I'm just trying to shrink it further if possible.
A filler word is an apparently meaningless word, phrase, or sound that marks a pause or h... |
Given n=m^2, return a list of integers that do not border the m x m grid of integers from 1 to n.
Examples
n=1 (m=1)
Grid:
[1]
Return:
[]
n=4 (m=2)
Grid:
[1,2]
[3,4]
Return:
[]
n=9 (m=3)
Grid:
[1,2,3]
[4,5,6]
[7,8,9]
Return:
[5]
n=16 (m=4)
Grid:
[ 1, 2, 3, 4]
[ 5, 6, 7, 8]
[ 9,10,11,12]
[13,14,15,16]
Return:
[6,... |
Your challenge is to implement a cyclic Program Sequence Generator (PSG) in a language of your choice.
Given a language, L, a PSG in L is a program in L that outputs a PSG in L. Some properties of a PSG are:
Repeated execution of a PSG in L generates a sequence of programs in L.
A PSG is said to be cyclic if the seque... |
Normal brackets ((),[],<> and {}) are nice and unambiguous, however someone thought it would be a good idea to use non bracket characters as brackets. These characters, | and ", are ambiguous. For example does
""""
correspond to
(())
or
()()
It is impossible to tell.
Things start to get interesting when you mix ty... |
This challenge was originally sandboxed by Magic Octopus Urn; I adopted and posted it with his permission.
This is the cops' thread. The robbers' thread is here.
The challenge
Step One: Write a piece of code (function or full program) which checks for primality.
Step Two: Remove pieces of your code by replacing charac... |
This is the robbers' thread. The cops' thread is here.
Your challenge is to take an uncracked submission from the cops' thread and try to find the original unredacted program. Please comment on the cop's submission when you've cracked their code.
|
Challenge
The challenge is to write a code that takes a positive integer 'n' as an input and displays all the possible ways in which the numbers from 1 - n can be written, with either positive or negative sign in between, such that their sum is equal to zero. Please remember that you may only use addition or subtractio... |
It's annoying when you have to search for a language homepage, get its link, and add it to your SE comment/answer, right? Let's write a script to do that for you!
Challenge
For each language name (intentional or not) in the input, replace it with the markdown link to the language home page, defined by TIO.
Rules
(impo... |
Challenge
For this challenge, a mountainous string is one that conforms to the grammar rule M: x(Mx)* where at each production, the all x's are the same character. When indented, a mountainous string might look something like this:
A
B
C
D
C
E
F
E
C
B
A
As you can see, it looks a bit like a mounta... |
The brethren from the order of St Golfus the Concise have a tradition of reciting a short prayer whenever they see someone make the sign of the cross. Due to the high level of sin measured among tourists recently, they have installed CCTV in the monastery, and they've hired you to help them keep old tradition alive in ... |
Challenge
Given a real number as input, calculate the number of times which the natural logarithm function ln can be applied to it before the resulting number becomes imaginary.
Explanation
Applying ln to a negative number results in a non-real number. This means that, by repeatedly applying ln to a number, you will ev... |
There are n places set around a circular table. Alice is sat on one of them. At each place, there's a cake. Alice eats her cake, but it doesn't taste very nice. Then the Mad Hatter comes in. He gives Alice a list of n-1 numbers, each between 1 and n-1. For each item i in the list, Alice has to move around i places and ... |
Triangularity is a new esolang developed by Mr. Xcoder where code structure has to follow a very specific pattern:
For the nth line of code, there must be exactly 2n-1 characters of the program on it. This causes a triangular/pyramid shape, with the first line having only one character and the rest increasing by inc... |
Quylthulg is a language by Chris Pressey that attempts to solve the problem of infix notation using what it calls panfix:
like postfix, panfix does not require the deployment of arcane contrivances such as parentheses to override a default operator precedence. At the same time, panfix allows terms to be specified in t... |
Haskell has this neat(-looking) feature where you can give it three numbers and it can infer an arithmetic sequence from them. For example, [1, 3..27] is equivalent to [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27].
That's cool and all but arithmetic sequences are fairly limiting. Addition, pfft. Multiplication's ... |
Given the following input:
An integer n where n > 0.
A string s where s is not empty and s~=[0-9A-Z]+ (alpha-numeric capitals only).
Using a standard, simplified QWERTY keyboard (as shown below):
1234567890
QWERTYUIOP
ASDFGHJKL
ZXCVBNM
Perform the following operation:
Find the original row that each character is in... |
Last month I borrowed a plenty of books from the library. They all were good books, packed with emotions and plot-twists. Unfortunately, at some points I got very angry/sad/disappointed, so I tore some pages out.
Now the library wants to know how many pages I have torn out for each book.
Your goal is to write a program... |
On PPCG, we have had lots of challenges where the length of your output is dependent on the length of your source code. For the purposes of this challenge, we will call these Source-length problems. The two most well known examples of source-length problems are
Output with the same length as the code (the 1X source-l... |
You are given an array A of n strictly positive integers, with n ≥ 2.
Your task is to map each entry Ai to:
1 if Aj mod Ai is odd for each j such that 1 ≤ j ≤ n and j ≠ i
2 if Aj mod Ai is even for each j such that 1 ≤ j ≤ n and j ≠ i
0 otherwise (mixed parities)
Example
For A = [ 73, 50, 61 ], we have:
50 mod 73 = ... |
A repost of this challenge. Meta discussion. Sandbox post. Body of the question similar to the original
Robber's challenge
This cops and robbers is now (08/03/2018) closed to further competing cop entries, as robbers may no longer be competing to crack answers, but feel free to post new answers.
The Cops challenge was... |
Cops challenge
The Robbers' Challenge
Find a vulnerable answer. That is, an answer which hasn't been cracked yet and which isn't safe yet either.
Crack it by figuring out its language. That is, find any language in which the given program is a valid program (subject to the rules outlined in the Cops' Challenge above)... |
Choose a set of four bytes without replacement (i.e. no byte repeated), and not necessarily in any particular order, from any one of the following four sets:
The characters of any one single-byte encoding
The Unicode characters in the range 00–FF
The signed decimal integers in the range −128–127
The unsigned decimal i... |
Most everyone here is familiar with Pascal's Triangle. It's formed by successive rows, where each element is the sum of its two upper-left and upper-right neighbors. Here are the first 5 rows (borrowed from Generate Pascal's triangle):
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
. . .
Collapse these rows to the left
1
1... |
Introduction
Write a program to output the outgoing spiral of the famous pangram following given rules.
Challenge
A pangram is a sentence using every letter of a given alphabet at least once. One of the most famous pangrams is the one used extensively in Windows font viewer, namely "The quick brown fox jumps over the l... |
This is a different type of compression challenge. In a normal kolmogorov-complexity challenge, you are required to recreate a list exactly. Here, you are allowed to round the values in any way you wish. What's the catch? Your score is penalized based on how wrong your output is.
At the bottom of this question is a... |
Write a code that runs or compiles in as many programming languages as possible and prints a newline separated list of names of previous and current programming languages.
Every used language must have 1 character longer name than previous; ex. C#, C++, Ruby, Jelly, Python...
Each language must output a list of langua... |
Note
This is the encryption challenge. The decryption challenge can be found here.
Challenge
The challenge is to encrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces.
Equivalent of a Character
Now, firstly you would need to know how to... |
An Izhikevich neuron is a simple yet quite effective model of a biological neuron, designed for use in a discrete time-stepping simulation. In this golfing challenge, you will be implementing this model.
Parameters
This model involves only 7 variables organized into 2 differential equations, compared to the dozens of p... |
Context
Consider square matrices with n columns and rows containing the first n^2 (i.e. n squared) positive integers, where n is odd. The elements of the matrices are arranged such that the integers 1 through n^2 are placed sequentially in a counterclockwise spiral starting at the center and initially moving to the lef... |
Your task is to write a computer program such that when it is cut up into lines (split on the newline character) every arrangement of the lines will output a different number between 1 and n! (where n is the total number of lines). No number should be output by two different arrangements and every arrangement should o... |
I was messing around with infinite resistor networks (long story) when I came across the following interesting recursive pattern:
|-||
|---
Each instance of this pattern is twice as wide as it is tall. To go from one level of the pattern to the next, you break up this rectangle into two sub-blocks (each of which is a ... |
Amazingly, this is the easier of the three card tricks I know off the top of my head...
The aim of this is to have your compiler perform a specific card trick. There's no slight of hand, and the compiler won't be memorizing the choice and saying "Voila, this is your card!" The code will basically manipulate a stack of ... |
Introduction:
I collect twisty puzzles, so I'm quite the fan of rubiks-cube-challenges (even though most are fairly difficult). So, let's try a fairly easy rubiks-cube-challenge for a change.
When an NxNxN Cube gets scrambled during a WCA (World Cubing Association) competition, the cube is always held in the same way b... |
You will be given a square matrix of integers M and another positive integer n, strictly smaller than the size of M. Your task is to generate all square sub-matrices of M of size n.
For the purposes of this challenge, a square sub-matrix is a group of adjacent rows and columns contained in M.
Input / Output Formats
Yo... |
Statement
Given N distinct integers, output them in order such that
for any integer J from 2 to N,
for any K>0 obtainable by dividing J by 2 (rounding down) at least one time,
the Jth integer output is larger than the Kth if and only if the division by 2 that gave K (i.e., the last division) divided an odd integer... |
A cyclic difference set is a set of positive integers with a unique property:
Let n be the largest integer in the set.
Let r be any integer (not necessarily in the set) greater than 0 but less than or equal to n/2.
Let k be the number of solutions to (b - a) % n = r where a and b are any members of the set. Each solu... |
Yes, It's basically You're a Romanizer, Baby, but harder. like, way harder.
Learning Korean is HARD. at least for a person outside Asia. But they at least have the chance to learn, right?
What you must do
You will be given a Korean Statement. For example, 안녕하세요. You must convert the input to its Roman pronunciation. ... |
Jack is a little businessman. He found out a way to earn money by buying electricity on days when it's cheap and selling it when it's much more expensive. He stores the electricity in a battery he made by himself.
Challenge
You are given N (if required), the number of days Jack knows the cost of electricity for, and X,... |
John has made an array of numbers which are important to him. Unfortunately, John lost the array.
Luckily, he knows some details about the array. You will receive each of these sets of details (which are lists of 3 integers).
Each detail is the sum of a section of the list. Each has the numbers a, the starting index... |
Most Android smartphones allow the user to use a swipe pattern to open their phone:
Certain patterns are legitimate, and others are impossible. Given an input swipe pattern, return a truthy or falsy indicating if the given input pattern is legal or not.
Input
The grid is labelled row-wise 1 through 9:
1 2 3
4 5 ... |
Pancake sorting is the colloquial term for the mathematical problem of
sorting a disordered stack of pancakes in order of size when a spatula
can be inserted at any point in the stack and used to flip all
pancakes above it. A pancake number P(n) is the minimum number of
flips required for n pancakes. 1
In 1979, a you... |
A palindrome is a string which is the same when read forwards and backwards. For example "racecar" is a palindrome, but "Racecar" is not. A substring is a contiguous set of characters in a larger string. Your task is to write a program or method which takes a string or character array as input and outputs the length of... |
Given a string l, find all palindromic substrings p of l (including duplicates and single character strings). Next, rearrange all sub-strings in p into a valid palindrome (there may be multiple correct answers). If it is not possible to rearrange p into a single palindrome, your program may have undefined behavior (err... |
Bertrand's Postulate states that for every integer n ≥ 1 there is at least one prime p such that n < p ≤ 2n. In order to verify this theorem for n < 4000 we do not have to check 4000 cases: The Landau trick says it is sufficient to check that
2, 3, 5, 7, 13, 23, 43, 83, 163, 317, 631, 1259, 2503, 5003
are all prime. ... |
Output or display the following three lines of text, exactly as they are shown below. A trailing newline is accepted.
bC#eF&hI)kL,nO/qR2tU5wX8z
A!cD$fG'iJ*lM-oP0rS3uV6xY9
aB"dE%gH(jK+mN.pQ1sT4vW7yZ
That block of text is the same as the one below, but where the n'th column is rotated n times downward:
!"#$%&'()*+,-./... |
Sequence Definition
Construct a sequence of positive integers a(n) as follows:
a(0) = 4
Each term a(n), other than the first, is the smallest number that satisfies the following:
a) a(n) is a composite number,
b) a(n) > a(n-1), and
c) a(n) + a(k) + 1 is a composite number for each 0 <= k < n.
So we start with a(0) =... |
Given a list of positive integers determine if there is an element that is either greater than its two neighbors or less than its two neighbors (a "bump"). To be clear a bump can never be the first or last item of the list because they only have one neighbor.
Your program should output one of two consistent values eac... |
Yabasic, or Yet Another Basic is a dialect of basic created by Marc-Oliver Ihm that may be run on Windows, Unix and PAL versions of the Sony PlayStation 2. Development for this language is ongoing.
Helpful Resources
Yabasic Official Website
Yabasic Manual
Yabasic Wikipedia Page
Yabasic GitHub
Yabasic PS2 Documentatio... |
This page is not for Visual Basic .NET Tips or VBA tips
Visual Basic (VB or VB6) is an object-oriented and event-driven dialect of basic that was developed and released by Microsoft in 1991. The last release of Visual Basic came as Visual Basic 6.0 in 1998, and the language was declared a legacy language in 2008. Visu... |
This page is not for Visual Basic Tips
Visual Basic .NET (VB.NET) is an multi-paradigm dialect of basic that was developed and released by Microsoft in 2002 as a replacement for Visual Basic. The current version of VB.Net as of Feb 2018 is Visual Basic .NET 15.0.
Unlike Visual Basic (VB), Visual Basic .NET (VB.NET) is ... |
Local periods
Take a non-empty string s.
The local period of s at index i is the smallest positive integer n such that for each 0 ≤ k < n, we have s[i+k] = s[i-n+k] whenever both sides are defined.
Alternatively, it is the minimal length of a nonempty string w such that if the concatenation w w is placed next to s so t... |
This is a brainfuck version of Largest Number Printable, and this.
Let's think about brainfuck interpreter such that,
Has array that can be stretched left & right arbitrary large
Each cell can contain arbitrary large integer
Can contain negative integer too
When the interpreter starts, every cell is intialized by ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.