Last active
February 17, 2022 21:34
-
-
Save Alekseyyy/c013a7786655de51ffa28c6187888e67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Aleksey's solution to the Collatz problem | |
count = 0 | |
x = 33 | |
while x > 1: | |
print("Iteration:", count, "\tx =", x) | |
if x % 2 == 0: | |
x = x / 2 | |
else: | |
x = (3 * x) + 1 | |
count += 1 | |
print("Total number of iterations to x = 1:", count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A brute force solution to the 25 Nov., 2020 @GWOMaths #dailymaths challenge | |
# ... and it's brute force cos I'm lazy like Homer Simpson :P | |
# By Aleksey (@EpsilonCalculus) | |
# Link to their problem: | |
# https://twitter.com/GWOMaths/status/133149281757551682 | |
die_1 = [x for x in range(1, 7)] | |
die_2 = [x for x in range(1, 7)] | |
target = 0 | |
combinations = [x + y for y in die_2 for x in die_1] | |
for w in combinations: | |
if (w == 5 or w == 6) and not (w == 5 and w == 6): | |
target += 1 | |
print("Solution:", (target / len(combinations)) * 100, "per cent") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment