Efficient algorithm for finding optimal sum from both arrays

I have two arrays(A,B) and a sum M. I need to find one number from each array that makes the sum M. If there is no two elements that form sum M, then nearest and less than M sum is the solution. See examples below. What is the efficient way to find the solution for this?

eg1:  A =[200,300,600,900] B =[1000,200,300,500] M = 900 Output : A(2), B(2) 600 from A and 300 from B sums 900.  eg1:  A =[200,300,600,1000] B =[1000,400,600] M = 1500 Output : A(3), B(1) 1000 from A and 400 from B sums 1400 which is near to the sum 1500. 

Not able to connect to internet when both ethernet and wifi is connected in Ubuntu 16.04

I have Ubuntu 16.04 (machine 1) and Windows 10 (machine2). I have connected the ubuntu to the wifi with IP 192.168.0.110 and I can browse internet easily.

I have to do remote C++ development on ubuntu from windows using Visual studio. I have connected the Ethernet cable between ubuntu and windows. On both the side I have set the static IP i.e. ubuntu has 192.168.0.150 and windows has 192.168.0.149. I can ping windows from ubuntu and vice versa. But when I try to browse internet on Ubuntu, its not working. If I disconnect wired connection from ubuntu, I can browse the internet fine. I don’t know what I have done wrong here due to which I am not able to connect to internet on Ubuntu.

Can anyone please suggest any idea. Thanks

Is concept of virtual memory about memory isolation or about ability to swap? Or both?

Most reading I found about virtual memory, such as http://www.linux-tutorial.info/modules.php?name=MContent&pageid=89 or https://en.wikipedia.org/wiki/Virtual_memory always state that virtual memory is a concept that allows operating system to make it “appear as though you have more memory than you really do”.

But isn’t that what overcommit is about? Isn’t whole virtual memory concept primarily about the fact that each process has an isolated virtual memory pool, thus being unable to read or modify other process memory?

If not, what is this technology of memory isolation within own virtual memory pools called?

Is the 5-foot range of the Help action my range to the ally, the enemy, or both?

A player in our group that knows much more than me explained the Help action during game, but then after the game I read the PHB and not sure if he’s using it correctly.

I thought I needed to be within 5 feet of the enemy. He said I need to be within 5 feet of the ally.

The Help action says:

You can lend your aid to another creature in the completion of a task. When you take the Help action, the creature you aid gains advantage on the next ability check it makes to perform the task you are helping with, provided that it makes the check before the start of your next turn.

Alternatively, you can aid a friendly creature in attacking a creature within 5 feet of you. You feint, distract the target, or in some other way team up to make your ally’s attack more effective. If your ally attacks the target before your next turn, the first attack roll is made with advantage.

Does the ally, the enemy, or both need to be within 5 feet of me when I take the Help action?

If a Thief Rogue casts True Polymorph (Object into Creature), does the creature move on both of their turns from the Thief’s Reflexes feature?

The Thief Rogue’s Thief’s Reflexes feature states:

When you reach 17th level, you have become adept at laying ambushes and quickly escaping danger. You can take two turns during the first round of any combat. You take your first turn at your normal initiative and your second turn at your initiative minus 10. You can’t use this feature when you are surprised.

The true polymorph spell states:

[…] Object into Creature. You can turn an object into any kind of creature, as long as the creature’s size is no larger than the object’s size and the creature’s challenge rating is 9 or lower. The creature is friendly to you and your companions. It acts on each of your turns. You decide what action it takes and how it moves. The GM has the creature’s statistics and resolves all of its actions and movement.

What happens if the Thief casts true polymorph on an object and turns it into a creature? Does the created creature get an additional turn when the Rogue does?


Note: At least one way a Thief Rogue could cast true polymorph is through feats or multiclassing and using a spell scroll.

Does the UA Beast Conclave revised ranger let you add your proficiency bonus to both the Boar companion’s Tusk damage roll and its Charge damage roll?

I am just hoping to get some clarification on this one.

The UA Ranger Beast Conclave’s Companion’s Bond feature says:

In addition to the areas where it normally uses its proficiency bonus, an animal companion also adds its proficiency bonus to its AC and to its damage rolls.

Does this mean if my boar companion uses a charge attack, I add proficiency damage twice (to the tusk damage and charge damage) or is it added only one time?

Just for referencing, the boar’s statblock says:

Charge. If the boar moves at least 20 ft. straight toward a target and then hits it with a tusk attack on the same turn, the target takes an extra 3 (1d6) slashing damage. If the target is a creature, it must succeed on a DC 11 Strength saving throw or be knocked prone.

Tusk. Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) slashing damage.

Cost of Numenera “Disrupting Touch” ability if player has Edge in both Speed and Might?

Disrupting Touch is an ability that can only be used when the player has already declared a use of the “Phase Sprint” ability. The Player’s Handbook states for Phase Sprint:

Note that some of your other special abilities enable specific actions that you can take while using Phase Sprint. For instance, when using Disrupting Touch, you can make one touch attack while moving…”

and for Phase Sprint

You can turn your Phase Sprint into a melee attack by purposefully grazing another creature as you run.

The character in question has an Edge of 1 in Speed and an Edge of 1 in Might.

So the question is, are these played in combat as two actions, or one, and how is the cost paid? Is it:

  1. Phase Sprint is action 1 which costs 0 because of Speed Edge; Disrupting Touch can’t be done till next turn, but also costs 0 because of Might Edge; Phase Sprint continues until the attack is made.
  2. Phase Sprint is declared as an action, and its cost is zero (1 Edge in Speed), then Disrupting Touch is declared as a modification to the action but its cost is 1 Might (because Edge was already used during this turn). Phase Sprint ends at the end of the turn (in sync with the attack).
  3. Phase Sprint is declared as an action, and its cost is zero (1 Edge in Speed), then Disrupting Touch is declared as a modification to the action and its cost is zero (because of 1 Edge in Might). Phase Sprint ends in sync with the attack at the end of the turn.

The player would, of course, prefer #2, but we’d all prefer to be sure we applied the system’s rules properly.

Show option is both required and previously selected in dropdown list

I realize this is probably not the best way to handle the problem, but I need to shoehorn in a solution to a previously existing design.

In this situation there are a number of fields the user needs to add from a dropdown list. Some are required, some are not… each can be used only once.

The request is to indicate which items in the drowdown are required and indicate if they have been previously added.

What is the best option for this?

My first thought is to use a red asterisk next to required item and change it to a checkmark when previously added as such:

-------------- | dropdown ▼ | |------------| | * option 1 | | * option 2 | | ✓ option 3 | |   option 4 | | ✓ option 5 | | * option 6 | -------------- 

Is it viable for a Druid to have both Wild Shape and Animal Companion?

As a Druid, you can take both the Wild Order (gaining Wild Shape) and the Animal Order (gaining an Animal Companion) via Order Explorer (Druid Feat 2). To be most effective, you would likely wish to change into a battle form and fight alongside your companion. However…

According to the Animal Companion rules:

Your animal companion has the minion trait, and it gains 2 actions during your turn if you use the Command an Animal action to command it

From Command an Animal, the action has the Auditory Trait:

Auditory actions and effects rely on sound. An action with the auditory trait can be successfully performed only if the creature using the action can speak or otherwise produce the required sounds.

And according to the Polymorph trait (which is on all Wild Shape spells):

Unless otherwise noted, the battle form prevents you from casting spells, speaking, and using most manipulate actions that require hands.

From this, it appears that if you change into an animal form, you can’t effectively command your animal companion. However, Auditory doesn’t specify that you have to speak, only “produce the required sounds”.

So, can you consider your animal trained to take commands in various grunts and growls from your animal forms, or are you forever gimped into only using one or the other feature (barring special forms like Thousand Faces which isn’t considered a battle form, and thus not subject to the restrictions)?