HNHacker News
TopNewBestAskShowJobs

qsantos

1,500 karma · joined March 4, 2021

https://qsantos.fr/

qsantos@qsantos.fr

Socials: - github.com/qsantos - linkedin.com/in/qsantos

submissionscomments
qsantos··on Dynamic programming is not black magic
But how to you systematically deduce the tail recursion version?

I feel like, in this case, the recursivity in definition of Fibonacci and the recursivity in the tail recursion is just a coincidence, with the second just being a contrived way to write the loop you get after applying dynamic programming and trimming the table to only the last two elements.

qsantos··on Dynamic programming is not black magic
Thanks for the details. To add to this discussion, I have a script to see the progression over the days.

Looking at the last two columns, you can see how brutal 2023 was compared to 2022. Especially in the beginning. The first few days, most people keep playing, with a retention higher than 80% most days, and virtually everyone people solve both parts. In contrast, only 76% of people solved part 2 after solving part 1. And many people gave up on days 3 and 5.

Interestingly, the last few days are not that much lower. And that can be explained by the fact that AoC 2023 is more recent than AoC 2022, like you said. My interpretation is that this group of people will get over all the challenges regardless of the difficulty (to an extent, of course), while many other people will give up when they realize it will take too much of their time.

    Stats for year 2022 of Advent of Code
    -------------------------------------
    
    Day   Both puzzles   One puzzle       Total   Rel. puzzle 1/2   Rel. day before
      1        280,838       15,047     295,885              95 %             100 %
      2        232,752       12,403     245,155              95 %              83 %
      3        200,016       11,392     211,408              95 %              86 %
      4        184,435        3,734     188,169              98 %              92 %
      5        157,392        3,116     160,508              98 %              85 %
      6        155,921        1,602     157,523              99 %              99 %
      7        113,241        2,592     115,833              98 %              73 %
      8        107,224        7,659     114,883              93 %              95 %
      9         82,414       11,449      93,863              88 %              77 %
     10         85,075        5,511      90,586              94 %             103 %
     11         68,838        9,258      78,096              88 %              81 %
     12         59,253        1,061      60,314              98 %              86 %
     13         51,512        1,220      52,732              98 %              87 %
     14         49,051          991      50,042              98 %              95 %
     15         39,677        5,773      45,450              87 %              81 %
     16         23,298        5,650      28,948              80 %              59 %
     17         21,525        6,237      27,762              78 %              92 %
     18         25,420        4,927      30,347              84 %             118 %
     19         17,516          928      18,444              95 %              69 %
     20         22,141        1,003      23,144              96 %             126 %
     21         23,022        3,060      26,082              88 %             104 %
     22         15,393        5,083      20,476              75 %              67 %
     23         18,531          254      18,785              99 %             120 %
     24         16,419          252      16,671              98 %              89 %
     25         13,192        7,473      20,665              64 %              80 %
    ~/src/advent-of-code% ./stats.py 2023
    Stats for year 2023 of Advent of Code
    -------------------------------------
    
    Day   Both puzzles   One puzzle       Total   Rel. puzzle 1/2   Rel. day before
      1        230,737       73,941     304,678              76 %             100 %
      2        196,352        9,256     205,608              95 %              85 %
      3        130,406       19,913     150,319              87 %              66 %
      4        130,271       17,691     147,962              88 %             100 %
      5         80,255       31,029     111,284              72 %              62 %
      6        103,358        1,918     105,276              98 %             129 %
      7         81,905        7,308      89,213              92 %              79 %
      8         74,034       14,707      88,741              83 %              90 %
      9         76,438        1,229      77,667              98 %             103 %
     10         48,313       17,054      65,367              74 %              63 %
     11         57,339        2,386      59,725              96 %             119 %
     12         30,985       14,440      45,425              68 %              54 %
     13         38,217        5,223      43,440              88 %             123 %
     14         36,500        7,457      43,957              83 %              96 %
     15         40,881        4,156      45,037              91 %             112 %
     16         35,347        1,023      36,370              97 %              86 %
     17         24,014        1,097      25,111              96 %              68 %
     18         24,799        4,937      29,736              83 %             103 %
     19         22,525        7,197      29,722              76 %              91 %
     20         18,287        4,398      22,685              81 %              81 %
     21         14,311       10,149      24,460              59 %              78 %
     22         15,830          988      16,818              94 %             111 %
     23         14,562        2,964      17,526              83 %              92 %
     24         11,864        4,918      16,782              71 %              81 %
     25         10,522        3,048      13,570              78 %              89 %
qsantos··on Dynamic programming is not black magic
The issue I have with not connecting dynamic programming with caching is that it becomes an exercise in cleverness, and many people just give up. It was pretty fun in school, but if I need colleagues to ramp up on it, I need a more effective approach. Sure, they might not grok the full theory right away, but they won't use it at all, and definitely won't get to the theory, if they think it's too abstract for them.
qsantos··on Dynamic programming is not black magic
I think the point of GP is that saying it's basically “smart caching”, or “filling the cache in the correct order” helps connect with a concept many people are already very familiar with, which grounds the concept immediately. In contrast, going through each step you have outlined introduces several new concepts that are generally new and counter-intuitive to most people, so many will just give up.
qsantos··on Dynamic programming is not black magic
I have listed a few in the article. It's pretty common to see them in lectures and practical exercices.

- longest common subsequence

- longest common substring

- line warp

- subset sum

- partition

- knapsack

You can also have a look at [1] for more ideas.

[1] https://en.wikipedia.org/wiki/Dynamic_programming#Algorithms...

qsantos··on Dynamic programming is not black magic
Did you encounter practical problems where genetic algorithms work well? So far, the only serious usage I did was for CodinGame's Mars Lander optimization problem (and it works pretty well there!).
qsantos··on Dynamic programming is not black magic
Ah yes, but I use Rust, I cannot go back up a tree (-:
qsantos··on Dynamic programming is not black magic
Do you mean tree rebalancing algorithms? I have to agree with this. AVL tree insertion is fine enough, but it gets hairy when you get to deletion. And Red-Black trees…
qsantos··on Dynamic programming is not black magic
I totally agree in that I use the same mental model. But, if you look at it as “the shortest path must be the shortest path through one of its neighbors”, it can actually be classified as a dynamic programming algorithm!

https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Dynamic...

qsantos··on Dynamic programming is not black magic
Thanks! I should have planned better for that before posting.
qsantos··on Dynamic programming is not black magic
It _is_ a funny quote.

But I would still point out that this is the exact reason “dynamic” does not help if you do not know about the history. Since it can be applied to anything, it does not help you trim down what it can refer to.

qsantos··on Dynamic programming is not black magic
From my own experience, being taught dynamic programming straight way makes it more of a puzzle. By going through the steps and explaining _why_ we are using a table, and connecting the concept to caching, I feel like it makes much more sense.
qsantos··on Dynamic programming is not black magic
Absolutely. I did not bother so far, since I was mostly writing for myself. But I should have before posting here; I know what the hug of death means!
qsantos··on Dynamic programming is not black magic
Sorry about that. It looks like the MySQL database did not like the sudden influx of traffic. It's back up!
qsantos··on Confusing Git Terminology
Because they are referring to different things. `mybranch` is a reference in your local repository. `origin/mybranch` is a reference on a remote repository that you call `origin`, `origin/mybranch` is just a representation of this remote reference for convenience.

So, if we take the example from derefr [1], `git chekcout foo` lets you go to your own local branch `foo`. Then, `git reset --hard origin/foo` modifies the current local ref (`foo`) to be the same as `origin/foo`, and change the working directory accordingly.

[1] https://news.ycombinator.com/item?id=38118475

qsantos··on IPv4 Turf War
I noticed a weird broken image at the bottom of Justine's articles https://justine.lol/cosmo3/ in a recent HN submission. It turns out the whole Cosmopolitan project is just an elaborate ruse to write articles that will get a lot of attention and get as many readers as possible to load a URL that claims that visitor's IP address for fake Internet points: https://ipv4.games/about.html

Previous discussion: https://news.ycombinator.com/item?id=32790429 (September 2022)

PS: Just in case, since I am bad at jokes: the Cosmopolitan project is a real and very cool thing.

qsantos··on A guy preserving the new history of PC games, one Linux port at a time
You can also try the Kill Sticky add-on for Firefox: https://addons.mozilla.org/fr/firefox/addon/kill-sticky/. It will also get rid of the annoying banner in fixed position at the top.
qsantos··on Chicago’s parking meter disaster
Compound interest:

    >>> 11**(1/75)
    1.0324885301426248
qsantos··on Crates.io Postmortem: User Uploaded Malware
Related thread: https://news.ycombinator.com/item?id=37259786
qsantos··on ProtonMail Outage
The Android app is not working either
qsantos··on [dead]
The Android app is not working either
qsantos··on Why SQLite does not use Git (2018)
> There were many scripting languages, javascript will be the final one

If, by “scripting languages”, you mean “browser-native languages”, WebAssembly might become a serious contender as the lingua franca for the Web in the long term.

qsantos··on A Nihilist's Guide to Meaning (2016)
There is nothing special about 生きがい (ikigai). It's just Japanese for “reason for living”.

There is a wider phenomenon where people attribute deep meaning to mundane Japanese words, such as 改善 (kaizen, improvement), 引きこもり (hikikomori, recluse), or even 看板 (kanban, board). This sounds like a case of exoticism.

qsantos··on 6 days to change 1 line of code (2015)
Shirley's review was accurate for a non-urgent MR, but was bogging an urgent ticket. Ignoring them would not have increased risk, but the policy is important to manage technical debt. A simple resolution in this case is to move the comments to technical tickets, assign them to Ed for later, and approve the MR.
qsantos··on OpenSSH has some peculiar handling around command line arguments
But you could expect

    ssh localhost sh -c 'cd /tmp && pwd'
to pass "sh -c 'cd /tmp && pwd'" over the network, which would trigger the expected behavior. But the arguments are not quoted so you end up with just: "sh -c cd /tmp && pwd".
qsantos··on Mistakes with Rust smart pointers: when Deref goes wrong
For the record, I have noticed two other places where the angle brackets are missing:

    struct AsciiString(Vec);
and

    impl Index> for AsciiString {
qsantos··on Ask HN: Who wants to be hired? (July 2023)
Location: Paris, France

Remote: yes, I am used to working fully remote, including in English

Willing to relocate: not short-term

Technologies: Rust, Python, React, C & C++

Résumé/CV: https://qsantos.fr/portfolio/ & https://www.linkedin.com/in/qsantos/

Email: qsantos@qsantos.fr

I tend to go deep into multiple topics. I especially enjoy making correct software and optimizing it. Thus, Cython, formal methods and Rust.

After implementing cryptographic primitives in low level C with SIMD, I went for a PhD to really understand cryptography. You can find a summary here: https://research.wmz.ninja/projects/phd/index.html (not by me).

I have spent too much time implementing and optimizing a Keplerian orbit simulator after playing Kerbal Space Program, I wrote multiple software project to help me learn Japanese, and I am now trying to improve Morse learning (WIP).

qsantos··on Ask HN: Could you share your personal blog here?
https://qsantos.fr/

Rants about C and undefined behaviors, random experiments with ham-compatible cryptography.

I finally gave up writing my own blog engine after a few iterations over the decades. I am just using WordPress. So at least, there is no article about how I implemented _this_ blog!

qsantos··on Fast machines, slow machines
That's not the point from the quote, and it is actually discussed in the Google article
qsantos··on Fast machines, slow machines
Check it with a cryptographic hash. With I/O bottleneck, and assuming a SSD at 300 MB/s, that should bring the latency to 3 ms, well below human perception. Even the 60 MB/s of slow HDDs should be more than fine.

Anyone who has worked on optimizing complex programs knows that you can do a lot with a computer. > 100 ms latency to open Notepad is just ridiculous.

← PreviousPage 2 of 3Next →