Featured image of post Weekly Report 2024.17

Weekly Report 2024.17

what is real life?

If you stayed at home long enough, the place you live in will become irrelevant.

Entertainment

Dave the diver

very relaxing causual game, which also makes me think, you have to become some kind of expert before you get old, or else, we don’t what kind of life is waiting for you.

Learning

We could use datetime, calendar built-in functions to deal with datetime problems in python

    1. Day of the Year datetime(y,m,d).days
    1. Day of the Week calendar.weekday(year, month, day)

classic BFS

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Solution:
    def openLock(self, deadends: List[str], target: str) -> int:
        st = set(deadends)
        q = deque(["0000"])
        step = 0
        while q:
            sz = len(q)
            for _ in range(sz):
                cur = q.popleft()
                if cur == target:
                    return step

                # skip already visited pattern
                if cur in st:
                    continue
                st.add(cur)

                # next pattern
                for i in range(4):
                    plus, minus = "", ""
                    if cur[i] == "9":
                        plus = cur[:i] + "0" + cur[i + 1 :]
                    else:
                        plus = cur[:i] + str(int(cur[i]) + 1) + cur[i + 1 :]
                    if cur[i] == "0":
                        minus = cur[:i] + "9" + cur[i + 1 :]
                    else:
                        minus = cur[:i] + str(int(cur[i]) - 1) + cur[i + 1 :]
                    if plus not in st:
                        q.append(plus)
                    if minus not in st:
                        q.append(minus)
            step += 1
        return -1

Life

  • finally eased some nerves, spent a lot of time to play games, or should I?
  • the days before and between holiday were always kinda meaningless
    • the study plan was disrupted
    • the working was not progressing
    • the fun was just-so-so
  • I’d rather go to office regularly to maintain a more disciplined life pace

Sharing

References

Licensed under CC BY-NC-SA 4.0
Last updated on Jan 09, 2024 11:32 CST
The older I get, the more I realize that most of life is a matter of what we pay attention to, of what we attend to [with focus].
Built with Hugo
Theme Stack designed by Jimmy