Skip to main content
Tweeted twitter.com/StackCodeGolf/status/891392380166955008
added 221 characters in body
Source Link
hyperneutrino
  • 42.6k
  • 5
  • 68
  • 224

Inspired by Create a binary wall

Given a list of positive integers, we can write them out all above each other like so, for [2, 6, 9, 4] as an example:

0010
0110
1001
0100

We can imagine this as a wall:

..#.
.##.
#..#
.#..

However, this is a very weak wall, and it has collapsed! Each 1 (#) falls down until it hits the "ground" or another 1 (#). The 0s (.s) are present in spots left by moved 1s.

This becomes the following:

....
....
.##.
####

Which translates back to:

0000
0000
0110
1111

Which, as a list of numbers, is [0, 0, 6, 15].

Another test case

[10, 17, 19, 23]

This becomes:

01010
10001
10011
10111

which becomes:

00000
10011
10011
11111

translating back to:

[0, 19, 19, 31]

Challenge

Given a list of positive integers, apply this transformation to the list. Input/Output as lists of positive integers in any reasonable format. Standard loopholes apply.

This is a , so the shortest answer in bytes wins!

Inspired by Create a binary wall

Given a list of positive integers, we can write them out all above each other like so, for [2, 6, 9, 4] as an example:

0010
0110
1001
0100

We can imagine this as a wall:

..#.
.##.
#..#
.#..

However, this is a very weak wall, and it has collapsed! Each 1 (#) falls down until it hits the "ground" or another 1 (#). The 0s (.s) are present in spots left by moved 1s.

This becomes the following:

....
....
.##.
####

Which translates back to:

0000
0000
0110
1111

Which, as a list of numbers, is [0, 0, 6, 15].

Challenge

Given a list of positive integers, apply this transformation to the list. Input/Output as lists of positive integers in any reasonable format. Standard loopholes apply.

This is a , so the shortest answer in bytes wins!

Inspired by Create a binary wall

Given a list of positive integers, we can write them out all above each other like so, for [2, 6, 9, 4] as an example:

0010
0110
1001
0100

We can imagine this as a wall:

..#.
.##.
#..#
.#..

However, this is a very weak wall, and it has collapsed! Each 1 (#) falls down until it hits the "ground" or another 1 (#). The 0s (.s) are present in spots left by moved 1s.

This becomes the following:

....
....
.##.
####

Which translates back to:

0000
0000
0110
1111

Which, as a list of numbers, is [0, 0, 6, 15].

Another test case

[10, 17, 19, 23]

This becomes:

01010
10001
10011
10111

which becomes:

00000
10011
10011
11111

translating back to:

[0, 19, 19, 31]

Challenge

Given a list of positive integers, apply this transformation to the list. Input/Output as lists of positive integers in any reasonable format. Standard loopholes apply.

This is a , so the shortest answer in bytes wins!

Source Link
hyperneutrino
  • 42.6k
  • 5
  • 68
  • 224

Weakened Binary Walls

Inspired by Create a binary wall

Given a list of positive integers, we can write them out all above each other like so, for [2, 6, 9, 4] as an example:

0010
0110
1001
0100

We can imagine this as a wall:

..#.
.##.
#..#
.#..

However, this is a very weak wall, and it has collapsed! Each 1 (#) falls down until it hits the "ground" or another 1 (#). The 0s (.s) are present in spots left by moved 1s.

This becomes the following:

....
....
.##.
####

Which translates back to:

0000
0000
0110
1111

Which, as a list of numbers, is [0, 0, 6, 15].

Challenge

Given a list of positive integers, apply this transformation to the list. Input/Output as lists of positive integers in any reasonable format. Standard loopholes apply.

This is a , so the shortest answer in bytes wins!