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.

Filter by
Sorted by
Tagged with
1
vote
0answers
7 views

Optimize Memory Java String Array

I was trying to solve one programming challenge : First input is a list of connections which is made of pair of IPv4 address. Each IP has its own state which starts with false, each connection also ...
1
vote
1answer
28 views

Filtering a Vec of structs and creating new vector of Strings or strs in Rust

I'm working through the Rust book, and it has the following example of how to use the filter method on Iterators (source): ...
2
votes
2answers
68 views

Exercism: determine if a word or phrase is an isogram

The task: Determine if a word or phrase is an isogram. An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed ...
3
votes
2answers
80 views

Code to modify string as per instructions

I solved this problem statement on dear old codeforces. The Problem Statement wants users to replace occurrences of '10' in the given string with either '1' or '0' until there is no occurrence of '10' ...
3
votes
1answer
45 views

Custom crossplatform extended ASCII converter

Problem/Background: I want to support only some special Unicode characters for my program (Greek letters and some math operators). C++ provides a char type, which ...
7
votes
4answers
1k views

JavaScript function that flips brackets direction

I have these strings: )hello( this has ]some text[ flip }any{ brackets even with )))]multiple[((( brackets As you can see, the brackets are all in the wrong ...
2
votes
1answer
73 views

Trie implementation for strings in Swift

A trie for handling strings for an autocomplete dictionary. This passes my fairly casual tests, though it's always possible that there are broken edge cases, but I'm mainly concerned about design and ...
3
votes
1answer
77 views

Hamming distance implementation in Java

I'm exploring String relativity and comparison techniques, and I found Hamming distance algorithm in my search so I give a try to implement that approach in Java and below I'm sharing my ...
5
votes
3answers
271 views

C: function to read a token from stdin

I recently started doing some competitive programming in C and one of my first requirements was a high-speed token reader (analogous to the java Scanner class' <...
1
vote
1answer
62 views

Implementation of itoa

...
6
votes
2answers
75 views

Pretty-print dollar amounts using custom precision for large amounts

Given a floating-point number, which is representing a dollar value, I'm aiming to return a rounded, human-readable string. Here are the rules for numbers equal to or greater than 1 million, equal to ...
0
votes
1answer
38 views

Encasing a string in double quotes

I need to add some characters to a String before using it for an API call. The idea is to add a " char both at the beginning and at the end of the String, to make ...
1
vote
2answers
43 views

Smartly joining possibly empty strings

I want to join two fragments into one string with a separator, but when one of the fragments is empty I only want one of them. I have two implementations. The first is long and slightly repetitive, ...
2
votes
0answers
28 views

SHA-256 implementation in JS (core codes)

As told by experts, I am re-posting the code review request with the code. Brief Description: from outside sha256() will be called with parameter having UTF-16 character set. then after prepareData()...
2
votes
1answer
72 views

Listing words from text, provide lines where appears, count them

I applied for Junior Java Developer in some company. Got a task:"Listing words (without duplicates) from text, provide lines where appears, count them." Output should looks like: Alphacoronavirus - 3 ...
-2
votes
1answer
74 views

Sorting through two dictionaries [closed]

What my code try to do here is to sort items trough 2 dictionaries. If they are similar or the same, I create a new list to append them. The test file is relatively big, around 2000 data each ...
1
vote
1answer
37 views

Perl - Splitting a string

I've decided to work on my Perl skills. I've written a small subroutine that splits a string based on an optional delimiter. I'd like any feedback on this program so I can kick bad habits to the curb. ...
1
vote
2answers
95 views

Protein Translation - Translate RNA sequences into proteins

RNA can be broken into three nucleotide sequences called codons, and then translated to a polypeptide like so: RNA: "AUGUUUUCU" => translates to Codons: <...
1
vote
0answers
48 views

Own implementation of C++ std::string_view

In order to improve my C++ skills I started doing some toy projects, one of them being my own std::string_view implementation. This was my first time implementing a std library. I'm pasting the code ...
10
votes
3answers
844 views

Roast my C# birthday code

So this is a pretty simple code, I think it was? It asks for the user's birth day and month, and gives it back with the day a discount reminder email will be sent (the day before their birthday) Now ...
4
votes
3answers
75 views

Add two digit strings and return the result as string

I haven't done C in a while. This looks like a simple problem to start. Leetcode problem 415 Given two non-negative integers num1 and ...
3
votes
1answer
148 views

Amending code to make it list some files in a directory, rather than all

The method list_all() is the code I am starting with. It just lists all files in "c:\windows". I want to adjust it to list only the first 10 files (if there are as ...
1
vote
1answer
60 views

Code for adding a user to the database

I have a code that adds a user to the database, getting the username from the dialog.My fragment implements the interface with the onInputSend method, which is called by the dialog when the user ...
0
votes
2answers
154 views

Sherlock and Anagrams in Javascript

I am trying to solve a Hackerrank problem Sherlock and Anagrams. I think my code is valid but somehow times out for some of the test cases. Any tips on how to improve its performance? Critique ...
6
votes
5answers
803 views

Convert Integer to String without using Java API library

I have written a Java program that converts an integer to String digit by digit and concatenate them together using the + operator without touching the Stock Java API library. I like to have feedback ...
2
votes
1answer
53 views

Receive an array input and output a string

I have some code which is working, but I would be interested if anyone could review it and tell me if there is a more efficient way of achieving my goal. I receive input from a data source as an ...
-3
votes
1answer
22 views

How to convert Recursive Approach to iterative one(Super Reduced String)? [closed]

The Question: Steve has a string of lowercase characters in range ascii[‘a’..’z’]. He wants to reduce the string to its shortest length by doing a series of operations. In each operation he selects a ...
5
votes
2answers
375 views

Dynamic String Alignment Code

My code works for user output alignment to the right side by maximum length of 4 different user input. I have 2 question. Is there a simplier way for append method in my code ? Is there a simplier ...
0
votes
1answer
81 views

Refactor to remove goto

Is it possible to implement this function without goto, while keeping the code correct and readable? ...
1
vote
1answer
48 views

Feedback Request on Title Capitalization Function Converted From JavaScript to PHP

I have a function in JavaScript that converts a string value to title case using APA style: ...
1
vote
1answer
46 views

Optimising multiple string splits and concatenations

I'm writing a program in Unity and am using a TextMeshProUGUI object (named history) to hold a list of messages to act as a ...
3
votes
1answer
44 views

Scala: Cumulative String Tokenisation

I'm trying to split an incoming stream of strings into cumulative tokens per line item using a function below, ...
4
votes
3answers
423 views

Vowels and consonants in Java-exercises with strings

I feel like my code is too messy-Im looking for possible way to make it more readable/shorter. Goals: 1)Get three strings from user input. They have to be the same length. a)First must contain only ...
3
votes
2answers
65 views

String input and split functions in C

I've some functions targeted to simplify working with strings in some of my other projects. I'd like feedback on this code and whether or not the implementation is efficient and memory safe. I work ...
8
votes
4answers
1k views

Determine if a String has a mirroring head and tail

Problem statement: Given a string, look for a mirror image (backwards) string at both the beginning and end of the given string. In other words, zero or more characters at the very begining of ...
2
votes
1answer
52 views

String Permutation

Below is my permutation function and I'm looking to make it more elegant and efficient if possible. The function should return a string which includes all the permutations of the given string (...
1
vote
1answer
79 views

Performance: Use plain for loops to look for (existence of) string in string array?

I timed a few ways to look for a string in a string array (with 82 elements in the example) in a case sensitive manner plus ignoring case. I am kind of suprised, that the plain for loops are faster ...
9
votes
2answers
342 views

Navigate objects from a path provided as a string

Recently I wrote a validator for some objects. To increase usability the validator gives the user hints on how to fix some of the found issues. Since the application is around something programmatic, ...
1
vote
2answers
83 views

increase speed & lower memory consumption of text normalization function

I'm trying to preprocess a large text document. I've written a text normalization function which takes a disproprtionate amount of time and memory. How can I format the function to lower these two? ...
3
votes
1answer
30 views

Convert a binary string, with each char separated by spaces, into a normal C string and print

This code is a purely for-fun project and it comes from this challenge at freeCodeCamp. This is simply an algorithm challenge which is usually meant for JavaScript, but I decided to perform in C. It ...
2
votes
1answer
41 views

Better filereading and print formating in R

I am a beginner using R and I am trying to solve some simple statistics problems and print the output. The following code takes in two datasets, computes the mean, ...
1
vote
2answers
83 views

Title Case function in C

I've written the following function in C which shall take as input a character array (decayed to a char * of course), and mutate the string into a title-cased string in the form "this is a string" -> "...
2
votes
1answer
38 views

Reading bytes between two quotes from a stream and decoding it to its appropriate character set [closed]

This is a component for a lexer which operates on a byte input stream that handles reading and decoding the contents of a string contained within double-quotes. The validity of the encoding is handled ...
13
votes
4answers
2k views

C Program which compares software version strings

I wrote the following C program to compare software version strings. Please provide any general feedback you'd like, but with special focus on error handling decisions, user input validation/...
3
votes
1answer
25 views

Check shell programs for portability

There are lots of shell programs that have /bin/sh as interpreter, yet use some features that are specific to bash or other popular shells. I have written a little ...
5
votes
2answers
215 views

Java Kata - String Calculator

I started learning Java recently. Currently I'm trying to improve my spaghetti code by solving different programming puzzles. It would be amazing if someone could give me feedback on the String ...
6
votes
3answers
1k views

Elegant solution to find a pair of Strings in a List [closed]

I'm new to Java8 and I must find an elegant solution to a problem. The problem goes I have a List of letters (of any size) that could contain any letter such as "A", "B", "C", "D", etc. I must check ...
4
votes
1answer
67 views

Clean up tags from a text

I need to generate random text for tests. I do that using alphanumeric characters and some special characters as well. For some special cases, I cannot generate the random text with tags. I have the ...
8
votes
3answers
1k views

Reverse each word in the string. All spaces in the string should be retained

This was part of a code challenge. I use them to help me learn c++/c# along with tutorials and guides. Basically I was taking a string... The quick brown fox jumps over the lazy dog. ...and ...
9
votes
4answers
962 views

Building string with max length

I need to run a evaluation for large (1 Million) number of components and build a string with error which has comma separated error codes. As the final string is to be persisted in RDBMS TABLE.COLUMN ...

1
2 3 4 5
52