### Sherlock Holmes Curious Lockbox Solver

Mar 12, 2021LeifMessinger

## More Python Posts

`bytes_data = b'Hello, World!'string_data = bytes_data.decode('utf-8')print("String:", string_data)`

#### hex to rgb

Nov 19, 2022CodeCatch

1 like • 2 views

```def hex_to_rgb(hex):  return tuple(int(hex[i:i+2], 16) for i in (0, 2, 4))
hex_to_rgb('FFA501') # (255, 165, 1)```

Mar 10, 2021Skrome

0 likes • 0 views

```color2 = (60, 74, 172)color1 = (19, 28, 87)
percent = 1.0for i in range(101):    resultRed = round(color1[0] + percent * (color2[0] - color1[0]))    resultGreen = round(color1[1] + percent * (color2[1] - color1[1]))    resultBlue = round(color1[2] + percent * (color2[2] - color1[2]))    print((resultRed, resultGreen, resultBlue))    percent -= 0.01```

#### delay time lambda

Nov 19, 2022CodeCatch

0 likes • 0 views

```from time import sleep
def delay(fn, ms, *args):  sleep(ms / 1000)  return fn(*args)
delay(lambda x: print(x), 1000, 'later') # prints 'later' after one second```
```import itertools
def compute_permutations(string):    # Generate all permutations of the string    permutations = itertools.permutations(string)
# Convert each permutation tuple to a string    permutations = [''.join(permutation) for permutation in permutations]
return permutations
# Prompt the user for a stringstring = input("Enter a string: ")
# Compute permutationspermutations = compute_permutations(string)
# Display the permutationsprint("Permutations:")for permutation in permutations:    print(permutation)```
```# Function to multiply two matricesdef multiply_matrices(matrix1, matrix2):    # Check if the matrices can be multiplied    if len(matrix1[0]) != len(matrix2):        print("Error: The number of columns in the first matrix must be equal to the number of rows in the second matrix.")        return None
# Create the result matrix filled with zeros    result = [[0 for _ in range(len(matrix2[0]))] for _ in range(len(matrix1))]
# Perform matrix multiplication    for i in range(len(matrix1)):        for j in range(len(matrix2[0])):            for k in range(len(matrix2)):                result[i][j] += matrix1[i][k] * matrix2[k][j]
return result
# Example matricesmatrix1 = [[1, 2, 3],           [4, 5, 6],           [7, 8, 9]]
matrix2 = [[10, 11],           [12, 13],           [14, 15]]
# Multiply the matricesresult_matrix = multiply_matrices(matrix1, matrix2)
# Display the resultif result_matrix is not None:    print("Result:")    for row in result_matrix:        print(row)```