board_1 = [[0]*4]*4 board_2 = [[0,0,0,0], [0,0,0,0], [0,0,0,0], [0,0,0,0]]   both the above methods yield the following list.  [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]   but when we replace an element(3,3) in those list we get different result  board_1[3][3] = 1   this will yield  [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]]   whereas, the below will get the correct output  board_2[3][3] = 1  [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]   why we get two different result?
410
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?
32772
In chapter 2, the section on bitwise operators (section 2.9), I'm having trouble understanding how one of the sample methods works.  Here's the method provided:  unsigned int getbits(unsigned int x, int p, int n) {     return (x &gt;&gt; (p + 1 - n)) &amp; ~(~0 &lt;&lt; n); }   The idea is that, for the given number x, it will return the n bits starting at position p, counting from the right (with the farthest right bit being position 0). Given the following main() method:  int main(void) {     int x = 0xF994, p = 4, n = 3;     int z = getbits(x, p, n);     printf("getbits(%u (%x), %d, %d) = %u (%X)\n", x, x, p, n, z, z);      return 0; }   The output is:     getbits(63892 (f994), 4, 3) = 5 (5)   I get portions of this, but am having trouble with the "big picture," mostly because of the bits (no pun intended) that I don't understand.  The part I'm specifically having issues with is the complements piece: ~(~0 &lt;&lt; n). I think I get the first part, dealing with x; it's this part (and then the mask) that I'm struggling with -- and how it all comes together to actually retrieve those bits. (Which I've verified it is doing, both with code and checking my results using calc.exe -- thank God it has a binary view!)  Any help?
71632
I tried evaluating an arbitrary generator of $[N,G']$, but I can't show it equal to $1$ that way.  Working with examples such as when $G=S_3$ and $N=A_3$, then $[N,G']=[A_3,A_3]=1$ holds, but I don't have an idea about how to prove this is true in general.
7945
What is the difference between &gt;&gt; and &gt;&gt;&gt; in verilog/system verilog? I know that == tests for only 1 and 0, while === tests for 1, 0, X, Z. So how is that similar to the shift operator?
4188
While I was investigating a problem I had with lexical closures in Javascript code, I came along this problem in Python:  flist = []  for i in xrange(3):     def func(x): return x * i     flist.append(func)  for f in flist:     print f(2)   Note that this example mindfully avoids lambda. It prints "4 4 4", which is surprising. I'd expect "0 2 4".   This equivalent Perl code does it right:  my @flist = ();  foreach my $i (0 .. 2) {     push(@flist, sub {$i * $_[0]}); }  foreach my $f (@flist) {     print $f-&gt;(2), "\n"; }   "0 2 4" is printed.  Can you please explain the difference ?    Update:   The problem is not with i being global. This displays the same behavior:  flist = []  def outer():     for i in xrange(3):         def inner(x): return x * i         flist.append(inner)  outer() #~ print i   # commented because it causes an error  for f in flist:     print f(2)   As the commented line shows, i is unknown at that point. Still, it prints "4 4 4".
10523
I know how to do it normally, but I could swear that you could fill out out like a[0] = {0,0,0,0}; How do you do it that way? I did try Google, but I didn't get anything helpful.
5089
For each 𝑘 ∈ ℤ⩾0, let 𝐷𝑘 = {𝑛 ∈ ℤ⩾0 ∶ 𝑘 = 𝑚𝑛 for some 𝑚 ∈ ℤ⩾0}. D1 = {1} D2={1,2} D3={1,3} D4={1,2,4} D5={1,5} Find the following:(write in roster notation) 1.{𝑛 ∈ ℤ⩾0 ∶ 𝑛 ∈ 𝐷𝑘 for some 𝑘 ∈ ℤ⩾0}  {𝑛 ∈ ℤ⩾0 ∶ 𝑛 ∈ 𝐷𝑘 for all 𝑘 ∈ ℤ⩾0}.  My attempt: 1.{1,2,3,4.....} 2.{1} Is my attempt for question 1 correct? I could not think of a more convincing answer and if my answer happens to be correct, can anyone else explain how to derive the answer for both part 1 and 2. Thanks!
18119
I know there is a method for a Python list to return the first index of something:  &gt;&gt;&gt; l = [1, 2, 3] &gt;&gt;&gt; l.index(2) 1   Is there something like that for NumPy arrays?
29781
I have the following problem: A class has 20 students, 16 females, 4 males. Find all possibilities of choosing 6 students so that at least one is male.  I did the following, pick one male from the 4, you have 4 possibilities, then you are left with 19 students, pick 5, so I get 4*${19}\choose{5}$ possibilities.  However, one can notice that if you want no one to be male, then the possibilities are ${16}\choose{6}$, so, one could argue that the solution is instead ${20}\choose{6}$ - ${16}\choose{6}$.  So, which is solution is correct, and why?  $$4* {{19}\choose{5}}$$  or $${{20}\choose{6}} - {{16}\choose{6}}$$
76152
int t=-1'd1; //trying to assign -1 to t; bit vb[7:0]; // simple declaration  bit matrix[0:1][0:7]='{'{0,1,0,0,0,0,0,0},'{0,0,1,0,0,0,0,0},'{1,0,0,1,0,0,0,0},'{0,0,0,0,1,0,0,0},'{0,0,0,0,0,1,0,1},'{0,0,0,0,0,0,1,0},'{0,0,0,0,1,0,0,1},'{0,0,0,0,0,0,0,0}};// initialising multi-dimensional array.  I am using QuestaSim to compile and simulate. this is the report: # -- Compiling module test # ** Error: (vlog-13032) test.v(8): near &quot;=&quot;: Syntax error. # ** Error: (vlog-13032) test.v(9): near &quot;;&quot;: Syntax error.  I am somewhat New to the Verilog. Please help me in fixing these errors.
23113
What's the difference?  What are the advantages / disadvantages of tuples / lists?
121693
To do the equivalent of Python list comprehensions, I'm doing the following:  some_array.select{|x| x % 2 == 0 }.collect{|x| x * 3}   Is there a better way to do this...perhaps with one method call?
94558
\documentclass[12pt]{article}  \usepackage{amsmath,amsthm,amssymb,amsfonts} \usepackage{enumerate}  \newenvironment*{exercise}{}  \newcommand{\R}{\mathbb{R}}  \begin{document}  \begin{exercise}{1.10.} Show that $B=\{[a,b)\subset\R|a&lt;b\}$ is a basis for a topology on $\R$.\\ \begin{enumerate} \item{stuff...} \item{stuff...} \end{enumerate} \end{exercise}  \end{document}   My main concern is that the list numbers in the list and the text in the instructions line up. That is that the S in show is lined up with the 1 and 2 etc in the list.
57200
Proof that the following equality is wrong: $$\mathcal{P}(A\Delta B) \setminus \{\emptyset\} = \mathcal{P}(A) \Delta\mathcal{P}(B) $$ I choose elements of sets $A$ and $B$ so that they are separate.  $A = \{1, 2\}$ $ \mathcal{P}(A) = \{\{1\}, \{2\}, \{1, 2\}, \emptyset\}$ $B = \{3, 4\}$ $\mathcal{P}(B) = \{\{3\}, \{4\}, \{3, 4\}, \emptyset\}$ $A\cup B = \{1, 2, 3, 4\}$ $A\cap B = \emptyset$  Now I see that: On the left side: $\mathcal{P}(A\Delta B) = \mathcal{P}((A\cup B) \setminus (A\cap B)) = \mathcal{P}((A\cup B) $ $ \mathcal{P}((A\cup B) =\{\{1\}, \{2\}, \{3\}, \{4\}, \{1, 2\}, \{1, 3\}, \{1, 4\}, \{2, 3\}, \{2, 4\}, \{3, 4\}, \{1, 2, 3\}, \{1, 2, 4\}, \{1, 3, 4\}, \{2, 3, 4\}, \{1, 2, 3, 4\},\emptyset \} $ $ \mathcal{P}((A\cup B) \setminus \{\emptyset\} =\{\{1\}, \{2\}, \{3\}, \{4\}, \{1, 2\}, \{1, 3\}, \{1, 4\}, \{2, 3\}, \{2, 4\}, \{3, 4\}, \{1, 2, 3\}, \{1, 2, 4\}, \{1, 3, 4\}, \{2, 3, 4\}, \{1, 2, 3, 4\}\} $ On the right side: $\mathcal{P}(A) \Delta\mathcal{P}(B) = (\mathcal{P}(A) \cup \mathcal{P}(B)) \setminus (\mathcal{P}(A) \cap \mathcal{P}(B)) = \{ \{1\}, \{2\}, \{3\}, \{4\}, \{1, 2\}, \{3, 4\} \} $ Therefore: $\{\{1\}, \{2\}, \{3\}, \{4\}, \{1, 2\}, \{1, 3\}, \{1, 4\}, \{2, 3\}, \{2, 4\}, \{3, 4\}, \{1, 2, 3\}, \{1, 2, 4\}, \{1, 3, 4\}, \{2, 3, 4\}, \{1, 2, 3, 4\}\} \neq \{ \{1\}, \{2\}, \{3\}, \{4\}, \{1, 2\}, \{3, 4\} \} $ i.e. $\mathcal{P}(A \,\Delta\,B) \setminus \{\emptyset\} \neq \mathcal{P}(A) \Delta\mathcal{P}(B)$. Is my proof valid? Are there any errors? I could take smaller $A$ and $B$ sets but I was scared that it wouldn't be so obvious that way.
12628
Is there a benefit to using one over the other? In Python 2, they both seem to return the same results:  &gt;&gt;&gt; 6/3 2 &gt;&gt;&gt; 6//3 2
34678
I've a List of this type List> that contains this  List&lt;int&gt; A = new List&lt;int&gt; {1, 2, 3, 4, 5}; List&lt;int&gt; B = new List&lt;int&gt; {0, 1}; List&lt;int&gt; C = new List&lt;int&gt; {6}; List&lt;int&gt; X = new List&lt;int&gt; {....,....};   I want to have all combinations like this  1-0-6 1-1-6 2-0-6 2-1-6 3-0-6   and so on.  According to you is This possibile to resolve using Linq?
72069
Given [1,2,3,4,5], how can I do something like   1/1, 1/2, 1/3,1/4,1/5, ...., 3/1,3/2,3/3,3/4,3/5,.... 5/1,5/2,5/3,5/4,5/5   I would like to store all the results, find the minimum, and return the two numbers used to find the minimum. So in the case I've described above I would like to return (1,5).  So basically I would like to do something like  for each element i in the list map some function across all elements in the list, taking i and j as parameters store the result in a master list, find the minimum value in the master list, and return the arguments i, jused to calculate this minimum value.  In my real problem I have a list objects/coordinates, and the function I am using takes two coordinates and calculates the euclidean distance. I'm trying to find minimum euclidean distance between any two points but I don't need a fancy algorithm.