As Kent Beck puts it: The goal of software design is to create chunks or slices that fit into a human mind. The software keeps growing but the human mind maxes out, so we have to keep chunking and slicing differently if we want to keeep making changes.
I think this is the primary message the book tells.
async
and await
FastAPI: Concurrency and async / await
The detailed exmaples are a bit confusing for me… and it does not provide clear definitions of the terminologies, not sure they have clear definitions tho.
By leveraging asynchronous (concurrency) code, we can avoid blocking I/O operations. Let's say, we have an API server that queries a database and returns the result. When the server accept a request, the process does not have to block I/O during database queries. Instead, the process can wait for the result on the side, without blocking I/O, leveraging concurrency.
Python Documentation: Coroutines and Tasks
Coroutines declared with the async/await syntax is the preferred way of writing asyncio applications. For example, the following snippet of code prints “hello”, waits 1 second, and then prints “world”:
>>> import asyncio
>>> async def main():
... print('hello')
... await asyncio.sleep(1)
... print('world')
>>> asyncio.run(main())
hello
world
coroutine Coroutines are a more generalized form of subroutines. Subroutines are entered at one point and exited at another point. Coroutines can be entered, exited, and resumed at many different points. They can be implemented with the async def statement.
I started with observation, using the third test case.
(n, m, k) = (10, 3, 8)
The sample test cases result in non-complete decreasing arrays. So, I
went ahead with [10, 9, 8, ..., 3, 2, 1]
f(1) = 10, g(1) = 0
f(2) = 19, g(2) = 0
f(3) = 27, g(3) = 0
f(4)~f(7) = 27, g(4)~g(7) = 0
f(8) = 27, g(8) = 3
f(9) = 27, g(9) = 5
From the observation, to minimize the sum of g(), we must order
1, 2, ...
from where g() > 0.
How about f()? to max out f() as soon as possible, we need to order
10, 9, ...
from the beginning.
Given the constraint m < k
, f() maxes out earlier
than g() starts having values. Therefore, we can start with a decreasing
subarray, and end with an increasing subarray to minimize g().
for _ in range(int(input())):
n, m, k = map(int, input().split())
res = []
for i in range(n):
if i < n - m:
res.append(n - i)
else:
res.append(i - n + m + 1)
print(" ".join([str(x) for x in res]))
IBM Documentation: Cyclomatic complexity
Cyclomatic complexity is a measurement developed by Thomas McCabe to determine the stability and level of confidence in a program. It measures the number of linearly-independent paths through a program module. Programs with lower Cyclomatic complexity are easier to understand and less risky to modify.
rubik/radon seems to be the most popular code analysis tool to check cyclomatic complexity, but the package does not support Python 3.11~.
TODO: Research the detailed algorithm of it.
Ketone 50 mg/dl
Cheese 5g Salad 10g Bacon Egg 5g
Total carbohydrate 20g
push ups 6k run
MUST:
difficulty
in the
dashboard/codeforces APITODO: