Stack Exchange Network

Stack Exchange network consists of 175 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.

3
votes
1answer
27 views

CareerCup (Bloomberg): Check if string is valid based on brackets

The goal of this problem is to determine if a string with brackets is valid. Below is a summary of the question from careercup. Check if string s is valid based on brackets ...
10
votes
3answers
599 views

Explicit song lyrics checker

To stay in practice with my Python I've decided to write an explicit song checker. It checks each word in the song against an array of 14 explicit words contained in the text file. I've decided not to ...
2
votes
1answer
46 views

Coding Challenge: Return The Smaller String

A coding challenge in which we are to write a function that compares two strings and returns the one that is smaller. The comparison is both lexicographical and numerical, depending on the content of ...
3
votes
2answers
65 views

RegEx version control

this is my first time on this stack exchange :) I created a little script to check for the latest version of specified API version available, but I am wondering if I am using the best way possible ...
3
votes
1answer
63 views

Find the longest word in a string

I have written code in the language Go. I wonder if anyone can do it in a very simple and effective way, because every language has its own way to solve this problem. My experience is in JavaScript. ...
3
votes
5answers
7k views

Replace sequence of strings in binary file

I have searched for method to find and replace strings sequence in binary files without any luck. The main requirement was that method should not load all file in memory but rather use chunks. I am ...
6
votes
3answers
3k views

Replacing each string of one or more blanks by a single blank

K&R 1.9 exercise: Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank. Is this correct and proper code? Could I have put ...
-2
votes
0answers
18 views

NZEC runtime error in The Next Palindrome problem on SPOJ using JAVA [closed]

So I have just started to solve some problems on SPOJ. I am stuck on the The Next Palindrome problem. I get the desired output on IDE but end up with NZEC on SPOJ. Problem statement A positive ...
4
votes
1answer
965 views

Find longest common string subsequence

The task (also found at https://www.youtube.com/watch?v=10WnvBk9sZc): Write a function that takes two strings, s1 and s2, and returns the longest common subsequence of s1 and s2. "ABAZDC", "...
3
votes
1answer
158 views

Zig-zag function - coded solution

Here is my coded solution to the LeetCode zig-zag problem - The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this (you ...
9
votes
2answers
846 views

The veiled guise of binary and string

Challenge Conceal a binary code within a word. Specifications The first argument is a path to a file. The file contains multiple lines. Each line is a test case represented by a space separated ...
2
votes
2answers
57 views

Keep ABC size down for conditional string concatenation in Ruby

This method takes a comment object and displays it correctly depending on what columns are available. EVENT_TEXT and REASON_TEXT ...
4
votes
0answers
50 views

Palindrome insertion challenge

Here is my solution to the following Daily Coding Problem challenge Given a string, find the palindrome that can be made by inserting the fewest number of characters as possible anywhere in the ...
2
votes
1answer
77 views

Find String white spaces indices

This function return all white spaces indices as an array of Integer , and it's work just fine with small string : ...
2
votes
1answer
75 views

Determine whether a word appears in a sentence

Given an array of words representing a sentence and a word to search for, the method must determine whether the word appears in the sentence. Specifications Case insensitive. The arguments are never ...
6
votes
2answers
664 views

First attempt at dealing with command-line args

A little while ago I was fiddling with dependency-injection and came up with this small WPF application that I can launch with command-line arguments. Not only this was my first experiment with DI, ...
2
votes
1answer
98 views

Simple program to hide messages in files (steganography)

That is a simple program to hide text messages in text files. I'd like to hear any advices to improve my code and style. Some notes: There is no error handling to simplify the program. It is not a «...
6
votes
4answers
720 views

Return a String containing only alphabets without spaces

Scenario: Return a String that contains only alphabets without spaces. input = "A man, a plan, a canal: Panama" output = "AmanaplanacanalPanama" Can you please critique my code? ...
3
votes
0answers
32 views

SHA256 implemented in Rust

I just finished making an implementation of a SHA256 hashing function (https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf) in Rust and I was looking for some feedback. As far as I can tell it ...
-4
votes
0answers
26 views
4
votes
2answers
2k views

Spell Checker program using dictionary implementation

This is a small program written for a small assignment to check spelling. The assignment asks for the following output: A list of words that are misspelled in the file A count of the ...
7
votes
4answers
2k views

String compression by using repeated characters count

My task was to perform a basic string compression by replacing consecutive repeated characters by one instance of the character and integer denoting the number of repetitions. For example the string "...
2
votes
1answer
53 views

Converting hex strings to byte arrays and back to hex strings in Java

Here is my attempt at converting hex strings to byte arrays and converting byte arrays to hex strings: net.coderodde.util.ByteStringConverter ...
2
votes
2answers
112 views

Python program to get the first word

Given a string the task it to find its first word with some rules: The string can have points and commas A word can start with a letter, a point or space One word can contain one apostrophe and it ...
18
votes
6answers
3k views

Comma Code - Ch. 4 Automate the Boring Stuff

I am new to programming and currently learning Python using "Automate the Boring" by Al Sweigart. I've just completed the "Comma Code" task in Chapter 4 and would like some feedback on my solution. ...
0
votes
3answers
71 views

Form a string consisting of the common letters that appear in two input strings

The idea is to write a function that takes two strings and returns a new string that repeats in the previous two: examples: ...
15
votes
2answers
489 views

Convert camelCase and PascalCase to Title Case

I'm trying to take camelCase and PascalCase strings into a function and spit them out as Title Case. This function also needs to be able to handle odd PascalCase strings with capitalized abbreviations ...
0
votes
0answers
30 views

string.To2DCharArray extension method implementation

I would like to ask a code review for the class below. I am asking this because VS showed a quite low Maintainability Index of 54 and I am wondering if it is good code. I know I could have extracted ...
5
votes
1answer
78 views

Advent Of Code 2017 Day 4 (part 2) in Functional Programming (FP)

I wanted to practice functional programming (FP) without using any library but using vanilla JavaScript only. So I took a problem from Advent of Code (the 2nd part of Day 4) You can only access the ...
1
vote
2answers
184 views

Python program to get the longest substring of the same character

Given a word the program outputs the length of the longest substring with the same letters. For example: long_repeat('sdsffffse') == 4 long_repeat('ddvvrwwwrggg') == 3 long_repeat('abababaab') == 2 ...
3
votes
2answers
150 views

Palindromic partitions solution

Task Find the smallest number of cuts required to break a string into a set of valid palindromes. For example: ababbbabbababa becomes a|babbbab|b|ababa (cuts = 3) partytrapb becomes partytrap|b (...
4
votes
0answers
64 views

Rabin-Karp algorithm implementation

This code uses the Rabin-Karp algorithm to compare two text files. It takes a few minutes when both files contain around 1000 words. How can I improve? ...
21
votes
5answers
33k views

Replacing letters with numbers with its position in alphabet

If anything in the text isn't a letter, ignore it and don't return it. a being 1, b ...
11
votes
2answers
11k views

String Repeat function in VBA

VBA has built-in functions for repeating a single character: Function String$(Number As Long, Character) As String ...
15
votes
8answers
4k views

Python program to take in two strings and print the larger string

I have written a Python program to take in two strings and print the larger of the two strings. Here is my code - ...
3
votes
4answers
96 views

Finding the Longest Word in a String

Challenge: Return the length of the longest word in the provided sentence. I've made a solution that works but it is kinda bad since the time complexity is \$O(n \log n)\$ and it involves mutation....
5
votes
4answers
770 views

Take a desired string, iterate through objects to see if it exists in a given field and append a number until a unique string is found

I wanted to in the most generic way possible write a method in C# to achieve the following. Take in a string, a set of objects, and a function to access the field of a given object Look at all of the ...
3
votes
1answer
59 views

Count the number of words and lines that have multiple vowels

I am working on this coding problem: Count the number of words & lines that have more than X vowels for every Y words in every Z line. Basically the input string has multiple lines and I need ...
2
votes
2answers
34 views

Generating a list (or a string) with random elements

During implementation and testing of different small hobby projects I often reach the point where I need (at least I like it more) some random data beyond the usual foo-bar strings or lists. Random ...
2
votes
2answers
2k views

Negation detection in sentiment analysis

This basic function to detect negation while performing sentiment analysis. So that not good kind of words can be considered a negative. This code is working fine. ...
3
votes
1answer
156 views

Splitting a long string based on its graphical presentation

I got a long string, let's call it Story. I fetch this story from a database so I don't know how long it is. I want to display this story in a view, but what if ...
6
votes
1answer
96 views

Find words with this prefix

This function (find_prefix) is supposed to find words starting with a given prefix in a container. The container is sorted. This function is a fairly performance-...
1
vote
2answers
43 views

Function to count words in Python

I am new to developing in Python and would like to see comments about my word count solution. Please indicate my mistakes or best solutions. ...
0
votes
1answer
22 views

Embolden parts of auto-complete suggestions that don't match the query

I made a function to embolden text that doesn't match a string, but it appears to be very performance-heavy. I am certain that there are much better ways to do this, but with what I tried, I ran into ...
4
votes
1answer
34 views

Python program to know who wins a tic-tac-toe game

Given an input where we have two players: "X" and "O", and empty cells marked with a "." like: check_winner([ "X.O", "XX.", "XOO"]) the program outputs if there are three "X" ...
4
votes
1answer
53 views

Preperiodic, periodic or aperiodic binary string

This is extension of the rep-string task from Rosette code. I do not only want to check if the input string is the shortest periodic string (rep-string) or not, but also check if it is preperiodic. ...
3
votes
2answers
50 views

Python program to translate sentences from “bird language”

Given a sentence in 'bird language', where there are two rules: After each consonant there is a random vowel added. For example if the consonant is "l" it will end as "la" or "le"... After each vowel ...
2
votes
1answer
71 views

Removing first or last character of a string with unit-testing

I am trying to remove a duplicate letter of first or last letter, with an exception of containing 'a' as first letter and 'l' and 'e' as last letter. However, this code does not look efficient to me ...
1
vote
2answers
41 views

Trimming strings in non-contiguous spreadsheet ranges

This code is tested and works, but I am needing some guidance on simplifying these loops with non-contiguous ranges. I was thinking an array might be better, but I ...
20
votes
4answers
3k views

Count all vowels in string

For a homework assignemnt, I was asked to complete this CodeStepByStep problem. It's coded correctly and gave me a right answer. I'm just wondering if there's an easier way to solve this problem ...