Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [string-processing]

Use this tag when the presented code focuses on string manipulations (such as concatenation, splitting, and extracting parts of a string) or on analyzing and manipulating the contents of strings (e.g., searching, matching against a pattern, and encoding / decoding).

Filter by
Sorted by
Tagged with
2 votes
1 answer
116 views

Intro (This is the continuation of HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets.) (See the GitHub repository.) This time: I have fixed the misspelled ...
coderodde's user avatar
  • 32.2k
4 votes
2 answers
341 views

(See the continuation of this post at HuffmanEncoder.java - computing prefix codes for arbitrary (generic) alphabets - Take II.) I have this Java implementation of the Huffmann encoding. It looks like ...
coderodde's user avatar
  • 32.2k
4 votes
3 answers
469 views

Intro In this post, I will elaborate on A simple method for compressing white space in text (Java). Here, I have incorporated some advice offered by Chris. Also, this version preserves a single new ...
coderodde's user avatar
  • 32.2k
5 votes
1 answer
525 views

(The story continues in A simple method for compressing white space in text (Java) - Take II.) Intro Now I have that text space compressor. For example, ...
coderodde's user avatar
  • 32.2k
2 votes
2 answers
106 views

Intro I call two \$n\$-strings \$s\$ and \$z\$ over the alphabet \$\Sigma\$ weakly isomorphic if their character frequency multisets are equal. In other words, for an input strings \$s\$, we derive a ...
coderodde's user avatar
  • 32.2k
10 votes
3 answers
959 views

Intro This snippet is a translation of the Java version. Code string_util.hpp: ...
coderodde's user avatar
  • 32.2k
4 votes
1 answer
168 views

Intro Two \$n\$-strings \$s = \langle s_1 \ldots s_n \rangle \$ and \$z = \langle z_z \ldots z_n \rangle\$ are considered isomorphic if and only if there exists a bijection \$f\$ such that for all \$...
coderodde's user avatar
  • 32.2k
2 votes
0 answers
60 views

(See the previous and initial iteration.) Intro This time, I decided to pack the genomic data such that 4 nucleotide bases are encoded into a single byte. In other words, ...
coderodde's user avatar
  • 32.2k
4 votes
1 answer
106 views

(See the next iteration.) This time I have programmed a simple data structure called \$k\$-mer index. The actual word \$k\$-mer is a synonym of substring of length \$k\$. This data structure is built ...
coderodde's user avatar
  • 32.2k
5 votes
1 answer
340 views

You can see it live here: https://flatassembler.github.io/multiplying-strings-aec.html ...
FlatAssembler's user avatar
5 votes
2 answers
110 views

I created a Python 3.11 utility that truncates an input string to a fixed word count—splitting on any whitespace, collapsing runs, and dropping trailing stop-words—so you get clean, concise snippets ...
Bob's user avatar
  • 221
5 votes
2 answers
179 views

Lately I came across a book exercise that asked to implement a calculator by resorting only to std::string manipulation. I avoided C++ streams as well, as they are ...
Giogre's user avatar
  • 515
5 votes
1 answer
399 views

I'm working on a legacy code base and I came across a method in which I wanted to remove the chance of swallowing an exception. In the following I want to walk you through the refacoring process, ...
Thomas Weller's user avatar
4 votes
2 answers
346 views

(This post elaborates on A string view over a Java String.) This time, I have incorporated both the great answers in the previous iteration: https://codereview.stackexchange.com/a/293506/58360 by ...
coderodde's user avatar
  • 32.2k
5 votes
2 answers
591 views

(This post has continuation at A string view over a Java String - improved take II.) This time, I have a simple string view class for faster operation on substrings in actual string objects: ...
coderodde's user avatar
  • 32.2k
3 votes
2 answers
356 views

Problem For some user-facing string, I want to truncate it to some given maximum length (also useful for file name/path lengths on Windows etc.). However, I want to do it a little more elaborately ...
rklec's user avatar
  • 163
4 votes
2 answers
506 views

The problem: Given a string s. For each i from 1 to |s|, find the number of occurrences of its prefix of length i in the string. Input: The first line of input contains an integer q (1≤q≤10⁵) — the ...
neely's user avatar
  • 43
0 votes
2 answers
164 views

Description: The task involves processing a set of workflows, each comprising rules. These rules define conditions based on part ratings and dictate the destination workflow if the conditions are ...
Madagascar's user avatar
  • 10.1k
1 vote
2 answers
120 views

Part 1: The task involves initializing the Lava Production Facility using an initialization sequence. The sequence consists of steps, each requiring the application of the Holiday ASCII String Helper ...
Madagascar's user avatar
  • 10.1k
1 vote
1 answer
78 views

Part 1: The task involves analyzing an environmental report from an oasis using the Oasis And Sand Instability Sensor (OASIS). The report consists of multiple histories, each containing a sequence of ...
Madagascar's user avatar
  • 10.1k
1 vote
1 answer
78 views

Description: The task involves navigating a haunted wasteland on a desert island using a camel. The objective is to escape from the current position (AAA) to the destination (ZZZ) by following left/...
Madagascar's user avatar
  • 10.1k
5 votes
1 answer
133 views

Part One: The task involves organizing multiple toy boat races, each assigned a specific race time and a recorded distance. To surpass the existing record, participants must optimize the duration of ...
Madagascar's user avatar
  • 10.1k
2 votes
1 answer
145 views

The task involves determining the lowest location number corresponding to a given set of seeds by following numerical mappings for soil, fertilizer, water, light, temperature, humidity, and location. ...
Madagascar's user avatar
  • 10.1k
4 votes
2 answers
194 views

Part 1: The task involves determining the total points of a set of scratchcards. Each scratchcard contains two lists of numbers: the winning numbers and the numbers the player has. Points are awarded ...
Madagascar's user avatar
  • 10.1k
6 votes
2 answers
249 views

This is a follow-up to the question asked here: Advent of Code 2023 day 1: Trebuchet (Part 1 and 2) Changes made: The code no longer assumes that all lines will fit into a fixed-size buffer. Although ...
Madagascar's user avatar
  • 10.1k
1 vote
2 answers
668 views

I've written a python function to split a netmask or an ip address. The code is about to become part of a custom router api. ...
Looser User's user avatar
4 votes
2 answers
357 views

I wrote a small LKM that opens the /proc/cpuinfo file, reads it line by line, and attempts to the cpu model name. If the function fails to extract the cpu model ...
766F6964's user avatar
  • 901