A string is a sequence of zero or more characters. It is commonly used to represent text or a sequence of bytes. Use this tag along with the appropriate programming language being used.
6
votes
3answers
56 views
Checking brackets nesting in a string
I took a training challenge on Codility that checks for the proper nesting of brackets in a string. The brackets to be checked are {,},(,),[,]. I have written the following Java program which passes ...
3
votes
2answers
66 views
Permutation of a string eliminating duplicates
This code lists the permutations of the string, and eliminates duplicates if any.
I'm looking for code review, best practices, optimizations etc.
Also verifying complexity: O(n! * n) as time ...
6
votes
1answer
45 views
Python compress and send
The following two functions are used to compress arbitrary Python objects and send them safely via socket or email, using only printable chars. In my specific message protocol, '=' signs are also not ...
1
vote
2answers
38 views
Calculate all possible combinations of given characters
I was asked in my textbook Lectures on Discrete Mathematics for Computer Science to construct a program that would take an alphabet ({a,b,c} or any combination of characters {1,4,s,a}) as well as a ...
5
votes
1answer
38 views
Inserting text file rows into an Access DB - Optimizing
How can I improve my inserts?
I am trying to speed up the process of inserting all of the rows in my text file into an Access DB. I originally switched to this route because of the size of those text ...
9
votes
2answers
281 views
Simple dice roll using std::string as dice notation
How this could be optimized (if there any need for optimization) and what are your thoughts?
This will be a function that returns a random number from Dice Notation (more on Wikipedia). I will later ...
2
votes
1answer
69 views
Refactor ConvertorToString class
Help me refactor this class that helps to represent an object state as String:
public class ConvertorToString {
private static final String SEPARATOR_BETWEEN_FIELD_NAME_AND_VALUE = "=";
...
-2
votes
0answers
16 views
input.nextLine() does not wait for input, and runs a method immediately [on hold]
I'm doing a program which allows me to de-code resistor values into colours.However even after searching for solutions online, I still do not get why I could not fix it. I just learned this for about ...
4
votes
1answer
60 views
Cutting strings into smaller ones based on specific criteria
So, I've got this largish (for me) script, and I want to see if anybody could tell me if there are any ways to improve it, both in terms of speed, amount of code and the quality of the code. I still ...
1
vote
3answers
101 views
To check if a string C is an interleaving of A and B Code
This is my code to check if a string C is an interleaving of Strings A and B. Please suggests optimizations, and where I can improve.
#include <vector>
#include <list>
#include ...
8
votes
2answers
85 views
Is there a simpler way to make an English-readable list from strings in a tuple?
I looking over some old code, I had written the function below with a C-style for-loop iterating over a count variable. I then fixed it up with new knowledge, but still am suspicious that there is ...
6
votes
3answers
83 views
Creating new string with only distinct letters
Aim: To have only one of each character on the Return string:
Public Shared Function CheckForDuplicates(ByVal vCharCheck As String) As String
Dim vDeDuplicated As String = ""
Dim i As ...
1
vote
2answers
51 views
Reducing cyclomatic complexity in a simple string concatenation
I have written the following function that takes an address object and builds a string using the object properties. It will later be used to display a tooltip
var getAddressTooltip = function ...
5
votes
2answers
190 views
Algorithm to determine if a string is all unique characters
This my solution to one of the practice problems from Cracking the Coding Interview: 150 Programming Interview Questions and Solutions [Book]
implement an algorithm to determine of a string has ...
4
votes
1answer
53 views
How to make this lingo game more compact?
I made a lingo game using Python:
You guess a word, and if its letter(s) is in the same spot as a hidden word's, you add [] around the letter. If it's in the hidden word, but not in the same spot, ...