How do I add a div class to the posts in a filter and not the entire filter element?

I am having some troubles with the Isotope filter gallery, as discussed in my Stackoverflow question here.

As per the first point of the accepted answer, I need to add the class .isotope, to the parent (the .row element) to make it work with URL hashes. Otherwise, it only works when you click on the filter links, as you can try on the live webpage.

Here is the element to which the user told me to add the class:

 <div class="isotope row masonry" data-masonry-id="d2546a5a8aed79adf8c0b3b78a16b29f" style="position: relative; height: 969.6px;">

Notice the <div class ="isotope before row masonry bit? That is what I need to add.

However, I can only apply a custom class to the entire Posts element in Elementor. If I do that, it causes the JS to think that it needs to sort the whole grid itself and makes it disappear.

How do I target this specific row element?

Finding the most frequent element, given that it’s Theta(n)-frequent?

We know [Ben-Or 1983] that deciding whether all elements in an array are distinct requires $$\Theta(n \log(n))$$ time; and this problem reduces to finding the most frequent element, so it takes $$\Theta(n \log(n))$$ time to find the most frequent element (assuming the domain of the array elements is not small).

But what happens when you know that there’s an element with frequency at least $$\alpha \cdot n$$? Can you then decide the problem, or determine what the element is, in linear time (in $$n$$, not necessarily in $$1/\alpha$$) and deterministically?

How to add xss script to lable element [closed]

i have a label element like below which allows user to input a text as a lable and i want to test xss injection by injecting a code into the label.

<label for="dafsjhfjksd"></label> and if i enter "> onclick=alert(1); " it stores as

<label for="dafsjhfjksd">"> onclick=alert(1); "</label>

How to achieve this?

Randomly assign n elements to n agents such that each agent only knows its own element

Problem

I’m working on an app that involves shuffling and distributing playing cards to players. As a challenge, I tried to solve this problem in a way that doesn’t require a trusted intermediary.

In other terms, the task is to find a distributed algorithm that

• uniquely assigns $$n$$ agents numbers $$1..n$$
• allows each agent to know nothing about the assignment but its own
• when revealing the assignment, allows other players to verify the assignment

We also assume that knowing other’s assignment is an advantage for each agent, and revealing its own prematurely a disadvantage. Agents are also assumed to be able to talk with each other in a way hidden from all other agents.

Partial solution

The solution I came up with works only under the assumption that adversaries do not collaborate.

The idea is to create a set of $$n$$ nonces, and assign each agent exactly one nonce. The set is then passed from agent to agent in an agreed upon order, hidden from all others, until each agent received the set exactly once. Each time an agent receives the set, it swaps its nonce with a new one, memorizes the new nonce, and confirms receival of the set to the others. This entire procedure is done twice, at which point, all agents have received the set at least once after all other agents swapped their nonces, making it impossible to recognize and hence map the nonces to the other agents.

When the last agent receives the set the second time, it shares it with everyone, and all agents confirm to the others that their nonce is contained in the set. The agents then assign a number to each nonce in the set based on an agreed upon random seed, giving us the required unique assignment.

To allow ownership verification, instead of the nonces, agents put the hash value of their nonce on the set, revealing the actual nonce only when verification is required.

The problem with this solution is that if adversaries are allowed to collaborate, each time an adversary receives the set, they can compare their versions, identify changes and potentially derive which nonce belongs to other agents, allowing them to know what number got assigned to them.

All ideas are appreciated!

Question about numbering of internal nodes in circuit diagrams when one circuit element has more than 1 internal node

I have the following circuit diagram that I’ve added labels for the internal nodes to using outside sources. I understand what an internal node is, however what I’m confused about is– for example– E1 has 2 wires connected to another circuit element, so they’re both internal nodes, but how do I distinguish which is n1? Or is this completely arbitrary?

And why is n2 after E4 here, is it because it has to follow the flow of the circuit?

Sorry for the noob question, my book doesn’t explain this (at least so I’ve read, I could be missing it).

Is there any neutral element for the cryptographic hash function SHA256? (or its variants)

My question is Is is possible to compute a string given that after applying a SHA256 function the result is the same string?

Probability of winning a turn-based game with a random element

I am preparing for a programming exam on probability theory and I stumbled across a question I can’t solve.

Given a bag, which contains some given amount of white stones $$w$$ and some given amount of black stones $$b$$, two players take turns drawing stones uniformly at random from the bag. After each player’s turn a stone, chosen uniformly at random, vanishes, and only then does the other player take their turn. If a white stone is drawn, the player, who has drawn it, instantly loses and the game ends. If the bag becomes empty, the player, who played second, wins.

What is the overall probability that the player, who played second, wins?

I assume it’s a dynamic programming question, though I can’t figure out the recursion formula. Any help would be greatly appreciated. 🙂

Example input: $$w$$ = 3, $$b$$ = 4, then the answer is, I believe, 0.4, which I arrived at after computing by hand all possible ways for the game to go, so not very efficient.

How does each element in the output array of a DFT correspond to a specific frequency?

I have a basic understanding of the Fourier Transform, though I’m trying to use it in a program and I’m confused on the specifics. Based on source code I can find online, the DFT takes a set of samples/numbers, performs a summation for each term, and returns a set of these summations which is the same size as the input set. Suppose I have a periodic function. As I understand it, the output array should contain the amplitudes/weights of each frequency which sum to that function. What I can’t figure out is how each frequency is encoded in the array as just an index. In each example I read, we just assign a summation at each iteration of the inner loop to the next consecutive index in the output array. How are these indices indicative of which frequency they correspond to?

I’m attaching the source code I’m referencing to the bottom of this in case the website I linked to ever goes down.

import cmath def compute_dft_complex(input):     n = len(input)     output = []     for k in range(n):  # For each output element         s = complex(0)         for t in range(n):  # For each input element             angle = 2j * cmath.pi * t * k / n             s += input[t] * cmath.exp(-angle)         output.append(s)     return output 

Check for common element in two arrays using FFT

My task ask me to check whether there is a common element in two arrays $$(x_1,x_2,…,x_n)$$, $$(y_1,y_2,…,y_n)$$ with $$x_i,y_i\in\mathbb{N}$$ using the Fast Fourier Transform(FFT). (I’m aware that there is a simple $$O(n\log(n))$$ algorithm to solve this problem using sorting and binary search.) The tasks hints that we should consider the following product to solve the problem: $$\prod_{i+j=n} (x_i-y_j)$$ The product is obviously zero if there is a common element, but I am still not sure how I could compute it faster via FFT.
… I know how to use FFT to multiply polynoms efficiently, but somehow I seem to overlook something.

How to find the size of gaps between entries in an array so that the first and last element of the array is filled and the gaps are all of equal size?

I have an array a of n entries. I need to place a token on the first and last position of that array, so a[0] = 1 and a[n-1] = 1.

I now want to place additional tokens into that array with a distance inbetween each index i where a[i] = 1 that is greater than 2 (so placing a token on every index is invalid as well as alternating using and not using an entry is invalid). Phrazed differently: I want that sum(a) < n/2 . The gap inbetween each token should be the same, so say with an array of size 16,

a[0] = 1, a[3] = 1, a[6] = 1, a[9] = 1, a[12] = 1, a[15] = 1

would be a solution with a gap size of 2 (distance of 3).

How do I find all gap sizes that are possible to fill said array with the given constraints?

Imagine a street inbetween two crossroads where a lamppost should be placed on each crossroad and then additional lampposts should be placed equidistant to each other and for some reason only natural number distances are allowed.

(The actual problem I want to solve is where to place Sea Lanterns in my Minecraft Project so do not disregard this problem as an assignment question I want a solution for.)