FAQ Database Discussion Community


How to calculate a length of array with out using library

java,arrays,string,string-length
yesterday I appeared in interview,interviewer told me to write a code for calculating a length of array with out using a length property of Array class. For examaple- char[] array=new Scanner(System.in).nextLine().toCharArray(); // i have to write a code for calculating length of this array //I can use any operator but...

compute string length in Spark SQL DSL

documentation,apache-spark,string-length,apache-spark-sql
I've been trying to compute on the fly the length of a string column in a SchemaRDD for orderBy purposes. I am learning Spark SQL so my question is strictly about using the DSL or the SQL interface that Spark SQL exposes, or to know their limitations. My first attempt...

How to hide the length of a decrypted string after encryption

string,encryption,cryptography,string-length
I've just written my own (simple) encryption and decryption functions... function MyEncrypt(const AValue : string; const AKey : string) : string; begin Result := //encryption end; function MyDecrypt(const AValue : string; const AKey : string) : string; begin Result := //decryption end; ...and I've got some doubts about how to...

Issues With length() And Multiples Of 3

java,math,multiplication,string-length
Lets see if someone can wrap their head around this: if you get the length of a String using length(), the String always being multiples of 3,(in my case: "1.02.03.04.05.06.07.0 etc.") each 3 characters representing a letter, with .1 indicating a capitol letter, how do you use the length to...

Biginteger Addition in C++

c++,string-length
I am trying to add two big integers. Here is a function I have made. s1 is the larger string in it. During passing the function parameter I will account for the string length. The code works fine for all values except those having 10^(n). As such it shows o/p...

Update form validation on right-click cut/paste

javascript,jquery,html,textarea,string-length
I check the length of user input to give feedback before they attempt to submit the form. Here's my code: var $foo = $("#foo"), $span = $("span") $foo.on('keydown keyup change', function(){ $span.text($foo.val().length); }).trigger('change'); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <textarea id="foo">Ipsum</textarea> <small><span></span> characters.</small> This works correctly for input typed. However, if a user cuts...

How to find the length of a numerical variable using PROC SQL

sql,sas,numerical,string-length,proc-sql
I have a dataset with a column of phone numbers. I want to filter this dataset using PROC SQL WHERE the length of the numbers is at least 7 digits. In normal SQL I can just apply a length function around a number and it works, however in SAS it...

Deep understanding: What is the underlying logic behind the way array indexes work?

javascript,arrays,indexing,string-length
My motivation for this question For me the thrill of programming is when a deep understanding of the logic behind a given language enables you to "just figure things out" using that logic. So when I stumble upon something that appears to miss this kind logic it bothers me. How...

Concatenation of strings array issues in Python: Str(ArrayOfString[1])+“ ”+Str(ArrayOfString[2]) doesn't seem to work

string,python-2.7,concatenation,slice,string-length
Hi I have a problem with a python script, I don't manage to do a concatenation of 2 arrays of strings it returns- SyntaxError: can't assign to function call Here's my script: import os, sys, MySQLdb # connecting to a database db = MySQLdb.connect(host="localhost", user="MyUser", passwd="MyPassword",db="MyDB") cursor = db.cursor() cursor.execute("SELECT...

C++ return length of string including contained null terminator bytes

string,string-length
The methods for getting the length of a string in C++ all seem to count up to a null terminating byte, then they either include it in the length or not and then return the length up to then. Well lets say I have a String like this: 'h','e','l','l','o','\0','t','h','e','r','e' Now...

Remove Element from Set

java,string,foreach,set,string-length
I'm trying to remove all Strings that are of even length in a set. Here is my code so far, but I am having trouble getting the index from the iterator in the enhanced-for-loop. public static void removeEvenLength(Set<String> list) { for (String s : list) { if (s.length() % 2...

Batch file getting a substring from a string from a position to a length

string,variables,batch-file,substring,string-length
(Edited at 04.03.2015) This is the working corrected version of the code. The aim of this code is to get paths of some directories and subdirectories of which structure shown below, to make a list. C:\__Genus1\_Species1\Directories C:\__Genus1\Directories C:\Directories C:\_Family\Directories C:\_Family\__Genus1\_Species1\Directories @ECHO off setlocal enabledelayedexpansion SET "_sDr=" SET "_sPt0=" SET "_sPt1="...

Why does program crash after exiting do-while loop asking for input in C?

c,string,input,do-while,string-length
I am having trouble with correctly using a do-while loop to keep asking for another string if the one input is longer than what you want. After entering a string which is too big the program expects another but after I input an acceptable one the programs crashes instead of...

Difference between $# and ${#@}

bash,string-length
I was looking at the following code and found that both $# and ${#@} print the same value. Could someone tell me what's the difference between the two? # length.sh E_NO_ARGS=65 if [ $# -eq 0 ] # Must have command-line args to demo script. then echo "Please invoke this...

Adding a data frame column with len() of another column's values

python,pandas,string-length
I'm having a problem trying to get a character count column of the string values in another column, and haven't figured out how to do it efficiently. for index in range(len(df)): df['char_length'][index] = len(df['string'][index])) This apparently involves first creating a column of nulls and then rewriting it, and it takes...

How to make top line shorter than bottom line (within div)

javascript,jquery,html,string-length
I have an unordered list which contains 3 list items (represented in my example as 3 green boxes). Each box has an image and 3 divs (title,location,price). I'm only concerned with each box's title div. If the title is long enough so that it produces 2 lines, I want the...

Smaller font-size if the string length of the div is greater than 10

javascript,jquery,html,string-length
I have a div that I want to detect the length of; if it's 10 or more, I want it to display in a smaller font-size. $(window).load(function() { function adjustFontSize() { var theTitleLength = $('.article-title-on-list').text.length; if (theTitleLength >= 10) { $('.article-title-on-list').css('font-size', '1.5rem'); } else { $('.article-title-on-list').css('font-size', '2rem'); }; }; adjustFontSize();...

How do I split an integer using an “if” condition?

regex,if-statement,awk,sed,string-length
I've been looking for days trying to use awk, sed, cut, and tr for a possible solution to my problem. I have a data set thats delimited with a "@" as shown below... [email protected]@[email protected]/[email protected]/[email protected]@11/2 [email protected]@31 1/[email protected] 1/[email protected]/[email protected]@21/2 [email protected]@116 1/[email protected]@911 3/[email protected]@38 1/2 [email protected]@[email protected]/[email protected]/[email protected]@49 1/4 [email protected]@[email protected]@67 1/[email protected] 1/[email protected] 1/2 [email protected]@[email protected] 1/[email protected] 1/[email protected]