Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 60042

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

40 votes
58 answers
4k views

Reverse a string by chunks

Your task is to write a program which, given a number and a string, splits the string into chunks of that size and reverses them. … The string should then be split into chunks of length n, if the length of the string isn't divisible by n any leftover at the end should be considered its own chunk. …
55 votes
63 answers
8k views

Is this string a square?

A string is considered to be square if the following conditions are met: Each line has the same number of characters The number of characters on each line is equal to the number of lines. … Input is a string or 1D char array; it is not a list of strings. You may assume input is non-empty and only contains printable ASCII, including spaces. …
22 votes
22 answers
3k views

Carve a square from a string

Your challenge today is to take a multiline string, and output the biggest square contained within the string that includes the top left corner. … Input is a string or 1D char array; it is not a list of strings. …
11 votes
2 answers
571 views

Shell Glob Golfing

Your task: Given a string array of paths that represent the "current directory" and a single target path, output the shortest possible string that would expand to only that target path after expanding … The target path can be taken as it's own string, as an index into the array of paths, as the first item on the array of paths passed in, or some other convenient way that isn't hard-coding. …
23 votes
25 answers
3k views

Sort a string by a given ordering

Your challenge is to sort a string, but rather than by the normal alphabetical order (abc..xyz), you will be sorting strings by a specified alphabet. … You must write a program or function that takes two inputs: An alphabet A and an string S. Both will only contain lowercase English letters, and both will contain at least one character. …
1 vote

Reverse a string by chunks

APL (Dyalog Classic), 22 bytes {0~⍨∊⊖(⌈⍺÷⍨≢⍵)⍺⍴⍵,⍺⍴0} Try it online!
Pavel's user avatar
  • 9,397
3 votes

Reverse a string by chunks

The /g modifier gives us every match of that regex in the input string as a list, which is then reversed and printed. In Perl, passing a list to say joins it without any delimiter by default. …
Pavel's user avatar
  • 9,397
24 votes
3 answers
2k views

Balance the Brackets

Your objective: Given a string of brackets, output the minimum Damerau-Levenshtein Distance required to turn the input string into a string where the brackets are balanced. … Output The output should be the minimum Damerau-Levenshtein Distance between the input string and a string in which the brackets are matched. …
1 vote

"Hello, World!"

>, ICallable { public H(IOperationFactory m) : base(m) { } String ICallable.Name => "H"; String ICallable.FullName => "qsharp.H"; public override Func<QVoid, String> Body => (_ … ; } ; public override void Init() { } public override IApplyData __dataIn(QVoid data) => data; public override IApplyData __dataOut(String data) => new QTuple<String>(data …
Pavel's user avatar
  • 9,397
2 votes

Make a Word Icicle

C# (Visual C# Interactive Compiler), 129 bytes var s=ReadLine();while(s.Any(c=>c!=32)){WriteLine(s);var i=s.IndexOf(s.Min(c=>c==32?(char)999:c));s=s.Remove(i,1).Insert(i," ");} Try it online!
Pavel's user avatar
  • 9,397
3 votes

What's the file extension?

C# (Visual C# Interactive Compiler), 22 bytes s=>s.Split('.').Last() Implicit using System.Linq; FTW! Try it online!
Pavel's user avatar
  • 9,397
2 votes

Fill in the Blanks, Please!

.*/]} Uses -p The first line is the format string, the rest of the lines are the array. Try it online! …
Pavel's user avatar
  • 9,397
3 votes

Uncomment a COBOL program!

Ruby, 39 38 36 29 23 22 20 + 1 = 21 bytes $_[/.{6}( |.* )/]='' Try it online! Uses -p flag. Explanation: The -p flag adds an implicit block around the code, so the code that actually gets run …
Pavel's user avatar
  • 9,397
0 votes

Check If my String is Prime

C# (.NET Core), 60 bytes s=>s.All(i=>Enumerable.Range(2,(int)i-2).All(j=>((int)i)%j))
Pavel's user avatar
  • 9,397
2 votes

Multiply a string by a number!

Ruby, 59 +1 = 60 bytes Uses -n flag. n=eval$_ a=$<.read a.reverse!if n<0 a.chars{|i|$><<i*n.abs} Try it online!
Pavel's user avatar
  • 9,397

15 30 50 per page