I am using simpson’s 1/3 rule in c++ to try to find the integral of k*(x*x), where k=2*m and ‘m’ goes from 1 to 10, hence I have to do 10 integrals. When I wrote the code below I got the answers but its adding the value of integral from the previous one! e.g. for […]

# Tag: B: [1

I have a scenario like this. Say: let a = [2,5,6] and let b = [1,2,3,4,5,6,7,8]. Array b is displayed in boxes and revealed when one clicks any of the boxes. What I am trying to do is, when one clicks on any box and the value is the same as any value in array […]

Suppose my input is: marcel bentok tanaka Output should be m-1,a-4,r-1,c-1,l-1,e-2,l-1,b-1,n-2,t-2,o-1,k-2 I don’t want to count spaces and don’t want to use dict or import functions.How can I achieve this in the easiest way possible? Please do help. I tried searching online,but all of them display output in dict format i.e., {m-1,a-4,r-1,c-1,l-1,e-2,l-1,b-1,n-2,t-2,o-1,k-2} I am just […]

I asked the question(How to mutate a new column by modifying another column?) Now I have another problem. I have to use more ‘untidy’IDs like, df1 <- data.frame(id=c(“A-1″,”A-10″,”A-100″,”b-1″,”b-10″,”b-100”),n=c(1,2,3,4,5,6)) from this IDs, I want to assign new ‘tidy’ IDs like, df2 <- data.frame(id=c(“A0001″,”A0010″,”A0100″,”B0001″,”B0010″,”B0100”),n=c(1,2,3,4,5,6)) (now I need capital ‘B’ instead of ‘b’) I tried to use str_pad […]

Given two numbers $a, b \in \mathbb{Z}$ with $gcd(a, b) = 1$, the set $P = \{(k \cdot a, k \cdot b) \; | \; k \in \mathbb{Z}\}$ is the intersection of points on the line $g: ax = by$ and the integer points $I = \{(x, y) \; | \; x,y \in \mathbb{Z}\}$ in […]

Given two numbers $a, b \in \mathbb{Z}$ with $gcd(a, b) = 1$, the set $P = \{(k \cdot a, k \cdot b) \; | \; k \in \mathbb{Z}\}$ is the intersection of points on the line $g: ax = by$ and the integer points $I = \{(x, y) \; | \; x,y \in \mathbb{Z}\}$ in […]

Consider the following game (two players, two actions): (1) Find values of $A$, $B$, $C$, and $D$ such that this game has no pure strategy Nash equilibrium. If we set A=1, C=-1, B=-1, D=1, than this game has no pure strategy (matching pennies example). (2) Find values of A, B, C, and D such that […]

Find all positive integer pairs $(a, b)$ such that $$(ab + a + b) \mid (a^2 + b^2 + 1)$$ Let $a^2 + b^2 + 1 = k(ab + a + b), k \in \mathbb N, k \ge 1$. For $k = 1$, we have that $$a^2 + b^2 – ab – a – b […]

To start, I have a DataFrame that looks like the following: df = pd.DataFrame({‘a’: [25, 22, -2, 16, 10], ‘b’: [-5, 18, -2, 25, 48], ‘c’: [34, -12, 7, 8, 22], ‘d’: [10, 8, -2, -4, 12]}) Goal: Eliminate all zeroes using a specific script or function that preserves the effect of the negative value […]

In Python 3.x, I have a list of lists: [[‘a’,’b’,’c’], [‘a’, ‘c’], [‘c’, ‘d’] ] I saw this answer, but it only applies to a single list. How would I do this for a list of lists? My desired output would be a sorted list (or a sortable list) of the frequency of a particular […]