Questions tagged [string]

A competition to solve a particular problem through the usage and manipulation of strings.

Filter by
Sorted by
Tagged with
19
votes
6answers
627 views

Local periods of strings

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 ...
26
votes
8answers
1k views

Collapse the antistring

In this challenge you will be given an alphabetic string as input. We will define the "anti-string" of a given input to be the string with the case of all the letters inverted. For example ...
70
votes
112answers
15k views

Print the alphabet without using each vowel

Inspiration: in 1939, a man named Ernest Vincent Wright wrote a novel called Gadsby without using the letter 'e'. Your task is to write a set of (up to 5) programs in any language (which has a text-...
10
votes
57answers
2k views

Print last inputted byte

Challenge You have one string of input bytes, output the last byte in it. Rules Your submission may be a program or function outputting the last byte in the input which is either a string, stdin ...
119
votes
181answers
29k views

Sing Happy Birthday to your favourite programming language

Your favourite programming language has just had a birthday. Be nice and sing it the Happy Birthday song. Of course you should accomplish this by writing a program in that language. The program takes ...
42
votes
14answers
2k views

No strings attached!

Intro There are 3 nails in the wall. You've got a piece of string that is fixed to the picture frame with both ends. To hang the picture, you entangled the string with the nails. But before letting ...
24
votes
64answers
9k views

!I!n!s!e!r!t! !n!b!e!t!w!e!e!n!

Posted from here. This challenge is highly "distilled" from this question. Special thanks to @Akababa! In this task, you should insert an exclamation mark at the start of the string and after every ...
44
votes
129answers
5k views

Full Width Text

Full width text is text that has a space after every character, including the last one. For instance, the first sentence of this question becomes: ...
26
votes
53answers
4k views

Alphabet to Number and Number to Alphabet

Challenge In this challenge you have to take a number as input and output the corresponding letter of the alphabet, and vice versa. (1 <=> A, 2 <=> B) etc. ...
69
votes
54answers
13k views

War is peace. Freedom is slavery. Ignorance is strength

As George Orwell wrote in 1984: War is peaceFreedom is slaveryIgnorance is strength Write a program or function that takes in one of the six main words from the Orwell quote and outputs its ...
175
votes
27answers
20k views

Do you want to code a snowman?

Here is a simple ASCII art snowman: _===_ (.,.) ( : ) ( : ) Let's make him some friends. This will be the general pattern for our ASCII art snowpeople: ...
4
votes
1answer
112 views

Wrong keyboard position [duplicate]

You are in fact writing an interpreter for the language "Wrong keyboard position". You can pretend that you are not doing this and just follow the instructions below. I typr re;atively accuratrly, ...
56
votes
117answers
11k views

“DDoouubbllee ssppeeaakk!!”

Super simple challenge today, or is it? I feel like we've heard a fair bit about double speak recently, well let's define it in a codable way... Double speak is when each and every character in a ...
415
votes
754answers
124k views

“Hello, World!”

So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
21
votes
35answers
1k views

All the k-mers/n-grams

Intro We have had histograms and counting, but not listing all of them. Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. This is a language ...
46
votes
77answers
7k views

Answer to life, the universe, and everything

Task Given a String as input, your task is to output 42 only if the input String happens to be exactly the following : ...
22
votes
22answers
2k views

Overlapping String-Blocks

Challenge: Given a list of multi-line strings, overlap them (in the top-left) and output the result. Example: Input: ["aaaa\naaaa\naaaa\naaaa","bb\nbb\nbb","c"] ...
79
votes
128answers
22k views

The shortest code to invert bit-wise a binary string

Me thinks there aren't enough easy questions on here that beginners can attempt! The challenge: Given a random input string of 1's and 0's such as: ...
148
votes
261answers
39k views

1, 2, Fizz, 4, Buzz

Introduction In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other ...
24
votes
38answers
2k views

Calculate average characters of string

Task Your task is to produce string that contains average characters of string. First character of result would be average character of first character (which is first character) and second character ...
54
votes
24answers
6k views

Significant Whitespace

We define whitespace to be any of the three characters, tab (0x09), newline (0x0A) or space (0x20). For this challenge, you're to write two programs or functions in the same programming language, ...
24
votes
26answers
2k views

Surround a string with hashes

I've already made this in Python, but it seems that it could be shortened a lot: ...
27
votes
83answers
3k views

Generate alphabet with 4 copies of each letter

Note that this is not the same as Print the alphabet four times. This task is to write a program to generate four copies of each letter of the English alphabet, one letter per line, on standard ...
28
votes
19answers
2k views

Rotate a column

Given an integer k and either a block of text, or a 2d array that the inner arrays may have unequal lengths (that resembles a block of text), rotate every character or element in the k-th column up or ...
49
votes
65answers
5k views

Output the alphabet, the ALPHABET, or just a character

The challenge is simple: Write a function or program that takes an input x, and outputs the lower case alphabet if x is part of ...
64
votes
40answers
9k views

Uncomment a COBOL program!

COBOL is a very old language, at the time of writing it is 58 years old. It is so old, in fact, that it has a very interesting quirk: the first six characters of each line are comments. Why is this, ...
41
votes
28answers
3k views

Marquee sign letters

Each day you put up a new word on a marquee sign with movable letters, buying just the letters you need to write it. You re-use letters you've bought for earlier words whenever possible. Given the ...
31
votes
43answers
3k views

Slowly turn a string into another

The Challenge Given two strings/an array of strings, output the first string slowly shrinking and expanding back into the second string. You can assume the strings will always start with the same ...
2
votes
11answers
695 views

Hello… eh, who?

Introduction You started to write a "Hello, World!" program, but after you wrote the part to print the hello, you forgot what your program should actually print. So now, you somehow managed it to ...
84
votes
74answers
22k views

It took me a lot of time to make this, pls like. (YouTube Comments #1)

Hold up..... this isn't trolling. Background These days on YouTube, comment sections are littered with such patterns: ...
74
votes
37answers
12k views

Non-discriminating Programming

We say a string is non-discriminating if each of the string's characters appears the same number of times and at least twice. Examples "aa!1 1 !a !1" is non-...
26
votes
29answers
3k views

Output with the same length always

With challenges like Output with the same length as the code and Create output twice the length of the code, I thought of a separate, but similar challenge. The task is to produce an output. It can ...
24
votes
1answer
1k views

Auto BATCH golfer

I love BATCH, despite its shocking lack of functional commands, despite even due to its lack of non-integer support. Why? Because this works: SET var=SET %var% i=0 ...
93
votes
83answers
9k views

Unique is Cheap

Write a function or program that determines the cost of a given string, where the cost of each character equals the number of how many times the character has occurred up to this point in the string,...
54
votes
37answers
6k views

Make some Alphabet Rain

Alphabet Rain The Task: The basic premise is to print out the input string and then repeat each character vertically, based on it's (0-indexed) position in the (case-insensitive) alphabet ...
96
votes
54answers
13k views

Make a “Ceeeeeeee” program

Once I wrote a JavaScript program that would take as input a string and a character and would remove all characters except for the first one and the character given as input, one by one. For example, ...
38
votes
45answers
6k views

Every word from babab to zyzyz

Your task is to write a program that will output a readable list of every five letter words with the structure: consonant - vowel - consonant - vowel - consonant The output should be sorted ...
19
votes
50answers
3k views

String to Binary

This is a code golf challenge. Just like the title says, write a program to covert a string of ascii characters into binary. For example: "Hello World!" should ...
71
votes
142answers
15k views

“99 Bottles of Beer”

Write a program that outputs the lyrics to 99 Bottles of Beer, in as few bytes as possible. Lyrics: ...
41
votes
86answers
7k views

Halloween Golf: The 2spooky4me Challenge!

A current internet meme is to type 2spooky4me, with a second person typing 3spooky5me, following the (n)spooky(n+2)me pattern. Your mission is to implement this ...
27
votes
56answers
6k views

Convert a string of binary characters to the ASCII equivalents

Take a string of binary characters separated by a space, and convert it to an ASCII string. For example... ...
36
votes
17answers
6k views

Count to 100 in Danish

Print all the numbers from 0-100 in the right order using the Danish way of counting How they count Like English, they have dedicated words for 0-20, 30, 40 and 100 Instead of saying ...
55
votes
24answers
5k views

Make a Bowl of Alphabet Soup

This is what we'll call a bowl of alphabet soup - a roughly circular ascii-art shape with the 26 uppercase English letters (A-Z) arranged clockwise to form the perimeter: ...
11
votes
13answers
2k views

Normalized Malbolge to Malbolge translator

In this task, you will write a program/function that takes a Normalized Malbolge program and outputs the resulting Malbolge program. (This is a secret tool that all Malbolge programmers are using!) ...
92
votes
33answers
6k views

Would this string work as string?

Write a program that takes a single line string that you can assume will only contain the characters /\_‾. (That's forward and backward slash, underline and ...
19
votes
13answers
4k views

“Hello world” that creates a different “Hello world” program

Create a program, that outputs a hello world string ("Hello world", "Hello, World" etc.), and source code. Output is written to stdout or equivalent. Hello world string is embedded in the source code. ...
3
votes
0answers
123 views

Golfed “User-pinging” [closed]

In this task, given a user's display name(e.g. Display Name) from which the first space has been removed, use the Code Golf & Coding Challenges' Stack Exchange API to find a user it could be and ...
45
votes
71answers
9k views

Is it double speak?

In an earlier challenge I asked code golfers to produce strings which copy each character in a string. For example: TThhiiss iiss ddoouubbllee ssppeeaakk!! ...
82
votes
40answers
13k views

What my dog really hears

My dog is called Rex. Every time I scold him, he seems not very impressed and the only times I see him react is when I pronounce his name. If I say ...
20
votes
49answers
3k views

Run Length Decoding

Write the shortest code in the language of your choice to perform run length decoding of the given string. The string will be supplied as input on stdin in the form ...