I wrote a really simple code to create some nested lists, and I got an unexpected problem, that while loop doesn't end.  Have no idea what is wrong in it. If you have any clues, would much appreciate it)  import random  square = [0,0,0,0,0,0,0,0,0] squares = []  def allsquares():     for i in range(9):         squares.append(square)     return squares   def autofill():         for i in range(9):             fn = random.randint(1,3)             sn = random.randint(6,8)             for s in range(fn,sn):                 print('Mary Sue')                 d = True                 while d:                     x = random.randint(0,8)                     print(x)                     if squares[i][x] == 0:                         d = False                 squares[i][x] = random.randint(1,9)         return squares    allsquares() autofill() print(squares[2])
I needed to create a list of lists in Python, so I typed the following: my_list = [[1] * 4] * 3  The list looked like this: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]    Then I changed one of the innermost values: my_list[0][0] = 5  Now my list looks like this: [[5, 1, 1, 1], [5, 1, 1, 1], [5, 1, 1, 1]]    which is not what I wanted or expected. Can someone please explain what's going on, and how to get around it?
What's the best way to check if a String represents an integer in Java? I normally use the following idiom to check if a String can be converted to an integer.  public boolean isInteger( String input ) {     try {         Integer.parseInt( input );         return true;     }     catch( Exception e ) {         return false;     } }   Is it just me, or does this seem a bit hackish?  What's a better way?    See my answer (with benchmarks, based on the  by ) to see why I've reversed my position and accepted  to this problem.  I think this original code will be used by most people because it's quicker to implement, and more maintainable, but it's orders of magnitude slower when non-integer data is provided. Find all integer solutions to $x^2+y^2+z^2=2xyz$ I have county data in which the &quot;FIP&quot;s (actually State &quot;FIP&quot;s and County &quot;FIP&quot;s combined). I have data imported as CSV with the sames &quot;FIP&quot;s data titled 'STCounty'. However, the shapefile &quot;FIP&quot;s is listed as a Real and the CSV came in as an Integer and the Join function does not seem to work.  The drop boxes are greyed out/empty. So the bigger questions is how do you change the attribute type in a table? I tried to create a new column in the shapefile (county data) and set it to an integer and then multiply the &quot;FIP&quot;s*1, but got a column full of NULL. I am new to QGIS and have a lot of experience in MapInfo, so the join concept is not new to me, just the syntax in QGIS. Are static fields open for garbage collection? Given an hypothetical utility class that is used only in program setup:  class MyUtils {    private static MyObject myObject = new MyObject();    /*package*/static boolean doStuff(Params... params) {        // do stuff with myObject and params...    } }   will myObject be garbage collected when it is no longer being used, or will it stick around for the life of the program? Turn off paragraph indention for a single line Is it possible to turn off the paragraph indention for a single line? I have the following use case: I open a new section which describes the task of an exercise. Since I use the font size \large for the section I don't want to use the section text for the task description.  Therefore I added the task description after the section. The disadvantage is that an indention is created when starting to write text after the task description.  What are possible solutions to this problem? Seeking alternatives to pgRouting for open source routing / network analysis? I'm trying to fill out the skills section on my first character, but when I look at the character sheets in the Starter Set as examples of how to make a character, the skills that are circled have higher modifiers than their Dexterity or Strength or whatever should make them.  I've filled out all skills but those. What do I add to the ability modifier to get those numbers?   My abilities are Strength 13, Dexterity 14, Constitution 11, Intelligence 15, Wisdom 8, and Charisma 8. Proficiencies are Arcana, Athletics, History, Investigation and Stealth. My saving throws are Strength and Dexterity.   I just started D&amp;D and have the Player's Handbook, DM's Guide, Monster Manual, and the Starter Set. HTML5 Canvas to PNG File How to convert std::string to LPCWSTR in C++ (Unicode) $(document) vs. $("document") How to use Terminal to delete all .svn folders recursively? Does there exist an holomorphic function such that $|f(z)|\geq \frac{1}{\sqrt{|z|}}$? I have some trouble solving this problem: Does there exist a holomorphic function $f$ on $\mathbb C\setminus \{0\}$ such that $$|f(z)|\geq \frac{1}{\sqrt{|z|}}$$ for all $z\in\mathbb C \setminus \{0\}$? I don't know where to start. My intuition is that you would get a problem with the singularity near $0$, but I am not sure how to prove it. Any help would be appreciated! Thanks! How do I add a condition to a query? S(x), which stands for “x is a surgeon”  P(x, y), which stands for “x is a patient of y”  R(x), which stands for “x recovers”  H(x), which stands for “x is happy”  1>"A surgeon with no patients is happy" means: for any person xx, if xx is a surgeon and there is no person yy for which yy is a patient of xx, then xx is happy.  2> "A surgeon is happy if all her patients recover" means: for any person xx, if xx is a surgeon and - if for every person yy for which yy is a patient of xx, we have that yy recovers - then xx is happy.  I have these as solution:  1:∀(x) ( S(x)∧ ∀(y)P(y,x) → H(x) ) 2: ∀(x) [ { S(x)∧ (∀(y)P(y,x) ∧ R(y)) } → H(x)]  Are these okay?  And how do prove that 1 follows from 2 by resolution (not by drawing a truth table)? I'm working on a WordPress site for my band and I'd like to mark every 3rd post on our blog page to have a special class applied to it, anybody have any pointers on how to achieve this? Any help is very very appreciated, thanks! rock n roll. I had given an cipher text (of JSON string), an IV and a key. I tried decrypting using 's method:      decryptWithManagedIV(algorithmName, privateKey, IVAndCipherText)     //Sample code   Blob key = Blob.valueOf(decryptionKey);   Blob encryptedDatafor = EncodingUtil.base64Decode(bodystring);   Blob decryptedData = Crypto.decryptwithManagedIV('AES128', key, encryptedDatafor);    cipher = decryptedData.toString();   System.debug('Encrypted BodyString: ' +cipher);   and I was able to decrypt the cipher successfully. But when I use the provided IV with the following method:      decrypt(algorithmName, privateKey, initializationVector, cipherText)    //Sample code  Blob exampleIV = Blob.valueOf('HSDlUkhrmfEo7SgM'); //provided IV   Blob key = Blob.valueOf(decryptionKey);  Blob encryptedDatafor = EncodingUtil.base64Decode(bodystring);  Blob decryptedDataIV = Crypto.decrypt('AES128', key, exampleIV, encryptedDatafor);   cipher = EncodingUtil.base64Encode(decryptedDataIV );  System.debug('Encrypted BodyString: ' +cipher);   I get some string which looks like, it is still in the encrypted form (different from the encrypted string I have passed).   Update:  I have tried the below code-snippet based on the suggestion from @identigral, but I am still unable to decrypt the cipher using the IV:  Blob exampleIV = Blob.valueOf('HSDlUkhrmfEo7SgM'); //provided IV  Blob key = Blob.valueOf(decryptionKey); Blob encryptedDatafor = EncodingUtil.base64Decode(bodystring);  String encodedCipherTextAndIV = EncodingUtil.convertToHex(encryptedDatafor); String encodedCipherText = encodedCipherTextAndIV.substring(32); String finCipher = encodedCipherText.difference(encodedCipherTextAndIV); Blob ciphertext = EncodingUtil.convertFromHex(finCipher);   Blob decryptedDataIV = Crypto.decrypt('AES128', key, exampleIV, ciphertext);  decryptStg = EncodingUtil.base64Encode(decryptedDataIV ); System.debug('Decrypted BodyString: ' +decryptStg); Is the convex hull of a compact set compact? Let $V$ be a normed vector space and $K$ a compact subset of $V$. Is the convex hull of $K$ given by $$\langle K \rangle = \left\{\sum_{i=1}^n t_i x_i\mid x_i\in K, t_i≥0\text{ s.t. }\sum_i t_i=1\right\}$$ again compact? My passport is expiring; can I still travel? How many ways can $b$ balls be distributed in $c$ containers with no more than $n$ balls in any given container? Catalina not allowing to change read/write permissions despite having SIP disabled Currently Running: macOS Catalina 10.15.1 Issue: Ever since I upgraded to Catalina, macOS is not allowing me to change read and write permissions on system protected files, hence, I am not able to tweak the system as per my likes and dislikes. Steps Tried To Solve The Issue: SIP, always remains . So, no question arises regarding any conflict with system integrity protection. I have also tried to force change the permissions on the system files I want to edit using certain brute force commands, which I can't recall the name of, right now. But, I have tried. As of now, I am still unable to change read and write permissions on system protected files and resources.