algebra precalculus – Find the number of small dogs in show — word problem

Let’s draw a picture here to help us picture what’s happening. There are $$42$$ dogs in show, of various sizes, which I shall represent with the following $$7 times 6$$ array:

$$begin{matrix} ? & ? & ? & ? & ? & ? & ? \ ? & ? & ? & ? & ? & ? & ? \ ? & ? & ? & ? & ? & ? & ? \ ? & ? & ? & ? & ? & ? & ? \ ? & ? & ? & ? & ? & ? & ? \ ? & ? & ? & ? & ? & ? & ? end{matrix}$$

I put $$?$$ into it to show that we don’t know the size of the dogs. Now, we know that there are $$36$$ more small dogs than big Dogs. So, at least, we know $$36$$ of these are small dogs:

$$begin{matrix} d & d & d & d & d & d & ? \ d & d & d & d & d & d & ? \ d & d & d & d & d & d & ? \ d & d & d & d & d & d & ? \ d & d & d & d & d & d & ? \ d & d & d & d & d & d & ? end{matrix}$$

If we remove these dogs from the show, we get just $$6$$ dogs:

$$begin{matrix} ? \ ? \ ? \ ? \ ? \ ? end{matrix}$$
Importantly, now there are the same number of small dogs left as big Dogs, so half of these remaining dogs are small, and half are big, making our diagram look like this:

$$begin{matrix} d \ d \ d \ D \ D \ D end{matrix}$$

If we add the other $$36$$ dogs back, our show looks like this in total:

$$begin{matrix} d & d & d & d & d & d & d \ d & d & d & d & d & d & d \ d & d & d & d & d & d & d \ d & d & d & d & d & d & D \ d & d & d & d & d & d & D \ d & d & d & d & d & d & D end{matrix}$$

So, as you can see, there are $$3$$ big Dogs, and the other $$39 = 36 + 3$$ are small dogs.

It’s all well and good to do some operations, but you should try to keep track of what the numbers you get actually mean in terms of the real world!

algorithms – If in a given text the frequency of the letter A is 0.5, then the number of bits encoding in the Hoffman code for the text is 1

Suppose that no symbol has frequency $$0$$ (otherwise the claim is false).

Consider the tree $$T$$ built by the standard greedy algorithm to construct the Huffman code. This algorithm maintains a forest $$F$$ where each node $$v$$ is associated with a frequency $$f_v$$. Initially $$F$$ contains a collection of isolated vertices, one per input symbol (with the corresponding frequencies).
Then the algorithm greedly selects the two trees $$T_1, T_2 in F$$ rooted in the vertices with minimum frequencies and replaces them with the tree obtained by merging $$T_1$$ and $$T_2$$ into a single tree via the addition of new root $$r$$. The frequency $$f_r$$ of $$r$$ is the sum of the frequencies of the roots of $$T_1$$ and $$T_2$$.

Let $$a$$ be the node corresponding to symbol $$A$$ and
suppose towards a contradiction that the depth of $$a$$ in $$T$$ is at least $$2$$.
Let $$a’$$ and $$b$$ be the parent and the sibling of $$a$$ in $$T$$, respectively.
Since $$a’$$ cannot be the root (it has depth $$ge 1$$), it must have a sibling $$x$$. Some vertex $$y$$ of the subtree of $$T$$ rooted in $$x$$ was the root of a tree in $$F$$ when the isolated vertex $$a$$ was merged. Therefore the frequency of $$y$$ is at least the frequency of $$a$$ (othewise either $$a$$ or $$b$$ would have been merged with $$y$$ instead).

This is a contradiction since $$f_a + f_b + f_y ge 0.5 + f_b + 0.5 = 1 + f_b > 1$$.

python – Vectorized code to find the position and number of repeating 1s in a bit matrix

I’m trying to write something like an adjusted run-length encoding for row-wise bit matrices. Specifically I want to “collapse” runs of 1s into the number of 1s in that run while maintaining the same number of 0s as original (right-padding as necessary). For example:

``````input_v = np.array((
(0, 1, 0, 0, 1, 1, 0, 1),
(0, 0, 1, 0, 1, 1, 1, 0)
))

expected_v = np.array((
(0, 1, 0, 0, 2, 0, 1),
(0, 0, 1, 0, 3, 0, 0)
))

``````

My current attempt works after padding, but is slow:

``````def count_neighboring_ones(l):
o = 0
for i in l:
if i == 0:
return o
o += 1

def f(l):
out = ()
i = 0
while i < len(l):
c = count_neighboring_ones(l(i:))
out.append(c)
i += (c or 1)
return out
``````

Are there some vectorization techniques I can use to operate on the entire matrix to reduce row-wise operations and post-padding?

lineageos – DROP instead of REJECT calls from specific spammer without adding their number to my contact

I am running Lineage OS micro G (Android Q, version 10) with F-Droid as the app store. I always keep my phone on vibration mode because of my personal preference. I want to Blocking a call without the calling party knowing it but I don’t want to add the spammer’s number to my contact.

To be precise, I want that specific spammer to believe that I don’t pick up the call and let it vibrates until it times out, without my phone actually vibrating. Using Linux firewall (iptables) as an analogy, I want to `DROP` packets instead of `REJECT` packets. The solution mentions in the above question seems to require me to add the spammer’s number to my contact. I don’t want to do this.

I am fine with using 3rd party apps, but they should be FOSS only.

sql server – SQL – Counting number of friends

I have a table representing sending msgs between friends on FB:

``````    Sender    Receiver   Msgs #

Dave       John        6
John       Dave        1
Sam        Dave        2
Mark       Ash         1
Ash        Dave        3
Mark       Steve       8
``````

What is an SQL query to show how many have 1,2,3… friends:

``````    Num of friends       Quantity
3                 1
2                 2
1                 3
``````

Prove mutual exclusion – Multiprogramming with arbitrary number of components

Given the following multiprogram with arbitrary number of components:

``````Pre: m = 0 and n = 0
Comp.p: *[ ncs.p
; x.p, m := m, m+1
; if x.p = n -> skip fi
; cs.p
; n := n + 1
]

``````

Using Dijkstra’s guarded commands language, what should the Invariant be to prove mutual exclusion?

filters – Woocommerce : How to automatically input “digits” phone number filed to woocommerce billing_phone filed for every order?

I use woocommmerce to sell online courses in my website. also I use a plugin called “Digits” to help users easily login/register using only their mobile phone numbers and OTP sent to them as sms.

So the login/register in our website, just requires entering mobile phone number.

and because of that, we removed billing_phone field from woocommerce checkout form because every user is required to register with their phone number even before accessing the checkout page.

the question is : how to automatically add the “digits” phone number to woocommerce billing_phone filed in every order using maybe some filters and/or hooks?

Hotspot limit for number of connections?

I play Pokemon Go and have some phones that need to connect to a phone for its Hotspot for Internet.

I found that iPhone / iOS can serve as a hotspot, but has a limit of up to 5 connections for Hotspot. Is there a limit for Android phones acting as a hotspot? I have a Samsung A32, OnePlus Nord, and some Xiaomi phones such as 11i and 11 Lite 5G.

security – Sharing a requested secret number not knowing which

Alice has a list of secret numbers. Alice wants to give Bob the opportunity to choose one of her secret numbers, and then Alice has to share that specific secret number, but in such a way that Alice can’t know which secret number Bob got to know. Is this known to be possible?

warning messages – Find operation that will produce greatest number from list

``````findExtremeOps(list_) :=
(If(add(list) >= sub(list), maxNum = add(list) && maxOp = "addition",
maxNum = sub(list) && maxOp = "subtraction");
If(mult(list) > max(list),
maxNum = mult(list) && maxOp = "multiplication",
If(div(list) > max(list), maxNum = div(list) && maxOp = "division",
If(exp(list) > max(list),
maxNum = exp(list) && maxOp = "exponentiation",
checkExtremeOps(list, maxNum, maxOp)))))

checkExtremeOps(list_, maxNum_, maxOp_) :=
(If(maxOp ==
"addition", (If(maxNum == sub(list), addSub = true, null);
If(maxNum == mult(list),
If(addSub == true, addSub = false && addSubMult = true,
addMult = true), null);
If(maxNum == div(list),
If(addSub == true, addSub = false && addSubDiv = true,
If(addSubMult == true,
addSubMult = false && addSubMultDiv = true,
If(addMult == true, addMult = false && addMultDiv = true,
addDiv = true))), null);
If(maxNum == exp(list),
If(addSub == true, addSub = false && addSubExp = true,
If(addMult == true, addMult = false && addMultExp = true,
If(addSubMult == true,
addSubMult = false && addSubMultExp = true,
If(addDiv == true, addDiv = false && addDivExp = true,
If(addSubMultDiv == true,
addSubMultDiv = false && addSubMultExp = true,
addExp = true))))))), null);
If(maxOp ==
"subtraction", (If(MaxNum == mult(list), subMult = true, null);
If(maxNum == div(list),
If(subMult == true, subMult = false && subMultDiv = true,
subDiv = true), null);
If(maxNum == exp(list),
If(subMult == true, subMult = false && subMultExp = true,
If(subDiv == true, subDiv = false && subDivExp = true,
If(subMultDiv == true,
subMultDiv = false && subMultDivExp = true,
subExp = true))))), null);
If(maxOp ==
"multiplication", (If(MaxNum == div(list), multDiv = true, null);
If(maxNum == exp(list),
If(multDiv == true, multDiv = false && multDivExp = true,
multExp = true))), null);
If(maxOp == "division",
If(MaxNum == exp(list), DivExp = true, null), null);
displayExtremeOps(maxNum, maxOp, addSub, addSubMult, addSubMultDiv,
addSubMultDivExp, addMult, addMultDiv, addMultDivExp, addDiv,
addDivExp, addExp, subMult, subMultDiv, subMultDivExp, subDiv,
subDivExp, subExp, multDiv, multDivExp, multExp, divExp))

displayExtremeOps(maxNum_, maxOp_, addSub_, addSubMult_,
addSubMultDiv_, addSubMultDivExp_, addMult_, addMultDiv_,
addMultDivExp_, addDiv_, addDivExp_, addExp_, subMult_, subMultDiv_,
subMultDivExp_, subDiv_, subDivExp_, subExp_, multDiv_,
multDivExp_, multExp_, divExp_) :=
(StringForm(
"The operation that produces the greatest value is `` with a value
of ``.", maxOp, maxNum);
(*still need to check for same numbers*))

add(list_) :=
(For(i = 1, i <= length(list), i++, sum += list((i));
Return(sum)))

sub(list_) :=
(diff = list((1));
For(i = 2, i <= length(list), i++, diff -= list((i));
Return(diff)))

mult(list_) :=
(prod = list((1));
For(i = 2, i <= length(list), i++, prod *= list((i));
Return(prod)))

div(list_) :=
(quot = list((1));
For(i = 2, i <= length(list), i++, quot /= list((i));
Return(quot)))

exp(list_) :=
(res = list((1));
For(i = 2, i <= length(list), i++, res ^= list((i));
Return(res)))
``````

Things got messy when I realized I had to check for same numbers. I probably did not take the best route but this is just for a school project. Not sure what I’m doing wrong here. Here’s what I get when I test it. Note: I still need to add the portion in the display function where I check which values are same, if at all.

Input: findExtremeOps({1, 2, 3, 4, 5})

Output:

``````If(Null > max({1, 2, 3, 4, 5}),
maxNum = mult({1, 2, 3, 4, 5}) && maxOp = "multiplication",
If(div({1, 2, 3, 4, 5}) > max({1, 2, 3, 4, 5}),
maxNum = div({1, 2, 3, 4, 5}) && maxOp = "division",
If(exp({1, 2, 3, 4, 5}) > max({1, 2, 3, 4, 5}),
maxNum = exp({1, 2, 3, 4, 5}) && maxOp = "exponentiation",
checkExtremeOps({1, 2, 3, 4, 5}, maxNum, maxOp))))
``````

Thanks for your help!