Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [strings]

A string is a sequence of characters. It is commonly used to represent text or a sequence of bytes. Use this tag along with the appropriate programming language being used.

2
votes
0answers
28 views

Find out whether a given text contains any of the prohibited words

We have been given a list of strings which are blacklisted. The goal is to identify if a given text contains any of these blacklisted strings. The restriction here is that the blacklisted string needs ...
6
votes
3answers
169 views

Function to return subword of a camelcase string

Given a camelcase string and an index, return the subword of the string that includes that index, e.g.: ...
2
votes
1answer
44 views

Transforming full names to surname and initial

I have a large data frame that I want to merge with another dataset. In order to do so I need to get the names of individuals into a certain format. The function below converts the name in 'column' to ...
2
votes
0answers
18 views

vb.net Create textfile from template

What is the best approach for creating textfiles from/with a template ? Currently I just read the template from a textfile and Replace all values needed, but I don't think that this is the most solid ...
3
votes
1answer
40 views

Counting vowels and consonants in a string

The output should display as follows... ...
2
votes
2answers
35 views

I/O-TxtFile Line Distance Program

I am trying to write a lab/program that loops through a .txt input file. Reads an entire line of data as a string, then splits that string into an array delimited by a space. If there are 4 items in ...
2
votes
1answer
47 views

Program finds the first almost matching string in a list - Advent Of Code 2018 Day 2 Part 2

Advent of Code 2018, day 2, part 2: The [two IDs you are looking for] differ by exactly one character at the same position in both strings. For example, given the following IDs: ...
4
votes
2answers
70 views

Count characters in a string

This code is supposed to count each character in a given string and account for error handling and type casting as well, and it should do it in the most efficient manner possible, with O(n) being an ...
0
votes
1answer
23 views

find if one string is a valid anagram of another , in scala

Question is taken from leet code. Problem Given two strings s and t , write a function to determine if t is an anagram of s. Examples ...
1
vote
1answer
23 views

Longest Substring Without Repeating Characters in Scala

Question is taken from Leetcode and solution works for their test cases. I do see a scope of improvement and make it more functional (getting rid of vars and mutables data structures). Please suggest ...
1
vote
1answer
50 views

Replacing words with their abbreviations - Follow up

This is the follow up for a question you can find here: replacing words with their abbreviations The goal here is to compare two petential way of answering said question that was: This particular ...
2
votes
2answers
87 views

Substrings search (Aho-Corasick algorithm)

I have a code where the goal is to give score to strings based on how much score certain substrings are worth (including repeating substrings). The way my code (which is based on the Aho-Corasick ...
3
votes
2answers
76 views

Function to add two binary numbers in C

I tried to write a function bin_add() in C to add two positive binary numbers represented as zero terminated strings: ...
2
votes
1answer
56 views

Mad Libs excercise

I did the following Excercise from Automate the boring stuff with Python Chapter 8: Create a Mad Libs program that reads in text files and lets the user add their own text anywhere the word ...
1
vote
2answers
75 views

replacing words with their abbreviations

I'm working on a program that aim to take sentences (currently in french) and compact them to a length of 38 characters while retaining as much information as possible. You can find another part of ...
4
votes
1answer
82 views

Remove determiners in a string

I'm working on a program that aim to take sentences (currently in french) and compact them to a length of 38 characters while retaining as much information as possible. You can find another part of ...
0
votes
1answer
59 views

Parsing messages with fixed-width fields into Employee objects

I'm writing a application that reads from a queue of messages from a legacy mainframe system. Some characteristics of message in the queue: Message from the Q is always fixed length plain text : 64 ...
1
vote
1answer
46 views

Shortening words within a string

The function receives a string containing a sentence. Its goal is to shorten every word in it to a length of 4 characters until the string is shorter than 38 characters and return. The 38 ...
15
votes
2answers
723 views

Enforcing string validity with the C# type system

One of my biggest complaints about .NET is that there's no way to guarantee a string match a certain type in the type-system. Note This started as more of a proof-of-concept than a real usable ...
1
vote
3answers
58 views

Portably get one character from standard input using standard library only

While translating an old Basic game to C, I found myself needing a function to get one character from the keyboard. You can't do this with common standard C library functions like ...
3
votes
1answer
33 views

Table Printer excercise

I'm new to Python and I came to the following excercise: Write a function named printTable() that takes a list of lists of strings and displays it in a well-organized table with each column ...
2
votes
1answer
46 views

Map Character to Characters Most Frequently Found With it (in list of strings)

For an interview, I was tasked with writing a program that consumes a list of strings, and produces a mapping between every character in the list, and the characters found most frequently with it (let'...
5
votes
1answer
41 views

Repeated Strings Hacker Rank challenge

I'm doing a hacker rank challenge with this one called "Repeated String". I attempted this challenge in my weaker language java. The goal is to print out the occurrences of the letter a. First you're ...
0
votes
1answer
42 views

Return the first word with the greatest number of repeated letters

I'm learning JavaScript and have written a function that accepts a string and returns the first word with the greatest number of repeated letters. For example: Input:"Hello apple pie" - Output:"Hello"...
2
votes
1answer
92 views

Report on user-input chacters by their type

I'm a first year student at a college that focuses heavily on self learning (SCRUM) without any classical lessons. Because of this, I basically learned everything I know from websites like this. I don'...
1
vote
3answers
82 views

Generate all possible permutations of a string in C++

This is my version of the possible permutations of a string challenge. Please give me feedback or criticism. There are two vectors here: positions and ...
1
vote
1answer
46 views

Recursive trim() function to handle arrays and objects

I have come up with a recursive function which applies trim() recursively to all string members of an array/object. I don't have any specific quandaries about my ...
1
vote
3answers
225 views

Password generator in Python 3.7

I am learning how to code in Python by myself and have never coded before, I just want to know if there is any way I can upgrade my PasswordGenerator. ...
2
votes
2answers
54 views

New password generation

...
1
vote
1answer
42 views

K&R Exercise 1-22. Fold (break) lines at specified column

Intro I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it: learn (outdated) C and practice problem-solving at the same time. I believe that the author's ...
4
votes
1answer
22 views

Compare two strings in extended memory - classic 8052

I'm looking for a simpler code that isn't resource hungry that can compare two strings stored in different locations in the extended memory of a classic 8052 (namely the AT89S52 microcontroller) to ...
5
votes
1answer
100 views

K&R Exercise 1-21. Write a program `entab` that replaces strings of blanks with tabs

Intro I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it: learn (outdated) C and practice problem-solving at the same time. I believe that the author's ...
1
vote
0answers
14 views

Swapping variable length strings asynchronously with connected microcontroller (Byte-banging)

I have an AT89S52 and an AT89C4051 microcontroller (both in the 8052 family) in which the bit lines of the data bus, one control pin and one status pin are connected together. In code, the data bus is ...
1
vote
0answers
31 views

Mixed Duo String Generator Part 2

Mixed Duo String Generator Hello again; Previously my code was critique and I applied this feedback to form my new revised code for the Mixed Duo String Generator. In the code below I revised it to ...
3
votes
0answers
34 views

Finding differences in strings with Levenshtein distance and soundex

I am trying to find a way to optimize the code runtime. Improvements I have implemented include using dictionaries, removing redundancies and using str.translate. <...
2
votes
4answers
113 views

Split a string into a list of tokens

I have the following assignment that I succeeded in solving, but the code is very inefficient. I would appreciate if someone could show me a more efficient way, perhaps with substring. Note that I am ...
1
vote
3answers
64 views

Mixed Duo String Generator 2 [duplicate]

I've create a program that finds mixed duo within a string. It removes characters from a string that do not form the first mixed duo. It does not rearrange the order of the string, it ony remove ...
3
votes
2answers
76 views

Mixed Duo String Generator

I've create a program that finds mixed duo within a string. It removes characters from a string that do not form the first mixed duo. It does not rearrange the order of the string, it ony remove ...
1
vote
2answers
75 views

Balanced parenthesis, with backslash escaping

Given a Balanced Parenthesis problem. "Balanced Parenthesis Create a program that checks if in a given string expression all the parenthesis are balanced. For Example: (test) - valid ...
3
votes
1answer
62 views

Detect whether a string has a letter 'b' 3 characters after 'a'

I'm relatively new to JavaScript and wonder whether my code is 'acceptable' for a practice exercise. Essentially, the function (successfully) returns true or false if the provided string has a letter '...
5
votes
1answer
84 views

K&R Exercise 1-18. Remove trailing blanks and tabs from each line

Intro I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it: learn (outdated) C and practice problem-solving at the same time. I believe that the author's ...
3
votes
1answer
63 views

Find the first non-recurring character in string

I wrote a solution to first-unique-character-in-a-string: Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1. If there is better way ...
3
votes
1answer
51 views

htmlspecialchars() equivalent in C

I'm trying to write an equivalent of PHP's htmlspecialchars() in C. What is my implementation missing or doing wrong? ...
3
votes
3answers
253 views

Simple puts() function in x64 assembly

I'm trying to write as simple I/O library in x64 using linux syscalls ...
2
votes
2answers
42 views

Longest substring with 2 unique characters in a given string at linear time

This is my java implementation based on the solution of Aasmund Eldhuset here. Please give your opinion on my code (correctness, efficiency and coding conventions): ...
2
votes
3answers
117 views

C++ split function (equivalent to python string.split())

I wrote the equivalent to the split() in python for C++. I would like to know how I can make it better: ...
1
vote
1answer
39 views

Convert a type u16 number to a matrix (Vec<Vec<u8>> or array) of 4 x 4

I am a Rust newbie and I am not familiar with all the iterator options. This is what I have so far. How can I make this better or at least avoid collecting twice into a Vec? ...
5
votes
2answers
59 views

Computing word-frequency-table

I got a word count assignment and the requirements are shown below: INPUT The input contains words in several lines and in each line there could be more than one word. The input only ...
4
votes
3answers
557 views

Fancy padding of wide strings

I have a function that adds to a std::wstring some filler characters. The user gives a single filler character. They can also optionally given an initial filler ...