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).
29 questions
1
vote
1
answer
9
views
Substitute patterns with values from lists
I was looking at a Stack Overflow question and got somewhat carried away with improving the solution, well beyond the scope of that question.
In summary, we have a string such as
...
4
votes
2
answers
347
views
HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets
(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 ...
5
votes
1
answer
529
views
A simple method for compressing white space in text (Java)
(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,
...
10
votes
3
answers
983
views
Checking for string isomorphism in C++
Intro
This snippet is a translation of the Java version.
Code
string_util.hpp:
...
2
votes
0
answers
60
views
Funny time with DNA: a \$k\$-mer index data structure in Java, Take II
(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, ...
5
votes
1
answer
340
views
Multiplying two large numbers whose digits you have in a string, in AEC compiled to WebAssembly
You can see it live here: https://flatassembler.github.io/multiplying-strings-aec.html
...
9
votes
2
answers
1k
views
A simple C++ function converting the environment variables in main() to an unordered_map
I had this program:
...
5
votes
1
answer
401
views
Converting a char string to wchar_t string based on a given toWideStr() starting point
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, ...
5
votes
2
answers
591
views
A View over java.lang.String
(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:
...
4
votes
2
answers
506
views
Z-Function/ Algorithms on strings. C++
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 ...
1
vote
2
answers
120
views
Advent of Code 2023 - Day 15: Lens Library
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 ...
1
vote
1
answer
78
views
Advent of Code 2023 - Day 8: Haunted Wasteland (Part 1)
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/...
2
votes
1
answer
145
views
Advent of Code 2023 - Day 5: If You Give A Seed A Fertilizer (Part 1)
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.
...
6
votes
2
answers
249
views
Advent of Code 2023 day 1: Trebuchet (Part 1 and 2) Follow-up
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 ...
4
votes
2
answers
357
views
LKM: Extract cpu model name from /proc/cpuinfo
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 ...