String Looking for ways to improve my hangman code

Just getting into python, and so I decided to make a hangman game. Works good, but I was wondering if there was any kind of optimizations I could make or ways to clean up the code. Also, if anyone could recommend a project that I could do next that'd be cool. import sys import codecs import random def printInterface(lst, attempts): """ Prints user interface which includes: - hangman drawing - word updater """ for update in lst: print (update, end = '')

Split ByteString on a ByteString (instead of a Word8 or Char)

I know I already have the Haskell Data.ByteString.Lazy function to split a CSV on a single character, such as: split :: Word8 -> ByteString -> [ByteString] But I want to split on a multi-character ByteString (like splitting on a String instead of a Char): split :: ByteString -> ByteString -> [ByteString] I have multi-character separators in a csv-like text file that I need to parse, and the individual characters themselves appear in some of the fields, so choosing just one sepa

Case for first character of string

I need to make a decision about a string based on the first character, and I have a method defined in this way: (defn check-first [string] (case (get string 0) "+" 1 "-" 2 3 )) Currently it always returns 3 even when the string starts with those characters. What am I doing wrong? Also, is there a more elegant way to implement this?

MYSQL: Using GROUP BY with string literals

I have the following table with these columns: shortName, fullName, ChangelistCount Is there a way to group them by a string literal within their fullName? The fullname represents file directories, so I would like to display results for certain parent folders instead of the individual files. I tried something along the lines of: GROUP BY fullName like "%/testFolder/%" AND fullName like "%/testFolder2/%" However it only really groups by the first match.... Thanks!

What is the hidden character in this string?

I'm parsing a string from a news feed, and I'm getting some strange behavior on my app. I've been looking more close to this feed and I found some hidden characters in it. Here it's an example taken from that feed: "das empresas portuguesas neste país" After the word "portuguesas" seems to be some character there. How can I find what char is it so I can manage to remove them? Thanks in advance! EDIT: seems that copy/pasting text here just removed it. Can this be encoding-related?

How do I concatenation two strings in Bash without using variables?

I'm trying to tar a large directory, and I'd like the output file to contain the date. Here's what I have so far. tar -zcvf "mywebsite website backup" $(date "+%Y-%m-%d %T") public_html This doesn't quite work though. As an example, I'm trying to get the single string below to be the file name. The call to date is working fine and I don't need help with that, but I'm not sure how to concatenate the "my website backup" with the output from date without first storing them in variables (which se

String find frequency of every word

There is a question asked to me in the interview, but I am not able to answer that. Question is : You are given a directed graph in which every node is a character and you are also given a array of strings. The task is to calculate the frequency of every string in the array by searching in the graph. My approach : I used trie, Suffix tree, but the interviewer is not fully satisfied. Can you give me an algorithm for the given problem.

String Modifying a character array, the modified part shows up backwards

I have just started learning assembly, and I am trying to modify a character array. This is my assembly code: .data data byte 'Five', 0 .code Asm proc lea rax, data mov dword ptr[rax], 'Four' ret Asm endp end And my C++ code: #include <stdio.h> #include <conio.h> // external function extern "C" char* Asm(); // main function int main() { printf(Asm()); _getch(); } When I comment out mov dword ptr[rax], 'Four', the result is that the con

php script for comparing an string with other string

i try to prevent users from duplicate post in my website with php to do this i check the title entered by user with title field in database and if record with this title found in database system show error message to user but some users change title with little character for example some user change character place like this: main title: microsoft office lite(x86,x64) change by user: microsoft office lite( x64,x86) change by user: microsoft office_lite( x86,x64) change by user: microsoft

Bash indexof substring after nth character

is there a way to get indexOf of a substring after nth character in Bash, without needing to cut the original string one by one, that would be lengthy 12345678901234 $ expr index 'abcdeabcdabcaa' 'c' 3 $ expr index 'abcdeabcdabcaa' 'ca' 1 What i want would be: $ indexOf 'abcdeabcdabcaa' 'ca' 12 $ indexOfAfter 5 'abcdeabcdabcaa' 'c' 8 $ indexOfAfter 5 'abcdeabcdabcaa' 'ca' 12 $ indexOfAfter 9 'abcdeabcdabcaa' 'b' 11 $ indexOfAfter 111 'abcdeabcdabcaa' 'c' 0 probably there are

header title has a string addition and ignores one of the parametres when i run it remotely

I have the following problem: one member of the header row is an addition of strings like this: "Amount (" + ContextHelper.GetLocalCurrency().ToString + ")" in order to show, in case of us local currency: Amount (US) it works fine when I run this locally, whether if I do it in my pc hitting the localhost or if I run locally the VM throug the remote desktop connection, also hitting the localhost. But when i try hitting the service that is running in the VM from my pc (as the client will)

How can i determine if a string is a concatenation of a string list

Suppose we are given a string S, and a list of some other strings L. How can we know if S is a one of all the possible concatenations of L? For example: S = "abcdabce" L = ["abcd", "a", "bc", "e"] S is "abcd" + "a" + "bc" + "e", then S is a concatenation of L, whereas "ababcecd" is not. In order to solve this question, I tried to use DFS/backtracking. The pseudo code is as follows: boolean isConcatenation(S, L) { if (L.length == 1 && S == L[0]) return true; for (String s:

ActionScript 3 - How do I get my String to convert to a Number?

I have a Budget field (called txtBudget) where I want users to enter a number value. I then want to store what they entered as a variable (totalBudget) so that I can perform calculations based on it later. My problem right now is that when I go to a different frame, and then return to the frame with the code, the text field displays "NaN". I can't work out why, and it's driving me mental. On frame 1 I say: var totalBudget:Number = 0; Then on frame 14 I tried: onBudgChange(null); txtBud

add a space every 2 charaters in a string

I have mac addresses in this shape "001122334455" that I want to turn into "00 11 22 33 44 55". I guess there is a way to do this in one line, but the only way I found is the following ridiculously horrible proc. Can someone show me how to do this properly ? proc addSpaces { mac } { set mac [split $mac {}] set i 0 while { $i < 12 } { if { [expr $i % 2]

String Use For Loop to obtain values from multiple textboxes in Excel VBA

For a VBA code in Excel (not a userform) I have 4 textboxes named TextBox1 to TextBox4. I want to obtain the values from these textboxes using a for loop. The goal is to search for a value in a corresponding column (D in this case). Therefore I search in the selected sheet (named after the selected value in the UpdateComboBox). To be able to search I first select the rownumber corresponding to the Weld showed in RelatedWeldTextBox_i. This value differs following other input boxes. The code bel

scan string operators - javascript

In a calculator I own 4 input type ="number" in particular: <input type = "number" id ="mol" min="1" max="4"> <input type = "number" id ="div" min="1" max="4"> <input type = "number" id ="add" min="1" max="4"> <input type = "number" id ="min" min="1" max="4"> In a textbox, I insert the mathematical expression for extended. <input type = "text" id = "exp" readonly> The numerical values ​​and the operators have gone through the normal buttons. So, for example, t

Extraordinary string split

I have one string my $str = 'one ; two - three; four - five | six - seven; eight ; nine-ten | eleven - twelve | thirteen - fourteen; '; i need to output as seen below one ; two - three; four - five ; eight ; nine-ten ; ; ; six - seven ; ; eleven - twelve ; ; ; ; ; thirteen - fourteen ; split fields by ';', and split each by '|' ))) Help me please

String Why is Haskell unable to read "7e7" but able to read "7a7"?

Try to do: Prelude> reads "7a7" :: [(Int, String)] [(7,"a7")] Prelude> reads "7e7" :: [(Int, String)] [] I tested this for all possible characters in the middle. They all work except for 'e'. It seems as if Haskell tries to interpret the number in scientific notation, but it can't because I'm asking for Int. It seems like a bug to me.

MySQLi & mysql_real_escape_string() Giving me a bunch of errors

Im having problem with my UPDATE code., since i'm new at php, im trying to figure out what's been the prolem with my UPDATE command here's my line of code. My insert and delete commands are good to go but this one gives me a headache for 4 hours now. <?php include 'includes/conn.php'; if($_POST){ //write query $sql = "UPDATE member

Comparing String.Index values

Is it possible to compare two String.Index values in Swift? I'm trying to process a string character by character, and several times I need to check if I am at the end of the string. I've tried just doing while (currentIndex < string.endIndex) { //do things... currentIndex = currentIndex.successor() } Which complained about type conversions. Then, I tried defining and overload for < as such: @infix func <(lhs: String.Index, rhs: String.Index) -> Bool { var ret = true

Issue with searching for text within a returned string

I have wrote code that gets this returned: <div id="IncidentDetailContainer"><p>The Fire Service received a call reporting a car on fire at the above location. One fire appliance from Ashburton attended.</p><p>Fire crews confirmed one car well alight and severley damaged by fire. The vehicle was extinguished by fire crews using two breathing apparatus wearers and one hose reel jet. The cause of the fire is still under investigation by the Fire Service and Police

String Remove punctuation but keeping emoticons?

Is that possible to remove all the punctuations but keeping the emoticons such as :-( :) :D :p structure(list(text = structure(c(4L, 6L, 1L, 2L, 5L, 3L), .Label = c("ãããæããããéãããæãããInappropriate announce:-(", "@AirAsia your direct debit (Maybank) payment gateways is not working. Is it something you are working to fix?", "@AirAsia Apart from the slight delay and shortage of food on our way back from Phuket, both flights were very smooth. Kudos :)", "RT @AirAsia: ØØÙØÙÙÙÙ ÙØØØ ØØØ

String Removing everything between a certain set of characters with Swift

I'm quite new to Swift and native programming, and for a small project I'm doing for myself I'm getting in the full html after doing a twitter search, and I'm trying to filter out just the text of the first tweet. I'm up to the point were I'm able to get the first tweet, including all the tags that are in there, but I'm a bit clueless on how to filter just the text out of there and remove the HTML elements. For example, it's pretty easy to take a single tweet and filter out the possible <a

MS Access: how to delete everything in a string after two specific characters

How can I delete the number together with the space in a string while my data looks like this: randomtext = 567897 otherrandomtext = 3827475 evendifferentone : 483838 andsoon : 03948 type of contact 594837 other type of contact 453222223 so that it can look like this: randomtext otherrandomtext evendifferentone andsoon type of contact other type of contact I managed to use update query (written below) to remove everything after "=" but how to update both (with "=" and ":") at the same time

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

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 * FROM MyTable") db.commit() # get the number of rows in the resultset numrows = int(cursor.rowcount) # Opening a file to write in it

String CoreData find indexPath of entry

I have an CoreData model with the entity Person and an attribute called name. I store 4 strings into name (Pete, Paul, Dan and Jo). Now I'd like to find out which indexPath Paul has. How can I do this? My CoreData model:

String parsing using complex patterns

I have a complex string with an unknown number of letters, numbers, and characters. For instance "a83bal*av31-ab+asf3/af1124-xxx.afe-100/araw31/31*xxx.g41.abt.eta+131as*dfa" The goal is to find the string xxx and extract everything after it until a +, -, * , /. Thus I should be able to extract xxx.afe and xxx.g41.abt.eta Finding the string is simple string:find("xxx") the trouble I am having is gathering all of the information following the "xxx" until one of the operators. I have tried thing

Shuffling a string in Swift - swapping a location not supported

I have this code to shuffle a string in swift. For some reason it is giving an error in Xcode 7.1 "swapping a location with itself is not supported. I thought it was working ok. Any ideas where I have gone wrong much appreciated! let selectedWord = word1 // word1 is a string var chars = Array(selectedWord.characters) chars.shuffleString() let shuffledWord = String(chars) word1 = shuffledWord extension Array { mutating func shuffleString() { for index in 0..<(count - 1) { let j =

Using a bat file, Delete all but first occurences of a string in an XML

I want to remove all occurrences of strings <!-- and --> from an XML EXCEPT for the first which surround a comment that I want to keep. I do not want to delete any text enclosed by these strings. The strings all occur on different lines. I am able to delete all instances of a string(s) by using the proposals in Delete certain lines in a txt file via a batch file but am not sure of the best way (using a for loop?) of skipping the first ones. The XML looks like this: <?xml vers

How to determine length of null-terminated string in WinDbg

There is a null-terminated ASCII string existing in the address space of the target process under debugging. I want to write a WinDbg script to print out the length of this string. Assuming I know the address of the starting character of the string, how do I calculate its length?

String Libraries for text manipulation

So... I plan on doing an animation that pulls all the text from the screen to the middle and lets it pulse like a heart. For that I checked if I'm able to manipulate whole Strings and Chars the way I'm able to manipulate circles, for example. I found the libraries Nexttext and Fontastic, but those seem to be outdated, therefore I can't use them with Processing 3.0. Than there is the library Geomerative, which I manged to install through Processings library manager, but this one yields the error

String Python 3 unescape \"

I want to have a string variable to store a value that has \" in it. Example: a = 'attribute=\"something\"' with this exact value, not a = 'attribute="something"' I've tried with '\\"' even '\\\\"'. I want to store the value in a variable, not to print it like this. I'm trying to search and replace attribute=\"something\" to old-attribute=\"something\". But I can't manage to create the value and replace variables. I'm trying to store '\"' in a string variable: >>> b ='\"' >

VBA - Combine several cells into a single string in Excel

I'm working on a spreadsheet full of warranty data and there are three adjacent columns where different members of the service team can enter comments and trouble codes they find. I'm writing a macro to parse the comments looking for the trouble codes and I can get it to search one column fine, but I can't seem to get it to search adjacent columns in one step. My goal is to combine the three adjacent cells into a single string. I don't care about space or comma delimiters, the regex will still

split string become custom code in crystall report

i have string like this P-123C automatic P-H342 non automatic system P-HH231 automatic system PD 4357JP REF-B130MK3 air system BSC-WDB801 flow system and i want that string like this P-123C P-H342 P-HH231 PD 4357JP REF-B139MK3 BSC-WDB801 Please help...master

20 Random Strings containing all capital letters

I need to create a procedure that generates a random string of length L, containing all capital letters. When calling the procedure, I need to pass the value of L in EAX, and pass a pointer to an array of byte that will hold the random string. Then I need to write a test program that calls your procedure 20 times and displays the strings in the console window. The code below wont work it comes back with these errors: Line (33): error A2008: syntax error : main ENDP Line (35): error A2144: cann

String ShellScript parsing a sting variable to notify-send

I have never seen this anywhere in my search I am making a script to see if I can send a string variable to notify-send so far $MESSAGE='Hello world!' notify-send "`$MESSAGE`" -t 1 will trow Hello command not found and notify-send $MESSAGE -t 1 sends a too many argument error so is there a way to do that?

String How to avoid empty lists to be appended & parentheses and brackets

I am currently struggling with a small piece which should screen a large file and write out only specific data fulfilling certain restrictions giving by a a function. I have mainly formatting issues: from __future__ import print_function import numpy as np log = open("out_test", "w") log1 = open("out_test_empty", "w") def function(kx,ky,ek,sz,ef,tol): lines = [] if ((ef-tol)<ek<(ef+tol)): lines.append((kx,ky,sz)) # (lines.append((kx,ky,sz)) if (kx,ky,sz) is not Non

String How to match file extension in bash?

I want to call a function ONLY when the file name ends with .request but somehow it calls the function if request is sub-string. I marked with red and green the imported parts, on the right it's the output for file in ${filesOrDir[*]}; do if [[ -f "$file" ]]; then if [[ "$file"=*[".request"] ]]; then # Enters here when .request is a substring. fi fi if [[ -d "$file" ]]; then # ... some logics fi done

How can I find occurrence of an Id in a Scala String

Hello guys i'm kinda new on scala and i'm having this problem: On the following string: The ID 5d27e5d082c272591e25b8d5 is the only valid Field, The ID 5d27e5d06a77457139395318 is the only valid Field, The ID 5d27e5d0431e726aeb5ab84f is the only valid Field, The ID 5d27e5d282c27256cc24b6a2 is the only valid Field, The ID 5d27e5d282c27256cc24b6a2 is the only valid Field, The ID 5d27e5d282c2727ad524c567 is the only valid Field, The ID 5d27e5d2431e724af25a1bd6 is the only valid Field, The ID 5d2

String How to count all integers less than a given integer and having two contigous digits as y?

Suppose i have been given a number 54432 .How to count all numbers less than 54432 and having last two digits as 1 ? i.e all the numbers of form xxx11 and xxx11 < 54432 .Here x can be any digits but xxx11 < 54432 should hold. What is count of all the numbers of form x11xx and x11xx < 54432 ? How to solve this in general and fast way i.e any number other than 1 , say y and arbitrary position of two contiguous digits as y and count of all such numbers less than a given integer. can we

Substring after a character

I'm looking for a way to beautifully extract 'user id' from string in Groovy. Lets say I have string "key::${userId}" For example: String s = "key::123456" I can extract userId in java style as following Long.parseLong(s.substring(s.indexOf("::") + 2)) But I believe that there is a way to make it shorter and more neatly

String can anyone explain this error and also about this case too like why I cant equivalate that two values?

public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); System.out.println(remove(str)); } static String remove(String str) { int start=0; if(str.charAt(0)!=str.charAt(1)){ return str; } if(str.charAt(0)=str.charAt(1)){ str=str.substring(start+1,str.length()); remove(str); } } } /Root/src/Main.java:22: error: unexpecte

String Is it possible to Add 0 in Double Var in VB Net

I'm trying to add 0 before each number I'm having but it seems it's not working because I'm using double. I'm using double so I can input numbers such as 1.5 (hours) and translate it to seconds, minutes, and hours (Output should be 0 seconds, 30 minutes, and 1 hour and 01:30:00). I'm having no problems with the first output but I can't seem to do the second output (The desired 01:30:00 only displays 1:30:0). What I did first is I tried to convert the double variable to int32 then to string but i

String replace not work with if statement

1.I have an issue with String not replacing in this code 2.I tried to practice make a Clock and try to make seconds shown as "00" SeekBar timerSeekBar = (SeekBar) findViewById(R.id.timerSeekBar); TextView timerTextView = (TextView) findViewById(R.id.timerTextView); timerSeekBar.setMax(600); timerSeekBar.setProgress(30); int minutes = (int) progress/60; int seconds = progress-minutes * 60; String second

  1    2   3   4   5   6  ... 下一页 最后一页 共 76 页