Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6),  106 104  100 bytes

JavaScript (ES6),  106 104  100 bytes

###Commented

Commented

#JavaScript (ES6),  106 104  100 bytes

###Commented

JavaScript (ES6),  106 104  100 bytes

Commented

minor update
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

Example: \$4\rightarrow5\rightarrow6\$ is transformed asturned into \$[0,\color{red}9,6]\$ and then \$[0,0,\color{red}{15}]\$.

But when several values in a row are attracted by their left neighbor, we need to add \$a_i\$ to the first attractor \$a_k\$ of thethis sequence (with \$k<i\$) rather than simply \$a_{i-1}\$.

Example: \$6\leftarrow5\leftarrow4\$ is transformed asturned into \$[\color{red}{11},0,4]\$ and then \$[\color{red}{15},0,0]\$.

Example: \$4\rightarrow5\rightarrow6\$ is transformed as \$[0,\color{red}9,6]\$ and then \$[0,0,\color{red}{15}]\$.

But when several values in a row are attracted by their left neighbor, we need to add \$a_i\$ to the first attractor \$a_k\$ of the sequence (with \$k<i\$).

Example: \$6\leftarrow5\leftarrow4\$ is transformed as \$[\color{red}{11},0,4]\$ and then \$[\color{red}{15},0,0]\$.

Example: \$4\rightarrow5\rightarrow6\$ is turned into \$[0,\color{red}9,6]\$ and then \$[0,0,\color{red}{15}]\$.

But when several values in a row are attracted by their left neighbor, we need to add \$a_i\$ to the first attractor \$a_k\$ of this sequence (with \$k<i\$) rather than simply \$a_{i-1}\$.

Example: \$6\leftarrow5\leftarrow4\$ is turned into \$[\color{red}{11},0,4]\$ and then \$[\color{red}{15},0,0]\$.

rephrasing
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

But when several values in a row are attracted by their left neighbor, we need to add \$a_i\$ to the highest previous valuefirst attractor \$a_k\$ of the sequence (with \$k<i\$) when several values in a row are attracted by their left neighbor.

But we need to add \$a_i\$ to the highest previous value \$a_k\$ (with \$k<i\$) when several values in a row are attracted by their left neighbor.

But when several values in a row are attracted by their left neighbor, we need to add \$a_i\$ to the first attractor \$a_k\$ of the sequence (with \$k<i\$).

minor clarifications
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
added the new test case
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
added an explanation about a[i+1] vs a[k]
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
added an explanation about a[i+1] vs a[k]
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
saved 4 bytes
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
added a commented version
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
saved 2 bytes
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading