Using Graph Theory to Tackle the 1st "Hard" Problem from Project Euler! (PE#60 - C/C++)

Поділитися
Вставка
  • Опубліковано 1 січ 2025

КОМЕНТАРІ • 10

  • @NonTwinBrothers
    @NonTwinBrothers 10 місяців тому

    Excellent explanation, code was quite easy to follow
    + I'm totally stealing that alternate for-loop from now on
    Looking forward for part 2!

  • @TheSubsonicOne
    @TheSubsonicOne 10 місяців тому +2

    that bump in the data IS weird.

  • @driedurchin
    @driedurchin Рік тому

    Great video by the way!

  • @rayanebait
    @rayanebait 6 місяців тому +2

    Hey, a small comment on the density of the graph. So that graph looks more or less like y=1/x. A possible reason I found comes from dirichlet's theorem on arithmetic progressions. Consider the following: the concatenation of two primes p1 and p2 can be written as p1*10^n+p2, suppose this is a prime and write it p. Then we have p = p2 mod p1 AND p = p1*10^n mod p2. Now what is the probability of that? Dirichlet's theorem says there is roughly 1 chance over p1 for the first and 1 chance over p2 for the second. Combining these two we get 1/p1p2 chances of have a directed edge between the two. By symmetry, we get (1/p1p2)^2 chances of having an undirected edge between p1 and p2. Now to have a vague idea of the density, you can compute the arithmetic mean (1/N^2)*Sum((1/p1p2)^2)

    • @rayanebait
      @rayanebait 6 місяців тому

      (Great video by the way! )

  • @driedurchin
    @driedurchin Рік тому

    Do you post your source code somewhere for these solutions?

    • @MatthewBouyack
      @MatthewBouyack  Рік тому +1

      I haven't, though I've occasionally thought about uploading it to GitHub or similar. If I do, I'll be sure to mention it here!

    • @driedurchin
      @driedurchin Рік тому +1

      @@MatthewBouyack In the meantime, can you point me to the video where you implemented that prime number generate you reference?

    • @MatthewBouyack
      @MatthewBouyack  Рік тому +3

      @@driedurchin There was a series of five videos. The first shows the basic algorithm, then videos 2-5 go through the process of creating a static library, wrapping the algorithm in a class, and writing tests for the class. I just created a playlist that has all five:
      ua-cam.com/play/PLNBEGpVIu6jVcrQVSQIkNkXJ54trBudt0.html

    • @driedurchin
      @driedurchin Рік тому

      @@MatthewBouyack Thanks!