Search results

1. I EPR and Non-Locality - For and Against

I think this pretty succinctly hits the nail on the head: "local" by itself is a word that people learn by association from other people, seeing examples of things called "local" and others "nonlocal". So arguing about which box quantum physics should be put into is not interesting by itself...
2. Python IDLE and print function...

More precisely, print() prints the default "display" or "aesthetic" string representation of its argument, as returned by calling str() on it. By contrast, Python's interactive interpreter evaluates the expression you give it and tries to display it in source form, as returned by the repr()...
3. LaTeX Wide equation in Revtex 4.2 is overlapping with other content

Okay, that makes sense. I don't know for sure, but it may just have been a problem with RevTeX. Personally I usually avoid using RevTeX when I can since it seems to have trouble with placement of things not unlike what you've seen, particularly when using the pra/prb/etc. options. RevTeX with...

20. List with lists in Python

In case you don't know it already it's maybe worth adding that not only the contents of lists but variables in general are all references (a.k.a. pointers) in Python. This has a visible effect in code like the following: >>> a = [1, 2, 3, 4, 5] >>> b = a >>> b[2] = 99 >>> a [1, 2, 99, 4, 5] This...
21. List with lists in Python

You can use a list comprehension if you want to create a new list without modifying the original one. newlist = [[x, 5*y] for [x, y] in mylist]
22. List with lists in Python

for pair in mylist: pair[1] *= 5
23. XOR algorithm to find the missing number in a given array

This depends on the language. Python integers are not machine register integers; their size is only limited by available memory. Still, this just substitutes one possible problem for others (efficiency, and in very very extreme cases maybe exhaustion of memory) that xor doesn't have. On the...
24. XOR algorithm to find the missing number in a given array

Not a mathematician myself, but it seems the trick works if you have some subset ##S## of an abelian group (of numbers or some other type of object), you're given a subset ##S'## of ##S## with one element missing, and the problem is to identify that missing element. Being a group means each...
25. XOR algorithm to find the missing number in a given array

Just for info, there's a common functional idiom for accumulating a value from a sequence. Python is one of the languages that allows it: from functools import reduce # Only needed in Python 3. A = [2, 3, 1, 4, 6, 7] xor = lambda x, y: x^y # xor(x, y) returns x^y. x1 = reduce(xor, A) x2...
26. Visual C++ array question

The problem you're asking about has nothing special to do with the Microsoft Visual Studio environment. Here's one way to do what you're asking: unsigned int digits[4096][4]; for (unsigned int i=0; i<4096; ++i) { digits[i][0] = (i / 512) % 8; digits[i][1] = (i / 64) % 8...
27. Python Shifting an array one postion to the left -- Non Function Vs Function

Well the exercise says that the solution function should take K as a parameter, so it's really the line 'K = int(input(...' that shouldn't be there. I was meaning to comment on this. There's also a language-independent reason that the OP's solution is slow which is that it rotates the list K...
28. Python Shifting an array one postion to the left -- Non Function Vs Function

The indentation in line 24 is wrong. So the line 'A[len(A)-1] = temp' is outside the 'for x ...' loop in the function version unlike the not-function version.
29. Python Transpose of a non-square matrix (without using ndarray.transpose)

Better, using argument unpacking: list(zip(*xmatrix)) This works for a matrix (list of lists) of any size.
30. Insights Recursion in Programming and When to Use or Not to Use It

The thing with recursive functions is that they save a copy of all the function arguments and local variables on the stack for each recursive call. (Unless your code is tail recursive and your language or compiler recognises and eliminates tail calls, as mentioned earlier.) The factorial is a...