Return all pairs of integers from a given list of integers that have a difference of 2 Like the title says, i need to find the difference of integers in a list by 2 and must return a list with tuples.   initial_list = [1, 2, 3, 4] expected_output = [(1, 3), (2, 4)]   I wrote this code:  arr = [1, 2, 3, 4] n = 2 arr1 = [] for i in range(len(arr)):     x = i + n     if x in arr:         arr1.append(x) print(arr1)   But doesn't work...  Can u help me?  Thx
How do you split a list into evenly sized chunks? I have a list of arbitrary length, and I need to split it up into equal size chunks and operate on it. There are some obvious ways to do this, like keeping a counter and two lists, and when the second list fills up, add it to the first list and empty the second list for the next round of data, but this is potentially extremely expensive.  I was wondering if anyone had a good solution to this for lists of any length, e.g. using generators.  I was looking for something useful in itertools but I couldn't find anything obviously useful. Might've missed it, though.  Related question:
The problem   I have tens of thousands of small polygons for which I want to create buffer/doughnuts for, but I don’t get the units right. I want meters and not degrees, and changing to (what I think is) the right CRS my layer doesn’t longer show. The polygons are small farming plots. I work in QGIS 3.4.15.   Let me take you through it  I start by adding a vector layer. I opt for ‘Directory’ as a source type (Encoding: UTF-8 by default) and under Source (Type: UK. NTF2 by default) I point to the folder in which I store the shapefile.   The default CRS is set to EPSG:4326 – WGS 84, for both layer and the project (checked in bottom right), and unit is thus in degrees. I add the layer world map (EPSG:4326 – WGS 84 by default) by taping “world” in the coordinate box in the middle bottom, I also add Open street map (EPSG:3857 – WGS 84 / Pseudo-Mercator by default) from XYZ Tiles. The polygons appear nicely on the map considering some are just adjacent to the nearby lake, many nicely adjacent to roads, etc.   When attempting to do buffers the distance is obviously set to degrees. I have tried to change the CRS, both for the layer(s) and the projects, but without luck. After researching (e.g. here: ) I believe that the correct CSR would be Arc 1960 / UTM zone 36S EPSG:21036 (it is my understanding that either 36N or 36S would work as the polygons appear both south and north of, but close enough to the equator). When setting the mentioned CRS for my polygon layer, the polygons disappear from the map, and remain gone even after setting the project CSR (by bottom right) to the same. It seems that whenever I try with different CRS in UTM, the layer doesn’t show. Does this mean that the polygons are somehow not compatible with units in meter? Is there an issue with importing the .prj file?  Other things I've tried:   I have made a good attempt searching for solutions. I have ensured that the polygon layer is on top of the layers list. I have ensured the file names are identical and tried all different suitable CRS I can think of. I have seen similar questions been solved by saving the .shp 'as', but I don't think that's my issue as it's already a .shp file. Can it be the case that I need to perform a datum transformation? I gave it a shot using a transformation code (1122) provided by above link, but then the polygons were projected on the Antarctica on the world map, so obviously something went quite wrong...   Note that when I have changed to what I believe is the right CRS I can execute buffers in units of meters, however, they do not appear on the window… What does it mean if a Python object is "subscriptable" or not? R : Format the text file output Rails: Could not find bcrypt-ruby-3.0.1 in any of the sources The latest beta update made the app crash a lot:   when I press 'Add comment'. after deleting a comment. after up/down/unvoting a post (happened when I upvoted an answer) after editing a post (but the edit is applied).   Spec: Nexus 5 on Lollipop 5.1.1, SE App v1.0.66 (beta) Why are potential differences equal across two capacitors in parallel, but charge on each capacitor is not? Two or more capacitors are said to be connected in parallel if each one of them is connected across the same two points. In a parallel combination of capacitors potential difference across each capacitor is same but each capacitor will store different charge. Why is this true? Why is the potential difference across each capacitor in parallel the same and why will each capacitor store different charge?  Also, in series, why are Potential difference across each capacitor different, while charge is the same? Maximum Likelihood Estimate with different parameters Suppose that X and Y are independent Poisson distributed values with means $\theta$ and $2\theta$, respectively. Consider the combined estimator of $\theta$ $$ \tilde{\theta} = k_1 X + k_2 Y $$ where $k_1$ and $k_2$ are arbitrary constants.   Find the condition on $k_1$ and $k_2$ such that $\tilde{\theta}$ is an unbiased estimator of $\theta$. For $\tilde{\theta}$ unbiased, show that the variance of the estimator is minimized by taking $k_1 = 1/3$ and $k_2 = 1/3$. Given observations $x$ and $y$ find the maximum likelihood estimate of $\theta$ and hence show that $\tilde{\theta}$ is also the maximum likelihood estimator.   I have gotten (1) and (2) okay, but it's (3) I am having trouble with, I'd be okay if $X$ and $Y$ had the same parameter but I'm having trouble with $X$ and $Y$ having different parameters, any help would be appreciated.   NOTE   For (1) I got $k_1 = 1 - 2k_2$.   For (2) I found the variance of $\tilde{\theta}$, then differentiated and let equal to zero to minimize - therefore we get (after subbing in $k_2 = 1 - k_1/2 $) $$3k_1-1=0,$$ which when subbing in $1/3$, we see it is minimised.   Thank you. Sum of columns for rows containing a specific term I am trying to under stand how to build a barrel shifter using multiplexers. I understand how the barrel shifter works but I don't get how you decide the number of multiplexers to use, and how the shifting is done with the multiplexer basically.  So far wikipedia doen't help much. And the best I have so far is   But it does not really answer my question. My problem is that, I can not give name of my folder or file with special characters like \ / : * ? " &lt; > | in windows based O.S. This is very important for me, that giving name of file/folder which contain this type of characters.  I already search and refer so many site,for this problems but all are hopeless. I also read Microsoft support page, they suggest use other characters. This is its link,    I already try Alt button + ASCII code number of this type of special characters, from numpad key, just example rename file/folder and press Alt+60 (for &lt; characters) Still it giving message that, A filename cannot contain any of the following characters: \ / : * ? " &lt; > |   Suggest me suitable solution so that I can give name of my file/folder with this type of special characters. Render turns out plain white For some reason, when I render out the image, it is plain white. I've checked the sky settings, and I tried applying textures, but nothing seems to change.  How can I fix this? "Agree" vs. "concur" Windows Server 2008 R2: User account set to not show on login This afternoon I set up a Win Server 2008 R2 system for use with Team Foundation source code control. In order to give my team-mates the right to connect, I had to create a user account for each person, 10 in total. (I can't, and I don't want to create a domain).  Now, after doing this, all user accounts are displayed in the login screen.  What can I do so that all the accounts are not displayed there? It would be nice to allow users to mark a change in an answer (or question) as minor (e.g. for a simple spelling or grammar correction). A change marked as minor wouldn't push the question on top of the list of questions on the home page or in the feeds. It wouldn't trigger any notification. This could be implemented with a "Minor change" checkbox when editing an entry (a la Confluence). What do you think? Can I use one of my attacks to cast a cantrip? In the D&amp;D campaign I am currently participating in, I am playing as a level 5 high elf champion (I actually just reached level 5 at the end of the last session).  As a High Elf, I got a free cantrip at first level, and chose the firebolt cantrip.  Here's what I'm wondering now: for the purposes of the extra attack feature, does firebolt (and similar cantrips) count as an attack? Complex polynomial and the unit circle Given a polynomial $ P(z) = z^n + a_{n-1}z^{n-1} + \cdots + a_0 $, such that   $\max_{|z|=1} |P(z)| = 1 $      Prove: $ P(z) = z^n $      Hint: Use cauchy derivative estimation    $$ |f^{(n)} (z_0)| \leq \frac{n!}{r^n} \max_{|z-z_0|\leq r} |f(z)| $$ and look at the function $ \frac{P(z)}{z^n} $     It seems to be maximum principle related, but I can't see how to use it and I can't understand how to use the hint. Restoring a backup to an older version of SQL Server Customize Ubuntu for a library Internet kiosk Why is my USB drive showing corrupted data when plugged as an internal SATA drive? I have a 3TB Seagate Backup Plus Desktop USB 3.0 drive, which works fine when in its enclosure, but when I get it off its enclosure and directly plug it as an internal SATA drive, it's just not properly recognized (it works again when used in the enclosure). My systems’s motherboard is an , which has two SATA 6.0 Gb/s and four SATA 3.0 Gb/s ports.  When used as an internal SATA drive Windows 7 asks if I want to format the drive, as if it didn’t have a proper filesystem, and if I use the DISKMGMT.MSC tool (typing that in the start menu) I get completely wrong information about the drive.  It says the drive has 3 partitions (349,31GB of RAW data and two unassigned partitions of 1698,68GB and 746,52GB). This information is plain wrong, since the drive, when used in the USB enclosure, works as a single NTFS partition (2794,52GB). How come it’s shown as 3 partitions without filesystem when connected through SATA?!  Is Seagate using some proprietary way of storing the data when using the drive in its provided USB 3.0 enclosure? I didn’t use any kind of encryption. I just plugged the drive with USB 3.0 and started using it straight away, since it apparently came pre-formatted with an NTFS filesystem. I have a Git repo that I have deleted four files from using rm (not git rm), and my Git status looks like this:  #    deleted:    file1.txt #    deleted:    file2.txt #    deleted:    file3.txt #    deleted:    file4.txt   How do I remove these files from Git without having to manually go through and add each file like this:  git rm file1 file2 file3 file4   Ideally, I'm looking for something that works in the same way that git add . does, if that's possible.