How to automatically get the longest line on dendrogram?

Instead of manually guessing the longest vertical line , is there any way to automate it ? Or to clearly highlight it on graph itself ?

p.s : I am aware of Elbow method but I need this info about dendrogram.

My code

# Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd  # Importing the dataset dataset = pd.read_csv('Mall_Customers.csv') X = dataset.iloc[:, [3, 4]].values  # Using the dendrogram to find the optimal number of clusters import scipy.cluster.hierarchy as sch dendrogram = sch.dendrogram(sch.linkage(X, method = 'ward')) plt.title('Dendrogram') plt.xlabel('Customers') plt.ylabel('Euclidean distances') 

Dendrogram Dendrogram

Plotting boundary of 3d topographical plot on a 2D line

I have a table consisting of the points of the following plot: enter image description here

Which looks like this from the top: enter image description here

I would like to plot a line connecting all the dots of the boundary in the first picture, so that I have a 2d plot showing the the variation of height in the topograpghy. The code used for the generation of the plot is a little complicated so I do not want to post the whole code here. If I wanted to plot, say, the boundary of

Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}]  

using a line, how would I be able to do this? Thanks

How to calculate the transformation such that two points with different position, orientation and origins line up?

Let’s say you have two different 3D Objects which both contain a node that is off center (not at the origin) and have an orientation. How do you calculate the transform for one of the object so that both of these nodes line up? As in both nodes end up at the same position in space and the same orientation?

In gaming terms, both 3D objects have “snap” points and I’d like to calculate how to transform one of them so that they snap together at that specific node.

for illustration purposes The cubes are the 3D objects, the X/Y/Z axis represent the origin of each of these objects, and the arrow is the node. The goal would be in this case both arrows overlap and thus the cubes end up at the exact same place. Note the origin is NOT at the same spot for both objects.

Expected length of a random walk on a line

I am given the following randomized algorithm for SAT,

  • Input: A satisfiable CNF-formula $ \varphi$ .
  • Output: An assignment $ \rho$ , such that $ \rho \models \varphi$ .

The algorithm works as follow:

  1. Choose an arbitrary assignment $ \rho$ .
  2. As long as $ \rho \not \models \varphi$
    1. Choose a clause in $ \varphi$ not satisfied by $ \rho$ uniformly at random.
    2. Choose a variable $ x\in_{u.a.r}\operatorname{VAR}(C)$ .
    3. Flip the value of $ \rho(x)$ (set $ \rho(x) = \overline{\rho(x)}$ ).

We have to prove that for a 2-CNF Formula, the algorithm has polynomial expected running time.

I have proven that for a fixed assignment $ \alpha$ , such taht $ \alpha \models \varphi$ , with probability $ p \geq 1/2$ , after each iteration the number of variables that are assigned different values in $ \alpha$ and $ \rho$ decrease by one. With probability $ 1-p$ , the assignments $ \rho$ and $ \alpha$ differ at one extra variable.

Now I have to prove, that the algorithm finished in expected polynomial number of steps. I was able to add one more step of abstraction. Let $ X_i$ be the random variable that indicates the number of steps needed to make $ \rho = \alpha$ , when $ \rho$ and $ \alpha$ differ by exactly $ i$ variables. Then it holds that $ $ E[X_i] = 1 + p E[X_{i-1}] + (1-p) E[X_{i+1}],$ $ and $ X_i \leq X_{i+1}$ for all $ i$ and $ E[X_0]$ is equal to 0. We need to find a polynomial bound for $ E[X_i]$ .

Since $ p\geq 1/2$ and $ X_i \leq X_{i+1}$ , the following must hold $ $ E[X_i] \leq 1 + \frac{E[X_{i-1}] + E[X_{i-1}]}{2}$ $

Now this can bee seen as walking on the integer line, in each step we move either one step to the left or one step to the right and the probability of moving to the left is at least one half. We have to prove that in expected polynomial many steps (polynomial in the starting position), we reach the number $ 0$ on the line.

Any help on this problem is very appreciated 🙂

Is my nerfed version of the Healing Spirit spell in line with the relative power level of other sources of healing?

I have concerns about the immense healing potential that the Healing Spirit spell can put out.

As it appears in Xanathar’s Guide to Everything (page 157), the Healing Spirit spell is able to heal any creature that starts its turn within its effect, or passes through it during their turn. In practice, this spell is limited by the mobility of the party that tries to take advantage of it, but in my experience, the spell is still able to dramatically improve the hitpoint recovery of the whole party, along with minimizing the impact of Unconsciousness or Death Saving Throws. In my experience, campaigns where Healing Spirit is accessible tend to trivialize/obsolete use of features like Hit Dice, Second Wind,

For reference, at its base level, it’s capable of healing any creature that runs through it for 1d6 hit points once per turn for 10 turns. So even if you only hit a single creature, you’re still confidently healing an average of 35 hitpoints to a single creature, and much more than that on more than one creature. And all of that scales with the level of the spell. The spell, once cast as a Third Level Spell, is strictly better than the Paladin-exclusive spell Aura of Vitality (also a third level spell), which has action-economy restrictions and does not scale with level, and unlike Aura of Vitality, Healing Spirit is accessible to a full-spellcaster capable of upcasting the spell and casting the spell many more times in a day.

It’s also been my experience that banning “out of combat” use of the spell doesn’t help much, since it only takes a single combat encounter being dragged out to permit optimal use of this spell.

I could choose to ban the spell entirely, but I want to consider a compromise first before I resort to that. So for my campaigns, I’m proposing the following version of the spell designed to keep some of its power as a healing spell while tempering its more ludicrous features:

Healing Spirit

2nd-level conjuration
Casting Time: 1 bonus action
Range: 60 feet
Components: V, S
Duration: Concentration, up to 1 minute

You call forth a nature spirit to soothe the wounded. The intangible spirit appears in a space that is a 5-foot cube you can see within range. The spirit looks like a transparent beast or fey (your choice).

Until the spell ends, whenever you or a creature you can see moves into the spirit’s space for the first time on a turn or starts its turn there, you may use your reaction to cause the spirit to restore 1d6 hit points to that creature. The spirit can’t heal constructs or undead.

As a bonus action on your turn, you can move the spirit up to 30 feet to a space you can see.

The two changes are the following:

  • Instead of being a free action, healing with this feature now requires the use of the spellcaster’s Reaction
  • The ability to gain benefits by upcasting the spell have been removed

So in general, this is a significant nerf to the spell. It becomes unable to be upcast, and it can only heal one creature per turn. It puts the spell more in line with the relative power of spells like Aura of Vitality while still making it accessible very early for low level druids. I think the spell will still be competitive in terms of raw healing output and for helping keep allies alive, while keeping it from trivializing all other possible sources of healing.

Does this version of the spell bring it more in line with the relative power level of other sources of Healing? Or are my assumptions/observations about the power of the original spell off-base?

When spells can be moved, must it be in a straight line?

Healing Spirit (XGtE) says:

As a bonus action on your turn, you can move the Spirit up to 30 feet to a space you can see.

Moonbeam (PHB) says:

On each of your turns after you cast this spell, you can use an action to move the beam 60 feet in any direction

Can I move these spells to several points? For example, if my targets are arranged in a triangle formation, 10ft from each other, and my spell is currently on top of one of those targets, can I move the spell over all 3 of them before ending in a space?

On one hand, Moonbeam specifies direction, so it can be interpreted as just choosing a direction, and the spell only moves in that line. However, the spell also mentions any direction, so that can also be interpreted as moving any way you like.

Healing Spirit moves to a specific space. Can I choose the path the Spirit takes? Or can I only choose a single space as the destination, and the Spirit will take the shortest path there?

The reason I want to do this is that it would allow me to, for example, heal multiple targets with Healing Spirit.

whenever you or a creature you can see moves into the spirit’s space for the first time on a turn or starts its turn there

And for the Moonbeam, I could damage multiple enemies.

When a creature enters the spell’s area for the first time on a turn or starts its turn there

The description does not say that the creatures has to move into the spirit’s space on its turn, just a turn. I’m also assuming that moving the spirit on top of the creature would have the same effect.

Using Lean Theorem Prover from command line [closed]

I have read this link about using Lean: and am able to use Lean with VSCode, but I still have questions about using Lean from the command line.
1. When I download the lean binaries, there is a lean and leanchecker binary. What does each one do, and is there any documentation on using them?
2. What is LEAN_PATH? I wrote a Lean file that uses the Lean library list type. I want this to to be checked from the command-line, that is when I write a #check command in the file, on VSCode the #check is underlined in blue letting me know that it checks; I want to do the equivalent from the command-line. But when I run the Lean binary on my file, it says ‘error: file ‘data/list’ not found in the LEAN_PATH’. Now, I have the entire Lean repository ( in my system and it also contains the built binaries – this is what it took to get Lean to work on VSCode (that and telling VSCode where the head of the repository is). Also, the head of this repository is in my PATH but what does it mean for data/list to be in my LEAN_PATH?

I’m not able to find documentation for these specifics, most of them talk about using Lean from VSCode or Emacs. If I missed it, please point me to the right resource. Thanks!

Where is the line drawn for ethical hackers using stolen credentials in their paid services?

The very interesting question I have is when “ethical” hackers/pen testers harvestthese repositories of stolen credentials to then use them in pen testing for paying clients what ethical boundaries are broken? What laws are broken? If a lazy hacker leaves their captured credentials out on un insecure, public facing server and then an “ethical” hacker grabs them for their own paid services, it seems to me that it’s stealing already stolen goods.

What about a penetration tester taking credentials gathered from a paid/contracted job and adding them to a database to be used in future client jobs?

is there something like a “foreach” mode from the command line? Like in perl?

With perl we can run perl -p . That wraps a foreach loop around the code and executes the code on the file. What I’m looking for is something like


and then I get a new file in which the string replace happened (the above would convert a .tsv to a .csv). Doesn’t have to be StringReplace, can be anything that takes a line of stuff as input. Total[filename] would total all numbers in the rows of the file.

That is like “scripting” the M command line-by-line (during MS-DOS we used to call that “batch mode” — really means line-by-line).