[Solved] I can’t figure out this sequence – 11110000111000110010

There are many possible solutions to this problem. Here’s a reusable solution that simply decrements from 4 to 1 and adds the expected number of 1’s and 0’s. Loops used : 1 def sequence(n): string = “” for i in range(n): string+=’1’*(n-i) string+=’0’*(n-i) return string print sequence(4) There’s another single-line elegant and more pythonic way … Read more

[Solved] Coordinate system transformation, 3d projection to 2d plane

The problem can be expressed as finding the 3-by-3 matrix M such that the coordinates of a point P can be converted between the old coordinate system (P_old, 3 rows) and the new coordinate system (P_new, 3 rows). This is an affine transformation: P_old = Center + M * P_new (1) The (matrix-vector) multiplication with … Read more

[Solved] Tell me what’s wrong with this code GOLANG

Actually the code in question works on unix systems, but usually the problem is that calls like fmt.Scanf(“%f”, &x1) does not consume newlines, but quoting from package doc of fmt: Scanning: Scan, Fscan, Sscan treat newlines in the input as spaces. And on Windows the newline is not a single \n character but \r\n, so … Read more

[Solved] Math-pow incorrect results

Your question is very unclear; in the future, you’ll probably get better results if you post a clear question with a code sample that actually compiles and demonstrates the problem you’re actually having. Don’t make people guess what the problem is. If what you want to do is display a double-precision floating point number without … Read more

[Solved] How to divide items equally in 4 boxes? [closed]

Create a function that gets a product weight and returns a bag number – the one which has the least free space that’s still enough to fit. Put it in the bag. Repeat until done. $bags = array(60,80,20,10,80,100,90); $containers = array(1=>100,2=>100,3=>100,4=>100); // number -> free space $placement = array(); rsort($bags); // biggest first – usually … Read more

[Solved] Why does Math.round(1.53*20)/20 = 1.55? How does this actually work?

Math.round() will return the nearest integer value as described here For your input Math.round(1.53*20)/20 it will first calculate 1.53*20 answer is 30.6 Then your expression becomes Math.round(30.6)/20 After that result of Math.round(30.6) is 31 (nearest integer) Then your statement becomes 31/20 which is 1.55 solved Why does Math.round(1.53*20)/20 = 1.55? How does this actually work?