The Peg Puzzle Solved (Think Like a Programmer)

Sdílet
Vložit
  • čas přidán 4. 07. 2024
  • There's a puzzle with 15 holes and 14 pegs that I hadn't solved, and I thought, why am I solving this when I could write a program to solve it for me? You'll see the thoughts behind the program, the mistakes I made along the way, and some discussion of how we should choose approaches that match our programming strengths and weaknesses.
    Your comments and suggestions for future videos are welcome.
    "Think Like a Programmer" is a book I've written to help programmers with problem solving. If you've found that you are able to read programs and understand programming language syntax but aren't always confident writing programs from scratch, my book can help.
    For more information on the book head to one of these:
    Amazon page for the book: amzn.to/1MZlmlY
    My site: www.vantonspraul.com/TLAP
    My publisher's site: nostarch.com/thinklikeaprogrammer
    Connect with me:
    My site: vantonspraul.com
    Twitter: / vantonspraul
    Facebook: / thinklikeaprog
  • Věda a technologie

Komentáře • 11

  • @Pulsed101
    @Pulsed101 Před 3 lety

    The code is waaaay over my head but at least I can follow your logic, very impressive

  • @manishguptablackberry
    @manishguptablackberry Před 4 lety +1

    Great efforts

  • @Alexander-oh8ry
    @Alexander-oh8ry Před 4 lety +3

    This is unbelievably different from my approach for such a simple thing

    • @Pulsed101
      @Pulsed101 Před 3 lety

      Any chance you're willing to share your solution? I have no idea how I would approach it

    • @Alexander-oh8ry
      @Alexander-oh8ry Před 3 lety +2

      @@Pulsed101 Id use a 2d array to store the state, which would make the legal move definition much easier, and for such a simple program I would not use any structs. Also, I would not use an extra board state editor that changes a binary number that represents the board state because this would take more time to make than simply writing some input based functions in the code that can visualize the board and let you dynamically change it.

  • @Razyelgore
    @Razyelgore Před 2 lety

    Its very interesting wish you showed all the code

  • @jeffrygeorges1152
    @jeffrygeorges1152 Před 3 lety

    What programming software is this?
    (Im a noob)

  • @mohammedjawahri5726
    @mohammedjawahri5726 Před 3 lety

    Why not work it backwards? No need to check "all pegs" if u can just work backward from the hole

  • @mxdici
    @mxdici Před 4 lety +5

    Bro, what is going on

  • @ruthannmarie7119
    @ruthannmarie7119 Před 4 lety

    Just show the answer .lol