## How to determine whether a string is an integer or not?

Consider this example:

public int numberValue(String str){     return Integer.parseInt(str); } 

When giving a word that does not represent a number, we’ll get back an exception of type NumberFormatException. How can I rewrite this short fragment to make sure that in this case, I’ll get 0 back?

## Determine Intersection given only a hyperrectangle and a point-contained-in-shape-Predicate

Given only an n-dimensional hyperrectangle by its corner-point-values and an n-dimensional Predicate that corresponds to an arbitrary shape and tests whether a point is contained in said shape,

is it possible to calculate whether the box intersects the shape?

## Ansible playbook to determine OS release

I’m simply trying to check the version of ubuntu on all my servers. Based on this question I see that ansible has a ansible_distribution_version but this playbook does not show how I would simply just have it print out the ubuntu version, ie ubuntu 14.04, 16.04, etc

## Is it possible to use checkboxes to determine what data is in a list?

This is hobby related, so feel free to ignore. I want to learn how to use Googlesheets, and am doing so by building a partial DnD character sheet, piece by piece. I AM TRYING NOT TO USE SCRIPTS AS I DON’T HAVE THE KNOWLEDGE TO UNDERSTAND HOW IT’S WORKING

Problem Background

I have 10 checkboxes which each correspond with a list. If a box is checked, that corresponding list will appear in an answer column, and multiple checks will add multiple lists as one list in the column

Problem

How do I populate this answer list using the checkboxes?

My method

When I check a box as true, it returns a named range as a string. I use the indirect function and the index function to make this into a list, but I feel that this is not a good way to do it

I’m not sure how to paste cells to demonstrate what I mean, so I can only use images sorry

Also, I now realise Class is mislabelled as Race

## How does ping determine the IP address of an mDNS service?

I am trying to write a Python 3 program which, when given the name of a service, returns the IPv4 numeric address of the machine running the service. (I don’t want to use the zeroconf module.)

Using https://en.wikipedia.org/wiki/Multicast_DNS and https://pymotw.com/3/socket/multicast.html, I was able to put something together that finds the IP number of a host that has an /etc/hosts entry (i.e. query a hostname.local). However, when I have code running on that system (hostname.local) that registers an _osc._udp.local.” service (e.g. oscresponder.local), “ping oscresponder.local” returns the IP just as “ping hostname.local” does but my code does not.

In other words:

ping hostname.local           # works ./mDNS.py hostname.local      # works ping oscresponder.local       # works ./mDNS.py oscresponder.local  # does not work 

So, what is ping doing that goes above and beyond what the Wikipedia article lists?

(I tried to ferret out the information using Wireshark, but my network-fu is pretty bad, and I couldn’t determine which response was being picked up by ping to provide the IPv4 address.)

## How to determine new Challenge Rating when applying Shadow Dragon template?

The Monster Manual contains a template whereby any true dragon may be turned into a shadow dragon. A shadow dragon differs from a true dragon in the following ways:

• It has resistance to necrotic damage always, and resistance to all other forms of damage except force, psychic and radiant, when in dim light or darkness.
• It has double proficiency in Stealth.
• It can Hide as a bonus action when in dim light or darkness.
• It has sunlight sensitivity (disadvantage on attack rolls and Perception checks involving sight when in sunlight).
• The damage type of both its bite and its breath weapon is necrotic (regardless of type of dragon).
• A shadow rises from the corpse of any humanoid killed by its breath weapon.

Otherwise, the shadow dragon has the same stats as the true dragon. How do you evaluate these differences to come up with a new Challenge Rating? Right now I am specifically looking for the CR of a Black Shadow Dragon Wyrmling, but the best answer will explain how to determine the CR of all types of shadow dragon.

One clue: The Monster Manual provides one example stat block for a shadow dragon: a Young Red. The CR of a Young Red Shadow Dragon is 13, while the CR of a Young Red Dragon is 10. Is merely adding 3 to the CR a good rule of thumb?

## Determine whether the series $\sum_{n =1}^{\infty} \frac{n + \sqrt{n}}{2n^3 -1}$ converges?

Determine whether the series $$\sum_{n =1}^{\infty} \frac{n + \sqrt{n}}{2n^3 -1}$$ converges?

My answer: For large n, the given series is smaller than $$\sum_{n =1}^{\infty}\frac {2n}{2n^3}$$ which is equal to $$\sum_{n =1}^{\infty}\frac {1}{n^2}$$, but we know that the later is convergent by the p-series test, then by comparison test the given series is convergent.

Is my answer correct?

## Oven cooking queue problem: need help to determine its nature

CS community!

I’m more of a practical programmer than a computer scientist, so I need your help to find a solution (or at least point me into the right direction) to an extremely practical problem related to cooking food in the oven.

### Problem

I have N ovens and I have multiple various ingredients to cook in them. Each ingredient has certain preparation (e.g. peel the potato, cut the meat, etc.) time and oven cooking time. At time 0 we start preparing ingredients and putting them into the oven to cook. I need an algorithm to find the most optimal arrangement for the queues of these N ovens, so that it takes minimum time to finish cooking all of the ingredients.

Additional note: each ingredient is cooked at specific temperature, so no 2 ingredients can be cooked simultaneously.

### Example

2 ovens: O1, O2

7 ingredients:

A (PT 200, CT 400)

B (PT 180, CT 380)

C (PT 80, CT 240)

D (PT 60, CT 180)

E (PT 40, CT 120)

F (PT 20, CT 60)

G (PT 0, CT 20)

Where: PT – preparation time, minutes; CT – cooking time, minutes.

I solved it simply visually and found that optimal solution looks like this:

Time: action  0: put G in O1 20: take G from O1, put F in O1 40: put E in O2 80: take F from O1, put C in O1 160: put take E from O2, put D in O2 320: take C from O1, put A in O1 340: take D from O2, put B in O2 720, take A from O1, take B from O2 -- finished in 720 min! 

Visually it looks like this:

### Conclusion

In a search for an answer I found that problem cannot be solved by simply sorting ingredients in some order, as changing the timing on one of the ingredients can dramatically change the cooking order: sometimes ingredients need to wait for certain time, even though they are prepared and ready to be cooked — the priority queue can change completely!

### Question

Whoever sees any similarities with certain mathematical or CS problems (Knapsack? Packing?), please point me in the right direction. Or, preferably, point me to the solution, which surely must exist for such an obvious problem.

Thank you!

## Determine $\sup \{xy−x^2/2\mid x\in [-1,1]\}$

I am trying to find the supremum of the following set $$\{xy−x^2/2\mid x\in [-1,1]\}$$, where $$y$$ is a real number. I am not sure if this is correct, but I managed to find that $$\sup \{ xy-x^2/2\mid x\in [-1,1]\}=\begin{cases} y^2/2 & \text{ if } y\in [-1,1] \ y-1/2 & \text{ if } y>1 \ -y-1/2 & \text{ if } y<-1 \end{cases}$$

## How to determine the application used on top of TCP?

I am currently implementing a TCP Proxy Server. The huge problem I have right now is that, based on the clients’ TCP data, I am trying to determine whether the client is making an HTTP, FTP or SMTP request.

My solution, I am thinking that I have to read the first line of data of the TCP data. For example, an HTTP request would contain an HTTP method such as GET, POST, DELETE, etc.

My question is: is this solution of mine correct? and if so or not, how should I go about it (as well as for determining FTP and SMTP) ?