Skip to main content
added 44 characters in body
Source Link

Each of them creates an attractiona force tobetween itself and it's adjacent numbers. As you may imagineUnder some conditions, ifthis will cause another number to be attracted (moved) toward a number. When the number is bigger than the adjacent, it attracts it. Lets take a look at our previous example:

The number 1 is not big enough to attract the numbermove 6, but the number 6 can attract number 1is, etc... Basically, numbers are attractedmoved to the biggest adjacent number (also bigger than the number itself). If both of the adjacent numbers are equal it is not attracted then. It also happens when the number and it adjacent are equal.

Each of them creates an attraction force to it's adjacent numbers. As you may imagine, if the number is bigger than the adjacent it attracts it. Lets take a look at our previous example:

The number 1 is not big enough to attract the number 6, but the number 6 can attract number 1, etc... Basically, numbers are attracted to the biggest adjacent number (also bigger than the number itself). If both of the adjacent numbers are equal it is not attracted then. It also happens when the number and it adjacent are equal.

Each of them creates a force between itself and it's adjacent numbers. Under some conditions, this will cause another number to be attracted (moved) toward a number. When the number is bigger than the adjacent, it attracts it. Lets take a look at our previous example:

The number 1 is not big enough to move 6, but the number 6 is, etc... Basically, numbers are moved to the biggest adjacent number (also bigger than the number itself). If both of the adjacent numbers are equal it is not attracted then. It also happens when the number and it adjacent are equal.

Extra test case
Source Link

The gravitational force is a force that attracts any two objects with mass. In this challenge our objects will be Numbers and their mass will be their value. To do so, we don't care about the strength of the force but the direction of it.

Imagine this set of numbers

[1 6 9 4 6 9 7 6 4 4 9 8 7]

Each of them creates an attraction force to it's adjacent numbers. As you may imagine, if the number is bigger than the adjacent it attracts it. Lets take a look at our previous example:

[1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]

The number 1 is not big enough to attract the number 6, but the number 6 can attract number 1, etc... Basically, numbers are attracted to the biggest adjacent number (also bigger than the number itself). If both of the adjacent numbers are equal it is not attracted then. It also happens when the number and it adjacent are equal.

This is only to show the attraction, but what happens after? Numbers that collide due to attraction are summed up:

[20 32 28]

So basically the challenge is, Given a set of numbers, output the result of the attracted set of numbers.


Example 1

Input  => [10 15 20 10 20 10 10]
          [10 → 15 → 20 10 20 ← 10 10]
Output => [45 10 30 10]

Example 2

Input  => [9 9 9 9 8 1 8]
          [9 9 9 9 ← 8 1 8]
Output => [9 9 9 17 1 8]

Example 3

Input  => [1 6 9 4 6 9 7 6 4 4 9 8 7]
          [1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]
Output => [20 32 28]

Example 4

Input  => [1 2 3 2 1]
          [1 → 2 → 3 ← 2 ← 1]
Output => [9]

Example 5

Input  => [1]
Output => [1]

Example 6

Input  => [1 1]
Output => [1 1]

Example 7

Input  => [2 1 4]
Output => [2 5]

Notes

  • Attraction only happens once
  • Numbers are not attracted to non-adjacent Numbers
  • The set of numbers will only contain positive integers

The gravitational force is a force that attracts any two objects with mass. In this challenge our objects will be Numbers and their mass will be their value. To do so, we don't care about the strength of the force but the direction of it.

Imagine this set of numbers

[1 6 9 4 6 9 7 6 4 4 9 8 7]

Each of them creates an attraction force to it's adjacent numbers. As you may imagine, if the number is bigger than the adjacent it attracts it. Lets take a look at our previous example:

[1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]

The number 1 is not big enough to attract the number 6, but the number 6 can attract number 1, etc... Basically, numbers are attracted to the biggest adjacent number (also bigger than the number itself). If both of the adjacent numbers are equal it is not attracted then. It also happens when the number and it adjacent are equal.

This is only to show the attraction, but what happens after? Numbers that collide due to attraction are summed up:

[20 32 28]

So basically the challenge is, Given a set of numbers, output the result of the attracted set of numbers.


Example 1

Input  => [10 15 20 10 20 10 10]
          [10 → 15 → 20 10 20 ← 10 10]
Output => [45 10 30 10]

Example 2

Input  => [9 9 9 9 8 1 8]
          [9 9 9 9 ← 8 1 8]
Output => [9 9 9 17 1 8]

Example 3

Input  => [1 6 9 4 6 9 7 6 4 4 9 8 7]
          [1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]
Output => [20 32 28]

Example 4

Input  => [1 2 3 2 1]
          [1 → 2 → 3 ← 2 ← 1]
Output => [9]

Example 5

Input  => [1]
Output => [1]

Example 6

Input  => [1 1]
Output => [1 1]

Notes

  • Attraction only happens once
  • Numbers are not attracted to non-adjacent Numbers
  • The set of numbers will only contain positive integers

The gravitational force is a force that attracts any two objects with mass. In this challenge our objects will be Numbers and their mass will be their value. To do so, we don't care about the strength of the force but the direction of it.

Imagine this set of numbers

[1 6 9 4 6 9 7 6 4 4 9 8 7]

Each of them creates an attraction force to it's adjacent numbers. As you may imagine, if the number is bigger than the adjacent it attracts it. Lets take a look at our previous example:

[1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]

The number 1 is not big enough to attract the number 6, but the number 6 can attract number 1, etc... Basically, numbers are attracted to the biggest adjacent number (also bigger than the number itself). If both of the adjacent numbers are equal it is not attracted then. It also happens when the number and it adjacent are equal.

This is only to show the attraction, but what happens after? Numbers that collide due to attraction are summed up:

[20 32 28]

So basically the challenge is, Given a set of numbers, output the result of the attracted set of numbers.


Example 1

Input  => [10 15 20 10 20 10 10]
          [10 → 15 → 20 10 20 ← 10 10]
Output => [45 10 30 10]

Example 2

Input  => [9 9 9 9 8 1 8]
          [9 9 9 9 ← 8 1 8]
Output => [9 9 9 17 1 8]

Example 3

Input  => [1 6 9 4 6 9 7 6 4 4 9 8 7]
          [1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]
Output => [20 32 28]

Example 4

Input  => [1 2 3 2 1]
          [1 → 2 → 3 ← 2 ← 1]
Output => [9]

Example 5

Input  => [1]
Output => [1]

Example 6

Input  => [1 1]
Output => [1 1]

Example 7

Input  => [2 1 4]
Output => [2 5]

Notes

  • Attraction only happens once
  • Numbers are not attracted to non-adjacent Numbers
  • The set of numbers will only contain positive integers
Became Hot Network Question
added 218 characters in body
Source Link

The gravitational force is a force that attracts any two objects with mass. In this challenge our objects will be Numbers and their mass will be their value. To do so, we don't care about the strength of the force but the direction of it.

Imagine this set of numbers

[1 6 9 4 6 9 7 6 4 4 9 8 7]

Each of them creates an attraction force to it's adjacent numbers. As you may imagine, if the number is bigger than the adjacent it attracts it. Lets take a look at our previous example:

[1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]

The number 1 is not big enough to attract the number 6, but the number 6 can attract number 1, etc... Basically, numbers are attracted to the biggest adjacent number (also bigger than the number itself). If both of the adjacent numbers are equal it is not attracted then. It also happens when the number and it adjacent are equal.

This is only to show the attraction, but what happens after? Numbers that collide due to attraction are summed up:

[20 32 28]

So basically the challenge is, Given a set of numbers, output the result of the attracted set of numbers.


Example 1

Input  => [10 15 20 10 20 10 10]
          [10 → 15 → 20 10 20 ← 10 10]
Output => [45 10 30 10]

Example 2

Input  => [9 9 9 9 8 1 8]
          [9 9 9 9 ← 8 1 8]
Output => [9 9 9 17 1 8]

Example 3

Input  => [1 6 9 4 6 9 7 6 4 4 9 8 7]
          [1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]
Output => [20 32 28]

Example 4

Input  => [1 2 3 2 1]
          [1 → 2 → 3 ← 2 ← 1]
Output => [9]

Example 5

Input  => [1]
Output => [1]

Example 6

Input  => [1 1]
Output => [1 1]

Notes

  • Attraction only happens once
  • Numbers are not attracted to non-adjacent Numbers
  • The set of numbers will only contain positive integers

The gravitational force is a force that attracts any two objects with mass. In this challenge our objects will be Numbers and their mass will be their value. To do so, we don't care about the strength of the force but the direction of it.

Imagine this set of numbers

[1 6 9 4 6 9 7 6 4 4 9 8 7]

Each of them creates an attraction force to it's adjacent numbers. As you may imagine, if the number is bigger than the adjacent it attracts it. Lets take a look at our previous example:

[1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]

The number 1 is not big enough to attract the number 6, but the number 6 can attract number 1, etc... Basically, numbers are attracted to the biggest adjacent number (also bigger than the number itself). If both of the adjacent numbers are equal it is not attracted then. It also happens when the number and it adjacent are equal.

This is only to show the attraction, but what happens after? Numbers that collide due to attraction are summed up:

[20 32 28]

So basically the challenge is, Given a set of numbers, output the result of the attracted set of numbers.


Example 1

Input  => [10 15 20 10 20 10 10]
          [10 → 15 → 20 10 20 ← 10 10]
Output => [45 10 30 10]

Example 2

Input  => [9 9 9 9 8 1 8]
          [9 9 9 9 ← 8 1 8]
Output => [9 9 9 17 1 8]

Example 3

Input  => [1 6 9 4 6 9 7 6 4 4 9 8 7]
          [1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]
Output => [20 32 28]

Notes

  • Attraction only happens once
  • Numbers are not attracted to non-adjacent Numbers
  • The set of numbers will only contain positive integers

The gravitational force is a force that attracts any two objects with mass. In this challenge our objects will be Numbers and their mass will be their value. To do so, we don't care about the strength of the force but the direction of it.

Imagine this set of numbers

[1 6 9 4 6 9 7 6 4 4 9 8 7]

Each of them creates an attraction force to it's adjacent numbers. As you may imagine, if the number is bigger than the adjacent it attracts it. Lets take a look at our previous example:

[1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]

The number 1 is not big enough to attract the number 6, but the number 6 can attract number 1, etc... Basically, numbers are attracted to the biggest adjacent number (also bigger than the number itself). If both of the adjacent numbers are equal it is not attracted then. It also happens when the number and it adjacent are equal.

This is only to show the attraction, but what happens after? Numbers that collide due to attraction are summed up:

[20 32 28]

So basically the challenge is, Given a set of numbers, output the result of the attracted set of numbers.


Example 1

Input  => [10 15 20 10 20 10 10]
          [10 → 15 → 20 10 20 ← 10 10]
Output => [45 10 30 10]

Example 2

Input  => [9 9 9 9 8 1 8]
          [9 9 9 9 ← 8 1 8]
Output => [9 9 9 17 1 8]

Example 3

Input  => [1 6 9 4 6 9 7 6 4 4 9 8 7]
          [1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]
Output => [20 32 28]

Example 4

Input  => [1 2 3 2 1]
          [1 → 2 → 3 ← 2 ← 1]
Output => [9]

Example 5

Input  => [1]
Output => [1]

Example 6

Input  => [1 1]
Output => [1 1]

Notes

  • Attraction only happens once
  • Numbers are not attracted to non-adjacent Numbers
  • The set of numbers will only contain positive integers
added 57 characters in body
Source Link
Loading
Source Link
Loading