Determine whether array could become non-decreasing by modifying at most 1 element

The task

Given an array of integers, write a function to determine whether the array could become non-decreasing by modifying at most 1 element.

For example, given the array [10, 5, 7], you should return true, since we can modify the 10 into a 1 to make the array non-decreasing.

Given the array [10, 5, 1], you should return false, since we can’t modify any one element to get a non-decreasing array.

const arr = [10, 5, 7]; 

My functional solution

const isIncreasing = arr => {   let count = 0;   return[...arr].every((n, i) => {     if (arr[i + 1] && n > arr[i + 1]) { ++count; }     return count < 2;   }); };  console.log(isIncreasing(arr)); 

My imperative solution

function isIncreasing2(arr) {   let count = 0;   for (let i = 0, len = arr.length; i < len; i++) {     if (arr[i + 1] && arr[i] > arr[i + 1]) { ++count; }     if (count > 1) { return false;}   }   return true; }  console.log(isIncreasing2(arr)); 

How do I get MS Word form fields to become MS Sharepoint columns?

In my approved document library in MS SharePoint, I have a blank form, with fields (not Quick Parts) for users to complete when they are filling in the form; some are checkboxes, but the majority are drop-down menus, more than 20 in all.

What I want to do is to have users, when they fill in the form, store the completed form in another document library, for evidence, and have the field values automatically be columns in the default view for that library. All the fields have Titles/Tags that are meaningful, so I’m looking for the means of having each field as a column, using its title/tag as the column name.

Is there any way to become immortal in D&D 5e?

I’ve been thinking of maybe making an immortal character, either from the start, or throughout the campaign, and was wondering if there is any way of making that a reality.

Is there any way of starting with an immortal character? If so, how?

If not, how can my character achieve immortality throughout the campaign if that’s possible at all?

How to become more successful from a article blog website ?

I have a general health article website . it was built with WordPress and it has some organic traffic now but i need to earn more money from this blog . which are all the marketing ideas to boost my website ? i dont know ad-words will be helpful for me . i just want to find a way to earn a passive income from this website . can i live without a job . i mean i am looking to focus completely on my internet article website . i am still doubtful with the passive income . but i need advice's…

How to become more successful from a article blog website ?

Hard implications that become easy with the right intermediate step

I’m interested in examples of theorems of the form “If $ P$ then $ Q$ “ that were either unsolved or thought to require difficult arguments until someone came up with an $ X$ for which “If $ P$ then $ X$ ” and “If $ X$ then $ Q$ ” are significantly easier to prove.

[Can someone make this post community-wiki for me (I don’t know how to do it with the browser I’m using) and then delete this paragraph for me? Thanks!]

Ansible 2.6.2 remote user working but become is not. Config issue?

When attempting to run an ansible module on a destination server (via become) the ssh connection does not appear to be doing a “sudo” to become the application-owner user. The correct remote user is being used but the remote user is not doing “sudo” to become the app-owner account. The config used and command run are described below.

I am expecting to be able to run adhoc ansible commands and playbooks on the destination server.

The destination server has 2 users. User “myapp” that owns the directories and the daemons of the application we’re attempting to control. The user “inuser” has /usr/bin/sudo setup in their nologin permitted functions and has /bin/nologin as their shell in /etc/passwd. The “inuser” user has NO OTHER commands/functions in their nologin permitted functions (and it will be difficult to get any additional commands into nologin).

On the controller server, we’re running ansible as user called “build”. The /home/build/.ansible.cfg file looks like this:

[build@ecombuild01 ~]$   echo ""; grep -v "#" ~/.ansible.cfg  | grep -v "^$  "  [defaults] inventory      = /sites/utils/local/ansible/hosts library        = /sites/utils/local/ansible/modules/ module_utils   = /sites/utils/local/ansible/module_utils/ remote_tmp     = /sites/utils/tmp/ansible local_tmp      = /sites/utils/tmp/ansible forks          = 50 poll_interval  = 3 transport      = smart module_lang    = C gathering = explicit gather_subset = virtual gather_timeout = 4 roles_path    = /sites/utils/local/ansible/roles host_key_checking = False timeout = 4 remote_user = inuser log_path = /sites/utils/local/var/log/ansible.log private_key_file = /home/build/.ssh/rsa_sudo display_skipped_hosts = False deprecation_warnings = False bin_ansible_callbacks = True nocows = 1 retry_files_enabled = False allow_world_readable_tmpfiles = True [privilege_escalation] become=True become_method=sudo become_user=myapp become_ask_pass=False [paramiko_connection] pty=False [ssh_connection] ssh_args = -q -C -o ControlMaster=auto -o ControlPersist=60s control_path_dir = /sites/utils/tmp/.ansible/sockets scp_if_ssh = smart sftp_batch_mode = True [accelerate] [selinux] [colors] [diff] context = 3 

When I attempt to run a module, I am seeing the following output:

[build@buildserver:/home/build]  ansible -m attApache ecomtest03 -a "action=status" -b --become-method=sudo --become-user=atg -vvv  ansible 2.6.2   config file = /home/build/.ansible.cfg   configured module search path = [u'/sites/utils/local/ansible/modules']   ansible python module location = /sites/utils/Python-2.7.15/lib/python2.7/site-packages/ansible   executable location = /sites/utils/bin/ansible   python version = 2.7.15 (default, Aug 14 2018, 11:48:06) [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] Using /home/build/.ansible.cfg as config file Parsed /sites/utils/local/ansible/hosts inventory source with script plugin META: ran handlers <ecomtest03> ESTABLISH SSH CONNECTION FOR USER: inuser <ecomtest03> SSH: EXEC ssh -q -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="/home/build/.ssh/rsa_sudo"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=m06721 -o ConnectTimeout=4 -o ControlPath=/sites/utils/tmp/.ansible/sockets/0b70ddf0be ecomtest03 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /var/tmp/ansible-tmp-1554317228.92-158661897220269 `" && echo ansible-tmp-1554317228.92-158661897220269="` echo /var/tmp/ansible-tmp-1554317228.92-158661897220269 `" ) && sleep 0'"'"'' <ecomtest03> (255, '', '') ecomtest03 | UNREACHABLE! => {     "changed": false,      "msg": "Failed to connect to the host via ssh: ",      "unreachable": true }