Skip to main content

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).

9votes
2answers
917views

A simple C++ function converting the environment variables in main() to an unordered_map

I had this program: ...
coderodde's user avatar
5votes
2answers
144views

C++ arithmetic calculator built without resorting to tree structure as conventionally done, but by parsing input string and then std::stoi

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
5votes
1answer
288views

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, ...
Thomas Weller's user avatar
4votes
2answers
310views

A View over java.lang.String - improved take II

(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
5votes
2answers
553views

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: ...
coderodde's user avatar
3votes
2answers
257views

Truncating/abbreviating strings in the middle with an ellipsis (…) (or other) separators with a fixed character limit

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
4votes
2answers
485views

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 ...
neely's user avatar
0votes
2answers
124views

Advent of Code 2023 - Day 19: Aplenty (Part 1)

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
1vote
2answers
79views

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 ...
Madagascar's user avatar
1vote
1answer
57views

Advent of Code 2023 - Day 9: Mirage Maintenance

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
1vote
1answer
61views

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/...
Madagascar's user avatar
4votes
1answer
109views

Advent of Code 2023 - Day 6: Wait For It

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
2votes
1answer
136views

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. ...
Madagascar's user avatar
4votes
2answers
171views

Advent of Code 2023 - Day 4: Scratchcards

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
6votes
2answers
226views

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 ...
Madagascar's user avatar

153050per page
close