How to compute a vector V when N points are given and V satisfies given properties

We are given N points P1,P2,…,PN in a 2D plane(All points are distinct and N is as large as 10^5). For each valid i, the coordinates of the point Pi are (xi,yi). Help me to find a vector V = (a, b) ( where |a|, |b| <= 1e9) such that the following holds:

For each i (1 ≤ i ≤ N), let Si= dot(V, G(Pi, Pi+1)). lets assume PN+1=P1. where G(v1, v2) = ((v2(x) – v1(x)), (v2(y) – v1(y)) and dot(V1, V2) denotes dot product of two vectors

How to choose V such that It is possible to find two integers l and r (1 ≤ l ≤ r ≤ N) such that:

Si < 0 if(i <= r and i >= l) and Si > 0 otherwise

(or)

Si > 0 if(i <= r and i >= l) and Si < 0 otherwise

I need to know if there is a way of choosing vector (a, b) to satisfy the above conditions(If the solution is possible)

Best way to code a shopping cart consisting of items with different properties

This is an interview question. Interviewer wanted a scalable solution

Goal is to find value of shopping cart. Cart could have 3 different types of items(Physical,Digital,URL).

Only Physical Items have a shipping address.

Only Digital items have a redeemable code that is used in a merchant site.

Only URL items have a URL that gives access to some online resource.

I’ve suggested having an Item class with price property which is extended by classes PhysicalItem, DigitalItem, UrlItem. Objects of these classes added to list which is iterated over to find the total order amount. Interviewer wasn’t impressed.

Is there any good design pattern/approach that is best applied here?

Is an improvised weapon treated as similar enough to a weapon to use its properties still considered “improvised”?

In PHB, the 2nd paragraph of the description of Improvised Weapons (p. 147) states:

In many cases, an improvised weapon is similar to an actual weapon and can be treated as such. For example, a table leg is akin to a club. At the DM’s option, a character proficient with a weapon can use a similar object as if it were that weapon and use his or her proficiency bonus.

If I am understanding this correctly, then the mentioned table leg (or similar object) can be treated as a club. If that is correct, then it would have the light property, as the club has it. If that is also correct, that would mean I can wield a light weapon in one hand and an improvised club-like weapon in other hand, and use Two-Weapon Fighting with those, as both are light.

If all of that is still correct, then can an improvised weapon that is similar enough to a real weapon – e.g. a table leg used as a club – still be treated as an improvised weapon for the purpose of the last bullet point in the Tavern Brawler feat (PHB, p. 170)?

Specific scenario that I am wondering about: I wield a Scimitar (a light weapon) in one hand and a table leg (treated as a club, so also light) in the other hand. On my turn, I attack with the table leg as my Attack action. Then one of two things happen:

  1. I miss – then, as both wielded weapons are light, I proceed to attack with my scimitar (per Two-Weapon Fighting)

  2. I hit – then I drop one of my weapons to free one of my hands and attempt to grapple the target.

Of course this is assuming that I have the Tavern Brawler feat, which states:

  • You are proficient with improvised weapons.
  • Your unarmed strike uses a d4 for damage.
  • When you hit a creature with an unarmed strike or an improvised weapon on your turn, you can use a bonus action to attempt to grapple the target.

Does all of that work as I’ve described, or is there somewhere a flaw in my reasoning?

Properties of Javelin Quiver?

One of my players wishes to carry javelins. It seems logical that these could be carried in a quiver (appropriately sized of course) that would reside on the wearer’s back and would serve a similar function as a quiver does for arrows.

We cannot find any reference material for such a thing (how much it would cost, how many javelins it would hold). Is there a place where such a thing is specified?

What properties of a discrete function make it a theoretically useful objective function?

A few things to get out of the way first: I’m not asking what properties the function must have such that a global optimum exists, we assume that the objective function has a (possibly non-unique) global optimum which could be theoretically found by an exhaustive search of the candidate space. I’m also using "theoretically useful" in a slightly misleading way because I really couldn’t understand how to phrase this question otherwise. A "theoretically useful cost function" the way I’m defining it is:

A function to which some theoretical optimisation algorithm can be applied such that the algorithm has a non-negligible chance of finding the global optimum in less time than exhaustive search

A few simplified, 1-dimensional examples of where this thought process came from: graph of a bimodal function exhibiting both a global and local maxima

Here’s a function which, while not being convex or differentiable (as it’s discrete), is easily optimisable (in terms of finding the global maximum) with an algorithm such as Simulated Annealing.

graph of a boolean function with 100 0 values and a single 1 value

Here is a function which clearly cannot be a useful cost function, as this would imply that the arbitrary search problem can be classically solved faster than exhaustive search.

graph of a function which takes random discrete values

Here is a function which I do not believe can be a useful cost function, as moving between points gives no meaningful information about the direction which must be moved in to find the global maximum.

The crux of my thinking so far is along the lines of "applying the cost function to points in the neighbourhood of a point must yield some information about the location of the global optimum". I attempted to formalise (in a perhaps convoluted manner) this as:

Consider the set $ D$ representing the search space of the problem and thus the domain of the function and the undirected graph $ G$ , where each element of $ D$ is assigned a node in $ G$ , and each node in $ G$ has edges which connect it to its neighbours in $ D$ . We then remove elements from $ D$ until the objective function has no non-global local optima over this domain and no plateaus exist (i.e. the value of the cost function at each point in the domain is different from the value of the cost function at each of its neighbours). Every time we remove an element $ e$ from $ D$ , we remove the corresponding node from the graph $ G$ and add edges which directly connect each neighbour of $ e$ to each other, thus they become each others’ new neighbours. The number of elements which remain in the domain after this process is applied is designated $ N$ . If $ N$ is a non-negligible proportion of $ \#(D)$ (i.e. significantly greater than the proportion of $ \#(\{$ possible global optima$ \})$ to $ \#(D)$ ) then the function is a useful objective function.

Whilst this works well for the function which definitely is useful and the definitely not useful boolean function, this process applied to the random function seems incorrect, as the number of elements that would lead to a function with no local optima IS a non-negligible proportion of the total domain.

Is my definition on the right track? Is this a well known question I just can’t figure out how to find the answer to? Does there exist some optimisation algorithm that would theoretically be able to find the optimum of a completely random function faster than exhaustive search, or is my assertion that it wouldn’t be able to correct?

In conclusion, what is different about the first function that makes it a good candidate for optimisation to any other functions which are not.

Spring Boot, Set Up Spring Properties From Java Pojo not from application.properties

I have been struggling to set up spring boot properties programmatically. I know how to set up from application.properties file.

but I would like not to use the application.properties because in my use case application properties file is encrypted I mean the file itself is encrypted. (not the industry-standard way like data encryption). So I would like to read the encrypted file and set spring properites without saving the decrypted file on the server. I am able to decrypt and save in java object but i do not know how to set those properties for app.

Can a magical net be repaired and keep its properties?

This is a follow-up to this question: Can a magical net be destroyed?

Let’s say you have a +1 net which you throw at a target. The target then uses one of its attacks to attack the net, touching it and dealing enough damage to break it.

After defeating the target, you take the pieces of your destroyed net and mend them back together (using the Mending cantrip). Would that give you back your +1 net, or just a plain non-magical one?

This question is in the scope of Adventurers League, where it is indeed possible to get a +X net (if the magic item is a +X weapon if any kind).

How to get/set specific properties of a video texture in pixi.js?

I managed to get a video to play in Pixi using the following line:

    this._texture = PIXI.Texture.from(require("Images/video.mp4")); 

The problem is that I can’t find any properties to do things such as pausing it, forwarding/backwarding, adjusting volume, adjusting playing-speed etc.

Neither the PIXI.Texture or PIXI.Sprite seem to have any properties for this. Is this legitimately all the control PIXI gives you or am I missing something?

Could Adamantine armors (and Mithral armors) have magical properties (+1 for exemple) in 5e?

As an ex player of D&D 3.5, I’m a little bit confused about Adamantine armors and Mithral armors. In 3.5e, they are not magical, it just classic armor with a different material. So they can have magical properties.

However, in 5e, they are considered magic items in some way, but not in other (see the first related question’s accepted answer). So that why I’m here to ask “Could Adamantine armors (and Mithral armors) have magical properties (+1 for exemple) in 5e?”


related:

Are weapons and armor made of Mithral or Adamantine considered magical?

Which works best to describe character, item or dungeon properties: Affix or Trait?

I am working on an RPG portion of my game called “The Underground King“.

My item generator uses the same properties that also apply to characters, vehicles and racing levels (dungeons for short).

I am torn between using the term “Affix” and the term “Trait” to describe the procedurally generated properties, mainly because English is not my first language, and there may be a clear difference in usage between the two.

Examples of traits: Hearty: For items, it gives 5 more HP, for characters they have 5 more HP, for vehicles they have 5 more durability, for dungeons, enemies have 5 HP each. Indomitable: For items, characters and vehicles, it gives the player the ability to ressurect at 100% hp, once dead. For the dungeon, dead enemies remain invulnerable for a few seconds after being dead.

I am open to either opinions or arguments for any of them. Thanks!