mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-24 01:48:39 +00:00
Compare commits
No commits in common. "47b3c729826e864fb1d0a30b03cf95fa2adae591" and "b797e437aeadcac50556d6606a547dc634cf5329" have entirely different histories.
47b3c72982
...
b797e437ae
19
.github/ISSUE_TEMPLATE/other.yml
vendored
19
.github/ISSUE_TEMPLATE/other.yml
vendored
@ -1,19 +0,0 @@
|
|||||||
name: Other
|
|
||||||
description: Use this for any other issues. PLEASE do not create blank issues
|
|
||||||
labels: ["awaiting triage"]
|
|
||||||
body:
|
|
||||||
- type: textarea
|
|
||||||
id: issuedescription
|
|
||||||
attributes:
|
|
||||||
label: What would you like to share?
|
|
||||||
description: Provide a clear and concise explanation of your issue.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: extrainfo
|
|
||||||
attributes:
|
|
||||||
label: Additional information
|
|
||||||
description: Is there anything else we should know about this issue?
|
|
||||||
validations:
|
|
||||||
required: false
|
|
@ -937,8 +937,6 @@
|
|||||||
* [Sol1](project_euler/problem_097/sol1.py)
|
* [Sol1](project_euler/problem_097/sol1.py)
|
||||||
* Problem 099
|
* Problem 099
|
||||||
* [Sol1](project_euler/problem_099/sol1.py)
|
* [Sol1](project_euler/problem_099/sol1.py)
|
||||||
* Problem 100
|
|
||||||
* [Sol1](project_euler/problem_100/sol1.py)
|
|
||||||
* Problem 101
|
* Problem 101
|
||||||
* [Sol1](project_euler/problem_101/sol1.py)
|
* [Sol1](project_euler/problem_101/sol1.py)
|
||||||
* Problem 102
|
* Problem 102
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
"""
|
|
||||||
Project Euler Problem 100: https://projecteuler.net/problem=100
|
|
||||||
|
|
||||||
If a box contains twenty-one coloured discs, composed of fifteen blue discs and
|
|
||||||
six red discs, and two discs were taken at random, it can be seen that
|
|
||||||
the probability of taking two blue discs, P(BB) = (15/21) x (14/20) = 1/2.
|
|
||||||
|
|
||||||
The next such arrangement, for which there is exactly 50% chance of taking two blue
|
|
||||||
discs at random, is a box containing eighty-five blue discs and thirty-five red discs.
|
|
||||||
|
|
||||||
By finding the first arrangement to contain over 10^12 = 1,000,000,000,000 discs
|
|
||||||
in total, determine the number of blue discs that the box would contain.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def solution(min_total: int = 10**12) -> int:
|
|
||||||
"""
|
|
||||||
Returns the number of blue discs for the first arrangement to contain
|
|
||||||
over min_total discs in total
|
|
||||||
|
|
||||||
>>> solution(2)
|
|
||||||
3
|
|
||||||
|
|
||||||
>>> solution(4)
|
|
||||||
15
|
|
||||||
|
|
||||||
>>> solution(21)
|
|
||||||
85
|
|
||||||
"""
|
|
||||||
|
|
||||||
prev_numerator = 1
|
|
||||||
prev_denominator = 0
|
|
||||||
|
|
||||||
numerator = 1
|
|
||||||
denominator = 1
|
|
||||||
|
|
||||||
while numerator <= 2 * min_total - 1:
|
|
||||||
prev_numerator += 2 * numerator
|
|
||||||
numerator += 2 * prev_numerator
|
|
||||||
|
|
||||||
prev_denominator += 2 * denominator
|
|
||||||
denominator += 2 * prev_denominator
|
|
||||||
|
|
||||||
return (denominator + 1) // 2
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
print(f"{solution() = }")
|
|
Loading…
x
Reference in New Issue
Block a user