Black Holes

Black Holes

"Wow! That was amazing!" Stephen was greatly impressed. He took his eyes off the telescope and leaned back.

"Did you see that?" asked Sofia.

...moments ago a super massive black hole had just "swallowed" another one...

"You were right Sofia, that was an incredible event" Stephen said. "So, can I join your A&A (Astronomy & Astrophysics) research group?"

Sofia looked at him triumphantly and said - "Really, my plan was to rope you in anyway! We are currently researching black holes and their gravitational fields and we are looking for someone to help us create a software model that will predict the future state of black holes".

"Hmm, it's very interesting. Let me try...".

You need to help Stephen implement a software model (function) that predicts the state of black holes under a controlled environment. The A&A research team has identified some peculiarities in the behavior of black holes.

To create the software model one should take into account:

1. The cartesian coordinate system is used to map out the black holes.
2. Each black hole is represented as a circle with x , y (center coordinates) and r (radius).
3. In contrast to the area, which may change during the absorption process, the coordinates remain constant.
4. The area of a black hole greatly influences its mass, and consequently, the gravitational field.
5. The absorption order of black holes depends on the distance between their centers, starting with the black holes that are closest to each other. If the distance between different black holes is equal, then the leftmost black hole in the list should merge first.
6. The absorption process (merging) of black holes is possible if and only if the following conditions are met :
- The intersection area of the two black holes is greater than or equal to 55% (>= 55%) of one of the two black holes area.
- The area of one of the two black holes is over 20% (>= 20%) more than the area of the other.
7. If one black hole absorbs another, their areas are summarized as (S total = S 1 + S 2 ).
8. The absorption process continues as long as all conditions are met (see p. 6).

Let's look at some simple examples:

Input: [(2, 4, 2), (3, 9, 3)]
No intersection
Output: [(2, 4, 2), (3, 9, 3)]



first-example
Input: [(0, 0, 2), (-1, 1, 2)]
S 1 = 12.57; S 2 = 12.57
Intersection area = 7.03
p 1 = 56% p 2 = 56%
Domination: 0%
Output: [(0, 0, 2), (-1, 1, 2)]
first-example
Input: [(1, 3, 2), (1, 3, 2.19)]
S 1 = 12.57; S 2 = 15.07
Domination: 19.9%
Output: [(1, 3, 2), (1, 3, 2.19)]


first-example

More complex example: [(2, 2, 3), (0, 4, 2), (4, 6, 2), (4.7, 3, 0.5)]

Steps Before
Input: [(2, 2, 3), (0, 4, 2), (4, 6, 2), (4.7, 3, 0.5)]
R1, R2 - distance (2.83); S 1 = 28.27; S 2 = 12.57
Intersection area = 6.04
p 1 = 21% p 2 = 48%
Output: [(2, 2, 3), (0, 4, 2), (4, 6, 2), (4.7, 3, 0.5)]
----------------------------------------------------------
Input: [(2, 2, 3), (0, 4, 2), (4, 6, 2), (4.7, 3, 0.5)]
R1, R4 - distance (2.88); S 1 = 28.27; S 4 = 0.79
Intersection area = 0.5
p 1 = 2% p 4 = 63%
Output: [(2, 2, 3.04), (0, 4, 2), (4, 6, 2)]
----------------------------------------------------------
Input: [(2, 2, 3.04), (0, 4, 2), (4, 6, 2)]
R1, R2 - distance (2.83); S 1 = 29.03; S 2 = 12.57
Intersection area = 6.21
p 1 = 21% p 4 = 49%
Output: [(2, 2, 3.04), (0, 4, 2), (4, 6, 2)]
----------------------------------------------------------
Input: [(2, 2, 3.04), (0, 4, 2), (4, 6, 2)]
R1, R3 - distance (4.47); S 1 = 29.03; S 2 = 12.57
Intersection area = 0.87
p 1 = 3% p 4 = 7%
Output: [(2, 2, 3.04), (0, 4, 2), (4, 6, 2)]
----------------------------------------------------------
Input: [(2, 2, 3.04), (0, 4, 2), (4, 6, 2)]
R2, R3 - distance (4.47)
S 1 = 12.57; S 2 = 12.57
No intersection
----------------------------------------------------------
Output: [(2, 2, 3.04), (0, 4, 2), (4, 6, 2)]
first-example
After
first-example

Input: A list of tuples [(x, y, r), ..., ...], where x, y - coordinates, r - radius of a black hole

Output: Predictable (final) state of black holes as a list/tuple of lists/tuples, radius should be given with two digits precision as ±0.01.

Example:

How it is used: You can use this in game development (see Agar.io example), studying geometry or developing software models of real physical processes.

Precondition: 1 ≤ len(data) ≤ 20
0.5 ≤ radius ≤ 10
x ∈ [-100; 100], y ∈ [-100; 100]

Settings
Code:
Other:
Invalid hot key. Each hot key should be unique and valid
Hot keys:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

pip3 install checkio_client

Configure your tool

checkio --domain=py config --key=

Sync solutions into your local folder

checkio sync

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

checkio serv -d

Alternatevly, you can install Chrome extension or FF addon

checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

Pair Programming (Beta-version)

Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!

Waiting for Pair Programming to start...

You are trying to join a pair programming session that has not started yet.

Please wait for the session creator to join.

Waiting for Pair Programming to reconnect...

It looks like the creator of the pair programming session closed the editor window.

It might happen accidentally, so that you can wait for reconnection.

×
 
 
<< <
> >>
exec show

Whats Next?

Free accounts will see Best CheckiO solutions with some delay.
Best Solutions will be opened in a moment
Become Awesome and Don't wait
The next stage is ""
Will be activated in
View More Solutions Random Review Solutions Go to the next mission