Tagged Questions
A competition to solve a particular problem through the usage and manipulation of strings.
7
votes
2answers
83 views
How many squares are there?
This challenge is inspired by a picture that often roams on Facebook that looks like this. Except our base square will look more like this:
┌─┬───┬─┐
├─┼─┬─┼─┤
├─┼─┴─┼─┤
├─┼─┬─┼─┤
└─┴─┴─┴─┘
The ...
6
votes
2answers
57 views
Print the AdamN tile
Adam7 is an interlacing algorithm for raster images, such as PNG. It is called the "Adam7" algorithm because it was invented by Adam M. Costello, and it is generated by following a certain pattern 7 ...
0
votes
1answer
79 views
Needs more jQuery! [on hold]
Inspired by this site, this question could potentially be a doozie. People on StackOverflow often overuse jQuery as an answer. Therefore, we need a way to recognize programmatically if a code snippet ...
31
votes
13answers
3k views
Universal Spooky Meme Translator
Introduction
Turns out, aliens love memes just as much as we do. Every alien race we've encountered so far has their own version of 2spooky4me (see the following question) and equivalent, though, ...
21
votes
27answers
4k views
What is the most frequent word?
What is the most frequent word?
Given a sentence, your program must make it's way through it, counting the frequencies of each word, then output the most used word. Because a sentence has no fixed ...
7
votes
1answer
147 views
Double run-length encoding
Everyone knows what run-length encoding is. It has been the subject of many code-golf challenges already. We'll be looking at a certain variation.
Example
Normal: ...
0
votes
0answers
55 views
Drawing the Number ASCIIuare [duplicate]
You have to write a function/program that will draw an ASCII art of a square made with numbers.
Challenge
This program will take one input n as a positive integer and draw a hollow square using this ...
17
votes
15answers
2k views
Counting in bijective base 62
The task is to generate all the strings from 'a' to '999' including upper case characters like so:
'a', 'b', 'c' ... 'y', 'z', 'A', 'B', 'C' ... 'Y', 'Z', '0', '1', 2' ...
'8', '9', 'aa', 'ab', 'ac' ...
7
votes
20answers
663 views
Briefest code to find vowels and print consonants
Challenge: Read a string from user, print number of each vowel, then place all remaining chars in a line. Shortest answer wins!
Output must look like this:
Enter String: Input
Vowel Count: ...
20
votes
16answers
2k views
+50
Golf Text into DNA
Text to DNA golf
Challenge
Convert input into a DNA output.
Algorithm
Convert text into ASCII code points (e.g. codegolf -> [99, 111, 100, 101, 103, 111, 108, 102])
String the ASCII codes ...
-19
votes
15answers
239 views
Reverse a 1-dimensional array
Note: This challenge is not the same.
Challenge
Believe it or not, we haven't got ONE challenge for reversing one-dimensional arrays (although we've got one for n-dimensional ones)! This should ...
1
vote
1answer
80 views
Scale up an image! [duplicate]
Your task is to write a program/function to scale up an image (list of strings) by a factor of n.
Specs
You will receive two inputs: an image, and a positive integer.
The image will only contain ...
24
votes
17answers
2k views
Is it a prefix code?
In information theory, a "prefix code" is a dictionary where none of the keys are a prefix of another. In other words, this means that none of the strings starts with any of the other.
For example, ...
0
votes
1answer
104 views
Random word-sentence-story generator
This question got me nostalgic: Build a word generator!
In the '80s I wrote a simple word generator in under 42kB (code and working memory) that would take a collection of strings and use them to ...
5
votes
1answer
134 views
Will it float?
The challenge
Given a 2d string representing the bottom of a boat as an input, you must determine whether or not the boat will float. This 2D string can be in whatever format is most convenient. ...
12
votes
13answers
740 views
Shortest Unique Substring
Given (on STDIN, as command line arguments, or as function arguments) two distinct non-empty strings, find and return the shortest substring of the first string which is not a substring of the second. ...
12
votes
6answers
668 views
How compatible are my strings?
Introduction
Consider two strings A and B of the same length L, and an integer K ≥ 0.
For the purposes of this challenge, we say that the strings are K-compatible, if there exists a string C of ...
5
votes
2answers
223 views
QWERTY Quine Creation
Challenge
Create a quine, that instead of outputting it's source, output's it's source QWERTY-sorted.
What is QWERTY sorting?
QWERTY sorting is sorting code by the QWERTY keyboard. Anything higher ...
17
votes
1answer
217 views
Symme-Try This Triangle Trial
A string whose length is a positive triangular number (1, 3, 6, 10, 15...) can be arranged into an "equilateral text triangle" by adding some spaces and newlines (and keeping it in the same reading ...
27
votes
27answers
3k views
Exploded substrings
Introduction
Let's observe the string abc. The substrings that can be made from this are:
a, ab, abc, b, bc, c
We now need to align them under the initial string, like this:
abc
a
b
c
ab
bc
...
16
votes
23answers
2k views
Generate a parity bit
A parity bit, is one of the simplest forms of a checksum. First, you have to pick the parity, even or odd. Let's say we pick even. Now, we need a message to transmit. Let's say our message is "Foo". ...
17
votes
18answers
793 views
Compute the histogram entropy estimation of a string
Write a program or function that estimates the Shannon entropy of a given string.
If a string has n characters, d distinct characters, xi is the i th distinct character, and P(xi) is the probability ...
5
votes
3answers
135 views
Taylor Series of a Function with Periodic Derivatives
Taylor series are a very useful tool in calculating values of analytic functions that cannot be expressed in terms of elementary functions, using only information about that function at a single ...
29
votes
30answers
5k views
Watson-Crick palindromes
Problem
Create a function that can determine whether or not an arbitrary DNA string is a Watson-Crick palindrome. The function will take a DNA string and output a true value if the string is a ...
11
votes
21answers
1k views
Convert a Forsyth-Edwards Notation string to ASCII art
In chess, Forsyth-Edwards Notation, more commonly called "FEN", is a textual way of transcribing boards. It describes each of the board's eight rows (called "ranks" in chess) from top to bottom from ...
6
votes
0answers
205 views
Which switches are on?
Introduction
You are sitting with your coworker, having lunch, and bragging to him/her about the latest and supposedly greatest project you've been working on. Getting sick and tired of your constant ...
10
votes
3answers
175 views
How many 14ers did I climb?
In mountaineering terminology, a "14er" is any mountain with an elevation of 14 000 feet or more. However, there is another distinction. For a peak to count as a 14er, it must also have a "geographic ...
8
votes
5answers
261 views
CamelCase2snake_case()
Write a function to convert CamelCased text to snake_case: FunctionForHTMLManipulation becomes function_for_html_manipulation
The input text will be a single suitable identifier in many languages. It ...
-9
votes
13answers
359 views
Substitution cipher
A substitution cipher is an encoding method where each letter in the alphabet is replaced with a fixed, different one; for example, given the following substitution map:
abcdefghijklmnopqrstuvwxyz
...
33
votes
24answers
3k views
Expand a C array
In the C programming language, arrays are defined like this:
int foo[] = {4, 8, 15, 16, 23, 42}; //Foo implicitly has a size of 6
The size of the array is inferred from the initializing ...
28
votes
25answers
1k views
Subsequence Substitution
Most languages come with a built-in to search a string for all occurrences of a given substring and replace those with another. I don't know of any language that generalises this concept to (not ...
23
votes
6answers
2k views
Concatenating Primes
Challenge:
You are given a string containing only digits. Your task is to output the minimum number of primes which must be concatenated to form the string. If this is impossible, output 0.
Test ...
-4
votes
26answers
513 views
Convert phrases to reverse style
The Challenge
Convert a phrase of two words to reverse style: candy bar -> bar le candy.
Specifications
There will be one word (only a-zA-Z0-9 + -), a space (), and then another word.
For ...
14
votes
2answers
243 views
Virtual Keyboard Text Input
On modern game consoles and other devices without traditional keyboards, trying to input text is a nightmare. Having to type with a few buttons and a joystick on a virtual keyboard is annoying, and I ...
18
votes
2answers
369 views
What's being surrounded
I've always wanted to surround some text with #s, but I have trouble figuring out what I surrounded so in this challenge you'll be writing a program to do just that
Examples
Input / Outputs are ...
11
votes
9answers
447 views
“Stair-ify” a string
You must write a program or function that creates a "stair-ified" string. Here is how you "stair-ify" a string:
For each character in the string:
If the character is an upper or lowercase vowel, ...
9
votes
8answers
496 views
Split string into n pieces (or pieces of length n)
The Challenge
In this challenge you have to do two different (but related) tasks depending of the order of the input.
Your program will recieve a string s and an integer n as input and will
split s ...
14
votes
6answers
293 views
Insert semi-sorted into unsorted array
Welcome to your first day at PPCG Inc. As our newest junior assistant document sorter, you are responsible for making sure all documents we sent down to you are archived in alphabetical order. It's so ...
7
votes
2answers
192 views
Is the path correct?
Is the path correct ?
Given a string, your program must determine whether or not Alice can reach Bob, following the signs on the map. You must return a truthy or falsy value.
The input string will ...
42
votes
10answers
4k views
De-Snakify a String
A regular string looks like this:
Hello,IAmAStringSnake!
And a string snake looks something like this:
Hel
l rin
o,IAmASt g
S
!ekan
Your Task
String snakes ...
25
votes
21answers
2k views
Find the first word starting with each letter
Given a string, find the first word starting with each letter (case insensitive).
Sample
Using Ferulas flourish in gorgeous gardens. as input:
"Ferulas flourish in gorgeous gardens."
^^^^^^^ ...
35
votes
9answers
3k views
Snakify a String
A snakified string looks like this:
T AnE eOf ifi ing
h s x l A k e r
isI amp Sna dSt
Your Task
Take a string s and a size n, then output the snakified string. The inputs ...
34
votes
18answers
3k views
Are the brackets fully matched?
You must write a program or function that takes a string of brackets and outputs whether or not that string is fully matched. Your program should print a truthy or falsy value, and IO can be in any ...
20
votes
9answers
1k views
Rectangle Detection
Write a program or function that takes in a multiline string of 0's and 1's. No other characters will be in the string and the string will always be rectangular (all lines will have same number of ...
27
votes
21answers
2k views
Palindromizing the strings
Introduction
For the ones who don't know, a palindrome is when a string is equal to the string backwards (with exception to interpunction, spaces, etc.). An example of a palindrome is:
abcdcba
If ...
41
votes
33answers
3k views
Stretch the word
The input is a word of lowercase letters not separated by whitespace. A newline at the end is optional.
The same word must be output in a modified version: For each character, double it the second ...
8
votes
7answers
573 views
Read a crossword
Inspired by this question about packing into this format.
Occasionally I see a completed crossword and being as I am, I can't be bothered to find out what the solutions to the clues actually were.
...
14
votes
7answers
769 views
Turn a string into a windmill
The code on this site is rapidly being depleted. We need to invest in renewable strings. So you must write a program that takes a string and converts it into a windmill.
The Challenge
Let's take a ...
7
votes
3answers
122 views
Ordering words to fit in a given string
Given a string of letters and a set of words, output an ordering of the words so
that they can be found in the string by dropping letters that are not needed.
Words may occur more than once in the ...
13
votes
10answers
629 views
Determine the type of an input
The challenge is simple: Determine the type of an input, and output an identifier telling what type it is.
"UI", Unsigned integer: 0, 1,34, 111111111111111111111111111111111111111111
"SI", Signed ...