instruction stringlengths 34 53.1k |
|---|
C/C++ use double quotes "" for making string literals. If I want the double-quote itself, or certain other characters, to appear in the string, I have to escape them, like so:
char *s2 = "This is not \"good\".\nThis is awesome!\n";
Here, I used \" to represent a double-quote, and \n to represent the newline character.... |
A Vigenère Cipher is encrypted by repeating a keyword to be the length of the plaintext, and summing each character in that text with the corresponding letter in the plaintext modulo 26. (using A=0,B=1 etc.)
For example, if the keyword is LEMON and the plaintext is ATTACKATDAWN, then the key is repeated to form LEMONLE... |
Problem: given any input string that does not contain null bytes, determine whether or not the input string matches glob as defined below:
null is disallowed in both string in glob
* matches zero or more characters
** is disallowed in glob
? matches exactly 1 character
[ch] matches a character class o... |
You should write a program or function which receives a string representing a chessboard with only pawns as input and outputs or returns whether any capture is possible on the board.
Input is in a FEN-like notation describing positions of white and black pawns with no other pieces present. You should decide if there is... |
Your task is to create a program which takes a string, and if it contains any numbers, symbols or other non-letter characters, it throws an error. Else, it returns the original string. (The string may include whitespace)
("Letters" are a-z and A-Z)
Examples:
Input: My name is Joe
Output My name is Joe
Input: My userna... |
A three-fruit pie is made of three different fruits. What is the most three-fruit pies you can make from the quantities of 5 fruits you have?
For example, with
1 apple
1 banana
4 mangoes
2 nectarines
0 peaches
you can make 2 pies:
apple, mango, nectarine
banana, mango, nectarine
Input: Five non-negative integers, ... |
The Challenge
Implement the Sundaram sieve for finding prime numbers below n. Take an input integer, n, and output the prime numbers below n. You can assume that n will always be less than or equal to one million.
Sieve
Start with a list of the integers from 1 to n.
Remove all numbers that are in the form i + j + 2ij... |
Objective
Design a modulator/demodulator pair to accurately transmit data as quickly as possible over simulated plain old telephone service (POTS).
Steps
Generate some random (/dev/random or the like) data that will take 3-4 seconds to transmit
Modulate the data with your modulator to produce an audio file
Pass the au... |
I have always failed to give an answer for kolmogorov-complexity challenges which require string compression, the main reason being that I don't know to use string compression tools as effectively as I should.
For this reason, I have posted this question. Unlike my other tips questions, this is not language specific m... |
Between the kitten question and seeing this question at U&L about some sed magic, how about implementing tac?
Objective
Implement a program that will reverse and print the lines in a file.
Input
A file, provided as a name or via standard input
Output
The lines, reversed, to standard out.
Scoring
Bytes of source cod... |
Question
We are captured by robot army on their space station. Our space ship pilot is in the prison which is in level 1. There is only one way how to escape and it's rescuing your space ship pilot. It mean's moving from level N to level 1. However because it's very risky you need to get to the prison in the least numb... |
Introduction
In this challenge, we will simulate a certain probabilistic cellular automaton using very bad pseudorandom numbers.
The cellular automaton is defined on binary strings by the following local rule.
Suppose that the left neighbor of a cell and the cell itself have states a and b.
If min(a,b) == 0, then the ... |
Since the first weekend of October is drawing near, let's have our own Oktoberfest!
Background
You and some other programmers have been hired by the local sausage guys in Munich, Germany. The sausage guys provide Oktoberfest with all the sausages the giant Volksfest needs. You manage to overhear your boss speaking to t... |
I define the following operators:
Manhattan Addition a +M b, for single-digit numbers, is the result of concatenating b onto a. So, a +M b = 10a + b. Therefore, the general operator +M is defined as thus:
a +M b = 10a + b
Manhattan Subtraction a –M b, for single-digit numbers, is the result of removing the last b from ... |
A challenge with simple rules but non-trivial algorithms. :-)
Task
Take input in the form of space-separated integers:
N A B S
Where N is the side length of a 2D square matrix filled with unique numbers (integers) between A and B inclusive. For each row and column in this matrix, the sum is always the same: S. (In oth... |
The goal of this challenge is to create a program that takes in a matrix and outputs its reduced row-echelon form.
A matrix is in reduced row-echelon form if it meets all of the
following conditions:
If there is a row where every entry is zero,
then this row lies below any other row that contains a nonzero entry... |
Have you heard about trees?
When performing DFS on a binary tree, you can traverse it in 3 possible orders.
Root, left node, right node (Pre-order)
Left node, Root, right node (In-order)
Left node, right node, root (Post-order)
Check wikipedia to know more.
For this challenge, you have to provide a program that, giv... |
Objective
Write a program in any language that reads a matrix from stdin in which all columns are space delimited and all rows are newline delimited. The program must output a sub matrix so as that there is no other sub matrix with greater average, this sub matrix' average value, as well as the starting and ending coor... |
Objective
You have two knights on a standard chessboard labelled 1-8 and A-H, one knight is located at 1C and the other at 2G. You have to write a program in the language of your choosing that accepts a set of coordinates from stdin, like 2C, and then calculates which of the two knights you have to move in order to cap... |
Your task is to create the shortest infinite loop!
The point of this challenge is to create an infinite loop producing no output, unlike its possible duplicate. The reason to this is because the code might be shorter if no output is given.
Rules
Each submission must be a full program.
You must create the shortest infi... |
The Challenge
Write a complete program that writes twice as many bytes to standard output as the length of the program.
Rules
The program must write ASCII characters to the standard output.
The contents of the output doesn't matter.
The output, measured in bytes, must be exactly twice the length of the program, also ... |
Write a program that takes an input to STDIN and makes all of the lowercase letters (including accented letters) in the 2k-1th word uppercase and all the uppercase letters (also including accented letters) in the 2kth word lowercase (k is a positive integer). The program should not affect any other characters in any wo... |
Challenge
Your goal is to write a program which will output the 8 measurements of a rectangle, with only some measurements in the input. Your program should throw an error if it cant be done.
Here is what each measurement means:
| left
| | centerX
| | | right
| | ... |
I have read: Tips for golfing in Python
I would like to golf this code further. Any more tips?
x,y,q,w=[int(i) for i in raw_input().split()]
while 1:
a=int(input())
s=d=""
if q>x:
s="W"
q-=1
elif q<x:
s="E"
q+=1
if w>y:
d="N"
w-=1
elif w<y:
d="S"
w+=1
print d+s
The program:
You move on a map whi... |
Your task is to create a program that prints "Greetings, Planet!" exactly to the console. Seems simple enough, right? Well, here's the trick. The code must be a palindrome, meaning it reads from right to left the same as in left to right.
Standard loopholes are NOT allowed.
|
You have a number of polynomials who are lonely, so make them some companions (who won’t threaten to stab)!
For a polynomial of degree n, there is an n by n companion cube matrix for it. You need to make a function that accepts a list of coefficients for a polynomial in either ascending (a + bx +cx^2 + …) or descendin... |
Introduction
Suppose for a moment that the vipers and cliff are only two steps away, instead of three.
o
---
Hsss! |
';;' ___ /_\ ___ _
|
You are, unfortunately, a captive of a sadistic torturer. You must take a step either to the left or to the right every turn. ... |
Given a string consisting of printable ASCII chars, produce an output consisting of its unique chars in the original order. In other words, the output is the same as the input except that a char is removed if it has appeared previously.
No built-ins for finding unique elements in an array can be used (for example, MATL... |
Python's pickle module is used for serialisation, allowing one to dump an object in a way such that it can be later reconstructed. For this, pickle uses a simple stack-based language.
To keep things simple, we will be dealing with a small subset of this language:
( Push a mark to the stack
S'abc'\n P... |
I need to light some candles. In fact, I need to light an arbitrary amount of candles. But only the good ones.
OBJECTIVE Given a block of text (containing lit, valid, and invalid candles) and a number N as input, write a program or function that lights an amount exactly equal to N, minus the number of already-lit cand... |
In public-key cryptography, a public key fingerprint is a short sequence of bytes used to identify a longer public key.
In SSH in particular they can be used to verify that a server is in fact the server I'm expecting to communicate with and I'm not targeted by a man-in-the-middle attack.
They are usually represente... |
It's my 17th birthday and you're invited to my party!
And as always at parties, there will be cake.
One cake...
And you need as much of it as possible.
As this is a fair party, each of us will say how much of my cake we want and the person who said the smallest amount will get it. Then everyone else gets to repeat the... |
dog is a command-line utility that takes in an arbitrary number of arguments,
the first of which is the text to be written and the others are arbitrarily many files.
The dog utility will split the text in equal portions over these files. If there is a remainder n, the first n files get an additional byte
dog is the opp... |
Well, the librarian caught you cheating at your job by using your sorting algorithm, so now you're being punished. You've been ordered to create some code so the librarian can impress the object of their unrequited affection, the math teacher. So that's what "Other duties as assigned" means ...
Everyone is familiar wit... |
Challenge
Peter has risen again to save us from the duplicate challenges!
Peter Taylor is dead, and there's no doubt about it (well, apart from the huge amount of doubt we have... but just ignore that). In his memory, you must write a program which determines whether a given user is alive or dead.
Further Information
A... |
NB : Everything presented in the situation is totally fake and had just been put here to make the challenge a little more fun ;) ... Or maybe not ;)
=== === BEGINNING TRANSMISSION === ===
Hello,
I recently had a disk failure. I hopefully had backups and I now want my photos back. However, EVERY backup looks corrupted ... |
You are a web developer, and your boss has decided to update the company's website. He has decided that less color is better, but he wants the site to look the same. You justly decide that he has no idea what he's talking about, but you're going to try anyway, because you're bored. Since the company has thousands of we... |
Consider the following process:
Take some non-negative integer N.
e.g. N = 571
Express it in binary with no leading zeroes. (Zero itself is the only exception, becoming 0.)
e.g. 571 = 1000111011 in binary
Break apart consecutive runs of ones and zeroes in this binary representation.
e.g. 1000111011 → 1, 000, 111, 0,... |
Your task is to create an interpreter for a calculator. It has to parse commands like 5 + 5 and return the answer.
It has to be able to add, subtract, multiply, and divide. The interpreter only needs to accept two numbers (ex. 9 * 5 and 3 + 3)
The interpreter will take input from a console/whatever, not a file.
Eval is... |
Background
A few months ago, the adventure of your life was just about to start. Now, in this precise moment (yeah, now), after months of suffering and hard work, you and a group of friends are standing on the top of the world. Yes, you are right, you are on the summit of Sagarmāthā.
However, things aren't going as wel... |
It is a dry summer in the prairie. The four farmers in the area realize that they can corner the market on corn by burning their neighbors crops. But they need a strategy for doing so; that is where you come in.
Your task is to write a bot to tell the farmers what to burn. The goal is to finish the game with the larges... |
Quines have been around forever. It's a fun challenge: write a program that, when executed, generates its own source code as output. But how do you know it's actually producing its own source code? Generally, you have to look at it and compare it, but with quines generally being composed of tricky and intricate code... |
For golfing practice, I have been doing the assignments in my girlfriend's Intro to Python class. I found that for this assignment, there were multiple strategies that came very close in character count, and I'm sure people here can find even better ways. Although I am most interested in ways to do this in Python, I wo... |
Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday.
(Sorry this one's a little late.)
I'm sure most of you folks have heard of Levenshtein distance, an algorithm for calculating the distance between two strings. Well, this challenge is about implementing a similar algorithm of my... |
Write a function which takes in a list of positive integers and returns a list of integers approximating the percent of total for the corresponding integer in the same position.
All integers in the return list must exactly add up to 100. You can assume the sum of integers passed in is greater than 0. How you want to r... |
This reminds me when a few years ago someone uploaded a torrent "Hacker tool: complete list of all IP addresses". This was, of course, just a generated list of the ~4 billion IPv4 addresses, but thousands of "h4xx0rz" downloaded it. Look mum, imahacker!
This was then, but nowadays everybody has switched to IPv6. (Rig... |
Have you ever wanted to ask the compiler "Why?" Most of us have been frustrated when the code isn't working as it should. Mathworks has therefore implemented a nice little function, why, that answers the question. To give a few examples from MATLAB:
why
The programmer suggested it.
why
To fool the tall good and smart ... |
I like to do programming challenges in my free time to teach myself and keep fresh, this one I can't seem to optimize though and it's driving me insane.
The goal is essentially, "Given a number, return the numbers leading up to it as a palindrome."
For example if you are given the input 5 the answer your program should... |
Background
A polyomino is called L-convex, if it's possible to travel from any tile to any other tile by an L-shaped path, that is, a path that goes in the cardinal directions and changes direction at most once.
For example, the polyomino of 1s in the figure
0 0 1 1 1 0
1 1 1 1 0 0
1 1 0 0 0 0
is not L-convex, since... |
Pyth is in ongoing development, meaning that new features are being added all the time.
I want to make Pyth a better langauge, so I'd like to know what features people are looking for.
This is the place the post ideas you have for making Pyth better.
In your answer, please state:
What you'd like to see changed/added.
... |
Simply put, your goal is to create a complete program that modifies its own source code until every character of the source is different than what it started as.
Please include the beginning source as well as the ending source in your post, as well as a description. E.g. Describe what (else) your program does, the lang... |
mbomb007 asked us to make a self mutilating program. Its an interesting challenge, but I personally don't like to encourage my programs to be self-mutilating. I like to think that, at the heart of every program is a beautiful butterfly waiting to break out.
As such, for my first ever Code Golf challenge, I challenge ... |
Intro
In Objective-C (a superset of C and an object-oriented language), I can create an object called a UIWebView. There is a method for this object called loadHTMLString: in which I can load actual HTML into the UIWebView object itself. I can also inject Javascript into it using the method stringByEvaluatingJavaScript... |
Take a look at this chamomile flower:
Pretty, isn't it? Well, what if I told you that this wasn't actually one flower?
A lot of flowers (including sunflowers, chamomiles, daisies and others) actually consist of many very small flowers (the black dots on sunflowers) on a flower head. These miniature flowers are called ... |
QWERTY keyboard distance (QKD) is, in short, the distance between two letters/numbers/punctuation keys on a standard QWERTY keyboard (if you don't have one around, you can check this Wikipedia picture). Note that only characters without modifiers be considered for this challenge (so ; is valid, but ) is not).
Some exa... |
Challenge
Given a positive integer N that is 28 or above, output a list of numbers summing to N that uses each digit 1 through 7 exactly once. You can give as a program or function.
The digits can appear by themselves or concatenated, as long as you use each of them once without repeats. For example,[12, 34, 56, 7] is ... |
The program has an input of a and b, and outputs the sum of numbers from a to b, inclusive. Score is in bytes. As always, standard loopholes are disallowed.
If your input is in the format [a,b], +3 bytes
|
RTTTL, or Ring Tone Text Transfer Language is a music format that was invented by Nokia in the dawn of time when dinosaurs roamed the land. It allows for fairly crude pieces of music (no chords or anything), and the format is pretty simple which is why I think it's pretty cool. Take a look at this one:
DejaVu: d=8,o=5,... |
So, you're browsing Programming Puzzles & Code Golf, and you see a new challenge. The author (gasp) forgot to say "No standard Loopholes". You decide to take advantage of this situation, and you read the answer from a file/network. However, you need to make sure that your answer is actually shorter than the legitimate ... |
Let's say you've got a table of data:
meter_id date 0000 0600 1200 1800
0 030915 10 20 30 40
1 030915 15 7 49 2
where the last four columns are meter readings at different times. You want to output
meter_id date time reading
0 030915 0000 10
0 030915 0600 20
etc.
Your inpu... |
Background
The echo program is so neat. You can say anything to it, and it repeats your words perfectly, every time! How cool is that! Disappointingly, it repeats the input all at once, regardless of your typing speed, which is not very realistic. We'll have to fix that.
The Task
Your program shall take its input from ... |
Martin has created a nice snippet that can be used to keep track of the score for answers to challenges. That's great and all, but wouldn't it be better if you could keep track of it yourself?
Create a program that compares the byte counts in itself with the rest of the answers to this question, and returns "I'm answer... |
IUPAC in their insufferable wisdom have created a systematic element name for any newly created element. This is the temporary name of an element until they finally make up their minds about an actual name. It works like so: each digit of an element number is assigned a prefix based on its value. The prefixes are conca... |
In this challenge, you will be given the source code of a Java program. Your task is to write a function or full program that will remove the whitespace from this program. The whitespace-removed program should work exactly the same as the original program. Your program can be in any language. In this challenge, every s... |
In Python it is often necessary to use str.replace(a,b), however .replace is rather long and feels unnecessary. So is there a shorter alternative to str.replace.
Alternatively is there a similar trick to how you can use r=range for golfing for str.replace?
Example code for golfing
m=input()
f="hello"
print m.replace('t... |
Here goes a quick proof by Alan Turing that there is no program H that can solve the halting problem. If there was, you could make a program X such that X(n) = if H(n,n) == Halt then output X(n) else output ":-)". What is the value of H(X,X)?
Your job is to make a partial halting solver, such that when some X of your c... |
According to the Wikipedia page on the number 69, it is of note that \$69^2 = 4761\$ and \$69^3 = 328509\$ together use all decimal digits. The number 69 is in fact the lowest number that satisfies this property.
For a similar reason, \$32043\$ is remarkable: \$32043^2 = 1026753849\$ uses all decimal digits.
If we're g... |
Background
Last time, we counted groups of a given size, which is a non-trivial problem.
This time, we'll only count Abelian groups, i.e., groups with a commutative operation. Formally, a group (G, ∗) is Abelian if x ∗ y = y ∗ x for for all x, y in G.
The problem becomes much simpler this way, so we're going to count t... |
I created a programming language for manipulating strings called Stringy. It's very different from other programming languages, since you only have one string (for manipulation) and some variables. With the various commands you can manipulate that one string. I created it because it might be useful for some challenges ... |
Ulam's spiral is a truly fascinating, yet puzzling, topic in mathematics. How it works in detail can be found here, but a short summary can be explained as so:
I start off by writing a one, then I write a two to the right of it. Above the two, I write a three, and to the left of that I write four. I continue this patte... |
Everyone knows that the news is boring. Really boring. Unless if it's about Politicians and their scandals. That is fun! But alas, Politicians can commit only so many scandals. So, I am employing you to make the news more interesting.
Objective Given an HTML snippet, perform all the substitutions found here, that is, i... |
The robbers thread can be found here: The Mystery String Printer (Robbers)
Your challenge
Write a program, function, or REPL script that prints a string to STDOUT.
The robbers will try to create a program that prints the same string.
If they successfully can create the program within 7 days, your submission is cracked... |
The cops thread can be found here: The Mystery String Printer (Cops)
Your challenge
Choose a submission from the cops thread, and print out the string from an answer in that thread.
The submission that you choose must not be safe (it must be newer than 7 days).
Your program, function, or REPL script needs to follow th... |
The challenge involves printing the difference between ICMP originate and receive timestamps.
The idea is being able to determine which asymmetric internet path is responsible for packet delay.
One can use hping with --icmp-ts option to gain the raw data on ICMP_TSTAMP. The task is complicated by the fact that hping d... |
Portable Spec.
Iɴꜱᴘɪʀᴇᴅ ʙʏ @ConorO'Brien's ᴜꜱᴇʀɴᴀᴍᴇ.
Aʟꜱᴏ ᴛʜᴀɴᴋꜱ ᴛᴏ @Dᴏᴏʀᴋɴᴏʙ ꜰᴏʀ ꜱʜᴏᴡɪɴɢ ᴍᴇ ᴛʜᴇ ᴇxɪꜱᴛᴇɴᴄᴇ ᴏꜰ ǫ ᴀɴᴅ x.
Sᴍᴀʟʟ Cᴀᴘꜱ ᴀʀᴇ ᴘʀᴇᴛᴛʏ ᴄᴏᴏʟ. Tʜᴇʏ ᴀʀᴇ ᴜɴɪᴄᴏᴅᴇ ᴄʜᴀʀᴀᴄᴛᴇʀꜱ ᴛʜᴀᴛ ʀᴇᴘʟᴀᴄᴇ ꜱᴍᴀʟʟ ʟᴇᴛᴛᴇʀꜱ. Tʜᴇʏ ʟᴏᴏᴋ ᴊᴜꜱᴛ ʟɪᴋᴇ ᴛʜᴇ ᴄᴀᴘɪᴛᴀʟ ᴏɴᴇꜱ, ʙᴜᴛ ꜱᴍᴀʟʟᴇʀ, ᴀɴᴅ ʟᴏᴏᴋ ʀᴇᴀʟʟʏ ᴏꜰꜰɪᴄɪᴀʟ. Yᴏᴜʀ ᴛᴀꜱᴋ ɪꜱ ᴛᴏ ᴡʀɪᴛᴇ ᴀ ᴘʀᴏɢʀᴀᴍ ᴛʜᴀᴛ ᴄᴏɴ... |
Create program that counts the total number of letters common to two names, and finds the product of their lengths, to function as a "love tester."
Conditions: you may not get a 1:1 answer (being 3 out of 3, etc.) output.
Input
Two names from STDIN or closest alternative.
Output
Compute x as the total number of letters... |
Write a program that takes as input a string and an integer n, and outputs:
The string that was passed to the program n times ago;
A new program that will be used for the next invocation.
You cannot store any data outside of the program, and your program cannot call previous programs in the chain. If the string does ... |
Your boss just emailed you a list of 12 programming tasks he needs done as soon as possible. The tasks are simple enough but your boss, being a young software tycoon suckled by social networking, insists that your solutions be able to fit within a single Twitter tweet.
This means that you only have 140 bytes worth of c... |
Inspired by this badly received migrated post.
The head of security at your company is concerned about your PIN generating system after it gave him 12345. He also didn't really appreciate the Spaceballs joke you made at his expense, so you've been delegated to re-write the PIN generator. Since it has to fit on some spe... |
Story, or why we are doing this.
None. This exercise is completely pointless ... unless you are Stephen Hawking.
The Challenge
Given a list of angles, find the average of those angles. For example the average of 91 degrees and -91 degrees is 180 degrees. You can use a program or function to do this.
Input
A list of deg... |
My school has its Homecoming dance next week, and there's someone in mind I want to ask. But I don't want to ask her the normal way. I want to send her a program that prints "Rachel, will you go to Homecoming with me?" However, if I just send her print"Rachel, will you go to Homecoming with me?", it'll be way too obvio... |
What makes the ideal question? Perhaps it is merely the abstraction of a profound thought and the initialization of a dream, a hope, a thought, a (… 5,024.2 characters omitted). Therefore, I propose that we find such a factor to quantify questions. I propose also that this factor be called QF, or the Q-factor. I determ... |
Description
You, an armchair cryptanalyst, have noticed that the first letters of each word in your neighbor's mail (yes, you read it -- how else would you know if he's plotting something?) look very suspicious put together. To make sure that his mail is safe to send to its destination, you need to first decode these m... |
Palindromes are fun, but some of the other strings are starting to feel left out. We can turn those strings into chunky palindromes by splitting them up into palindromic arrays of chunks.
For example, the string "abcabca" isn't a palindrome if we read it character by character, but we have three different ways of makin... |
Write a program which finds the non-unique elements of an array of signed integers. The resulting array can be in any order.
Your answer may be a snippet which assumes the input to be stored in a variable (d, say) and evaluates to the correct result.
Test Cases
Each test case is a single line in the format input => out... |
Given the number of vertices n ≥ 3 and the "step size" 1 ≤ m < n/2 (indicating the distance between two connected vertices), output a graphical representation of the corresponding regular polygram. If the polygram consist of multiple closed loops, each loop must be rendered in a different line colour. (If this sounds ... |
On occasion I get a little blue and need a little music to cheer me up, but clicking the start button and finding my media player takes sooooooo long. I want a faster way to play a song.
The challenge:
Write a program that:
Choose a song from my home directory (so you don’t mix-up program sound
files with music) (thi... |
Whoa, whoa, whoa ... stop typing your program. No, I don't mean "print ABC...." I'm talking the capitals of the United States.
Specifically, print all the city/state combinations given in the following list
in any order
with your choice of delimiters (e.g., Baton Rouge`LA_Indianapolis`IN_... is acceptable), so long as... |
Given a square of text representing a spiral of characters, rotate it!
The spiral starts at the center and moves counterclockwise to the outer edge, starting to the left of center:
987
216
345
This translates to the string 123456789. Rotation is done to the left, so if you rotate it one position, it will be 234567891.... |
Home improvement for the Minotaur
The cretan labyrinth is quite easy to draw. Just start with a symmetric shape (here in red). Let us call all the endpoints of those lines 'nodes'. Then you begin drawing the arches (black): The first one alway begins in the top middle node and connects to the node next to it on the rig... |
Introduction
In this challenge, your task is to decide whether a given sequence of numbers can be separated into two subsequences, one of which is increasing, and the other decreasing.
As an example, consider the sequence 8 3 5 5 4 12 3.
It can be broken into two subsequences as follows:
3 5 5 12
8 4 3
Th... |
In chaos theory, the horseshoe map is an example of how chaos arises in a simple process of folding and squashing. It goes like this: take an imaginary piece of dough, fold it, and finally squash it to its original size. Chaos arises in the pattern of how the pieces of dough end up in the final arrangement after n iter... |
Imagine you have an infinite sequence of the alphabet repeated infinitely many times:
abcdefghijklmnopqrstuvwxyzabcd...
You start at index 0, which corresponds to the letter a, and the should_write boolean flag is False.
The input is a list or string of single-digit numbers. For each number n in the input, you should:... |
Given a pattern representing a list of lengths, and a string representing those lengths, do they match?
For those interested, this is question equivalent to verifying if a row or column of a Nonogram may be correct. However, I have omitted all language relating to Nonograms to make the question less confusing for those... |
Write a program or function that takes in a rectangular grid of text where every cell is either an A or a B. All the A cells will form a simply-connected shape, i.e. they will all be orthogonally connected with no holes (diagonally neighboring letters do not count as connected). Likewise, all the B cells will form anot... |
Monday Mini-Golf: A series of short code-golf questions, posted (hopefully!) every Monday.
(Sorry I'm late again; I was away from my computer basically all of yesterday and today.)
Us programmers (especially the code-golfers) sure love arbitrary integer sequences. We even have an entire site dedicated to these sequenc... |
Write a program or function that takes in an integer greater than 1 or less than -1. That is, the input won't be 0, 1, or -1.
If the input is 2, the output should be:
|\_/|
|___|
If the input is 3, the output should be:
|\_/\_/|
|______|
If the input is 4, the output should be:
|\_/\_/\_/|
|_________|
The pattern co... |
Note 2: I accepted @DigitalTrauma's 6-byte long answer. If anyone can beat that I will change the accepted answer. Thanks for playing!
Note: I will be accepting an answer at 6:00pm MST on 10/14/15. Thanks to all that participated!
I am very surprised that this has not been asked yet (or I didn't search hard enough). Ei... |
Write an algorithm to interpret a sequence of letters as a Roman numeral. (see roman numeral rules below)
Each distinct letter has a matching Arabic decimal value, no maximum. But you don't have the key beforehand, so {A=10, I=1, X=5, ... Z=1000000} is decided by your interpretation.
Challenge
Read input via STDI... |
The Alternating Harmonic Series is a well known convergent series.
"Clearly", it is obvious that it converges to the natural log of 2. Or does it?
Since the series is not absolutely convergent, by simply rearranging the terms, I can make it approach anything I want. Suppose I want the series to converge to e. All I'd ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.