## Determine the number of distinct roots of the polynomials

Can you help me?

Let F be a field of 125 elements. Determine the number of distinct roots of the
polynomials X124 − 1, X125 − 1 and X186 − 1 in F

## security – Is it possible to use conditional logic to determine where a file shortcut points in Windows 10?

I use a password manager for all of my passwords. The preferred .exe is run from an encrypted USB-Drive (my portable manager that I can use anywhere). I have a backup on my laptop in a VeraCrypt container, and on a server. The Laptop file is obfuscated so someone browsing the File Explorer could not identify it as a password manager.

I prefer to only use my portable version unless I happened to lose it or don’t have access to it.

Is it possible to set up a single Desktop Shortcut with conditional logic, such that for:

``````File pManager = PasswordManager.exe
File U = USB.pManager
File L = Laptop.pManager
File S = Server.pManager

if (USB.isConnected && U.isPresent): Run --> U
if (!USB.isConnected && L.isPresent): Run => L
else (Server.Connect)   // Kudos if there is a way to run SSH cmd to check for server file here
if (S.isPresent): Run=> S
else:
``````

If this is not possible with a shortcut, I think the next option would be creating a shell script or a small app/widget to handle the logic.

## dnd 5e – What range is used to determine the target of the attack made by the creature affected by a Spectator’s Confusion Ray?

The Spectator has an Eye Ray option, Confusion Ray, that says:

[The target] uses its action to make a melee or ranged attack against a randomly determined creature within range.

Unlike the spell Confusion which limits the attack to melee attacks, the Spectator’s victim can be compelled to make a ranged attack.

When determining the random target, are creatures that are outside of the weapon’s normal range but within the weapon’s long range included?

For a specific example, say a Rogue with a light crossbow is hit by the ray and fails their save. On their turn, there are three allies within 80 feet, and the Spectator is 90 feet away. Is there a chance that the Rogue randomly targets the Spectator?

## automation – Is there some way that I could get a nice, simple “signal” to check for to determine how finished the SAFE Network is?

I’ve been following the SAFE Network for a few years now. They’ve been at it for many years prior to me ever hearing about it, and it seems like there will be several more years before they actually release this thing.

Their website is: https://safenetwork.tech/

They don’t even have an RSS feed, but even if they did, it would doubtlessly keep giving me unwanted news/blog items about the progress of the network. I’m not interested in that. I’m only interested in knowing when the network is finally 100% finished, and then I want to know immediately.

My ideal scenario would be to be able to make a cURL request every day to:

``````https://safenetwork.tech/progress.json
``````

Which would spit back:

``````{ "safe-network-finished-percentage": 57 }
``````

Or:

``````{ "safe-network-finished-percentage": 99 }
``````

My script would then notify me when that value is over a certain amount, such as 99 or 98, or indeed 100. (I’ll probably want to read up on the final guides and whatnot slightly before the mass news hit, so that I have some little advantage over the general public.)

The same problem goes for their e-mail list (other than the fact that I don’t want to give them or anyone my e-mail address): they will doubtlessly send many unwanted e-mails “on the way”, whereas I’m purely interested in the project’s status and whether it’s almost or entirely finished.

I simply have no interest in reading their endless forum posts. And this also goes for many other projects to which I would have also loved something like this, because I’m interested enough to want to know when it goes live, but not interested enough to be an active part of their struggle.

## Algorithm to determine if binary tree is a Binary Search Tree (BST)

Continuing with algorithms I’ve implemented a binary search tree validator. I don’t like the two boolean variables within `NodeFollowsBSTContract` as it feels too complicated. I feel like it should be cleaned up but don’t see how, yet.

Also, before each recursive step down, to check child nodes, a new list is created. Is there’s a better way to implement this check that doesn’t repeatedly create new lists?

``````public class BinaryTreeNode
{
public BinaryTreeNode Left { get; set; }
public BinaryTreeNode Right { get; set; }

public int? Value { get; }

public BinaryTreeNode(int value)
{
Value = value;
}
}

public class ValidateBST
{
BinaryTreeNode _root;
public ValidateBST(BinaryTreeNode root)
{
_root = root;
}

public bool IsBinarySearchTree()
{
if ((_root.Left?.Value ?? 0) <= (_root.Value)
|| (_root.Right?.Value ?? 0) > (_root.Value))
{
var listIncludingRootValue = new List<int>()
{
_root.Value.Value
};

var leftLegValid = NodeFollowsBSTContract(_root.Left, new List<int>(), new List<int>(listIncludingRootValue));

var rightLegvalid = NodeFollowsBSTContract(_root.Right, new List<int>(listIncludingRootValue), new List<int>());

return leftLegValid && rightLegvalid;
}
else
{
return false;
}
}

private bool NodeFollowsBSTContract(BinaryTreeNode node, List<int> parentSmallerValues, List<int> parentLargerValues)
{
if (node == null)
{
return true;
}

bool isLessThanAllParentLargerValues = !parentLargerValues.Any()
|| parentLargerValues.Where(value => node.Value.Value <= value).Count() == parentLargerValues.Count;

bool isGreaterThanAllParentSmallerValues = !parentSmallerValues.Any()
|| parentSmallerValues.Where(value => node.Value.Value > value).Count() == parentSmallerValues.Count;

if (!isLessThanAllParentLargerValues || !isGreaterThanAllParentSmallerValues)
{
return false;
}

if (node.Left != null)
{
var updatedLargerValues = GenerateUpdatedLists(node.Value.Value, parentLargerValues);
var updatedSmallervalues = new List<int>(parentSmallerValues);

if (!NodeFollowsBSTContract(node.Left, updatedSmallervalues, updatedLargerValues))
{
return false;
}
}

if (node.Right != null)
{
var updatedvalues = GenerateUpdatedLists(node.Value.Value, parentSmallerValues);

if (!NodeFollowsBSTContract(node.Right, updatedvalues, parentLargerValues))
{
return false;
}
}

return true;
}

private List<int> GenerateUpdatedLists(int addValue, List<int> values)
{
var updatedValues = new List<int>(values)
{
};

return updatedValues;
}
}
``````

## analytic number theory – How to determine the coefficient of the main term of \$S_{k}(x)\$?

Let $$kgeqslant 2$$, suppose that $$p_1,p_2,dotsc,p_k$$ are primes not exceeding $$x$$. Write
$$S_{k}(x) = sum_{p_1 leqslant x} dotsb sum_{p_k leqslant x} frac{1}{p_1+dotsb +p_k}.$$
By AM-GM inequality, $$p_{1}+dotsb + p_{k} geqslant k sqrt(k){p_{1}dotsm p_{k}}$$, we have
$$S_{k}(x) leqslant frac{1}{k} sum_{p_{1}leqslant x}dotsb sum_{p_{k} leqslant x} frac{1}{sqrt(k){p_{1}dotsm p_{k}}} = frac{1}{k} left( sum_{p leqslant x} p^{-frac{1}{k}} right)^{k}.$$
By Prime Number Theorem and (Riemann–Stieltjes) integration by parts we see that
$$sum_{p leqslant x} p^{-frac{1}{k}} = mathrm{Li}big( x^{1-frac{1}{k}} big) + O left( x^{1-frac{1}{k}}mathrm{e}^{-csqrt{log x}} right),$$
Here $$mathrm{Li}(x)$$ is the logarithmic integral, and $$mathrm{Li}(x)sim x/log x$$. Hence
$$S_{k}(x) leqslant left( frac{k^{k-1}}{(k-1)^{k}} +o(1) right) frac{x^{k-1}}{log^{k} x}.$$
On the other hand, $$p_{1}+dotsb +p_{k} leqslant kx$$, we have
$$S_{k}(x) geqslant frac{1}{kx} sum_{p_{1} leqslant x} dotsb sum_{p_{k} leqslant x} 1 = frac{1}{kx} left( sum_{p leqslant x} 1 right)^{k} = frac{pi^{k}(x)}{kx} = frac{(1+o(1))}{k} frac{x^{k-1}}{ log^{k} x}.$$
My question is how to determine the coefficient of the main term of $$S_{k}(x)$$?

## coin selection – Is there a way to determine the optimal size of a batched transaction to save on fees?

I’ve been looking at other questions about fees and batching, but it seems no one asked if there is some way to determine the optimal size of a transaction to save on fees (assuming all inputs are spending from segwit native UTXOs for simplicity).

To expand a bit on what I have in mind: I need to pay various amounts to different people (let’s consider their number can be anywhere between 1 and infinite), and I guess that by making one “big” transaction paying them all at once instead of 1 transaction for each of them I can save on fees. But is it the more people I can add up in the same transaction the better, or would I save less at some point if my transaction keeps getting bigger? Is there some model to calculate the “optimal” size for my batched transaction, or maybe it doesn’t make sense?

Here’s my best guess for now: adding more people means really adding outputs, which makes the transaction grow linearily (assuming all ouputs are pretty standard and roughly of the same size), so assuming the fees are split between each receivers the more people you can onboard on the same transaction the cheaper it gets for everyone.

But at some point the sum of the amounts of the ouputs will grow bigger than the one input I added at first and I’ll need to add another input. If I have relatively big ouputs to spend this is probably ok, but if I only have small outputs and/or I’m adding relatively big amounts in the outputs at some point adding one more output could need to add one or maybe more inputs, making the growth in size transaction not worthing the save in fees, so I’d rather just stop it and send the batch at this point.

## python – Exercism: determine if a word or phrase is an isogram

Determine if a word or phrase is an isogram.
An isogram (also known as a “nonpattern word”) is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times.

Examples of isograms:

• lumberjacks
• background
• downstream
• six-year-old

The word isograms, however, is not an isogram, because the s repeats.

Even though I’m aware that questions about isograms have already been posted, in this variation of the problem spaces and hyphens are allowed to appear multiple times so that you can not use a solution such as `len(string) == len(set(string))`

What bothers me about my solution is hardcoding bounds of `ascii` character ranges and using `collections` library for such a small problem. I’m wondering if there is a better way to do it.

Here is my code:

``````from collections import Counter

ASCII_LOWER_BOUND = 97
ASCII_UPPER_BOUND = 123

def is_isogram(string):
char_counts = Counter(string.lower())
return all(
char_counts(char) == 1
for char in char_counts
if ord(char) in range(ASCII_LOWER_BOUND, ASCII_UPPER_BOUND + 1)
)
``````

And a test suite provided by exercism:

``````import unittest

from isogram import is_isogram

# Tests adapted from `problem-specifications//canonical-data.json` @ v1.7.0

class IsogramTest(unittest.TestCase):
def test_empty_string(self):
self.assertIs(is_isogram(""), True)

def test_isogram_with_only_lower_case_characters(self):
self.assertIs(is_isogram("isogram"), True)

def test_word_with_one_duplicated_character(self):
self.assertIs(is_isogram("eleven"), False)

def test_word_with_one_duplicated_character_from_the_end_of_the_alphabet(self):
self.assertIs(is_isogram("zzyzx"), False)

def test_longest_reported_english_isogram(self):
self.assertIs(is_isogram("subdermatoglyphic"), True)

def test_word_with_duplicated_character_in_mixed_case(self):
self.assertIs(is_isogram("Alphabet"), False)

def test_word_with_duplicated_character_in_mixed_case_lowercase_first(self):
self.assertIs(is_isogram("alphAbet"), False)

def test_hypothetical_isogrammic_word_with_hyphen(self):
self.assertIs(is_isogram("thumbscrew-japingly"), True)

def test_hypothetical_word_with_duplicated_character_following_hyphen(self):
self.assertIs(is_isogram("thumbscrew-jappingly"), False)

def test_isogram_with_duplicated_hyphen(self):
self.assertIs(is_isogram("six-year-old"), True)

self.assertIs(is_isogram("Emily Jung Schwartzkopf"), True)

def test_duplicated_character_in_the_middle(self):
self.assertIs(is_isogram("accentor"), False)

def test_same_first_and_last_characters(self):
self.assertIs(is_isogram("angola"), False)

if __name__ == "__main__":
unittest.main()
$$```$$
``````

## monk – How do I determine the proper bonuses for my attack and damage rolls?

I am a half-orc monk at level 14. I am using a homebrew gun called “the demon of powder”, which has 6 charges that it expends as ammunition instead of regular bullets. My stats are 14 20 14 8 15 10 in order.

The description of the weapon says I get +5 to both hit and damage rolls, but on dndbeyond it says I have +6 to hit and 2d8+6 for damage. My DM said that the regular damage for this weapon is 2d8.

I’m very confused where dndbeyond is getting the bonuses of +6 from.

Additionally, I am wondering if I should manually add in the +5 to hit from the description or if it is already included?

## unity – (Unity3D) Determine If Ray Intersects Given Rectangle

I’m building a city generator for my game and I want to ensure buildings are never placed in such a way that they overlap roads. Currently I have the system build the roads, then place buildings alongside those roads.

I have the beginning and end points of the roads as Vector3s (only using X and Z, Y is never considered for road/building placement). For buildings, I use the size of their Box Colliders to check if they can fit in a given space (with rotation and scale applied appropriately). I’ve done a fair amount of research for answers on lines intersecting planes, though they always seem to be incredibly hard to follow or just don’t properly apply to my situation (such as determining if the line is coterminous or not). I simply need to know if the line at any point exists within the bounds of the building’s rectangle. I do not need to know where or at what angle.

I also understand that my problem is essentially a 2D math problem, as I’m ignoring Y, and some of the 2D solutions I’ve seen to this would be extremely costly to do in city generation.

Any help would be greatly appreciated.