Shuffling Arrays and a Map Trick (Advent of Vue #14)

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 2024
  • My solution to the 14th Advent of Vue challenge! New favorite - we get to talk about shuffling algorithms and the the jankiness of Array.prototype.sort.
    👉 Fisher Yates Shuffle: en.wikipedia.o...
    🎄 Advent of Vue: adventofvue.com/
    💻 Code: github.com/lmi...
    🐦 Keep up with me on Twitter! / lachlan19900
    If you like my teaching style, I have a book and two courses!
    👀 (Book) Design Patterns for Vue.js: lachlan-miller... (YT_5_OFF for $5 off)
    👉 (Course) Vue.js: The Composition API: www.udemy.com/...
    🖖 (Course) Complete Vue.js 3: www.udemy.com/...

ความคิดเห็น • 9

  • @nyanRETARD
    @nyanRETARD ปีที่แล้ว +1

    I love this video and your style! Straight to the point with interesting details without any mumbo jumbo. Your speech is very clean and the speed is not too slow. Thank you.

    • @LachlanMiller
      @LachlanMiller  ปีที่แล้ว

      Thank you for the kind words!
      I'd still like to speak a bit more clearly. I'm glad you appreciate the pace.

  • @michaelm8044
    @michaelm8044 ปีที่แล้ว

    Thanks for the video, I am a fan of the way you went about solving this problem. It's always nice to get an idea of the history of the algorithm as well and it's much appreciated. Can't wait for more videos!

    • @LachlanMiller
      @LachlanMiller  ปีที่แล้ว +2

      Thanks for the support - I appreciate it. More videos soon!

  • @_the_one_1
    @_the_one_1 ปีที่แล้ว

    Thank you so much, this is my favorite video I am sure I wouldn't have come out with such a great solution. Didn't know about the sort and random, definitely helpful to keep in mind optimizations when coding and Github Copilot is not helping with that.
    Again, thank you I always look forward to your solutions!

    • @LachlanMiller
      @LachlanMiller  ปีที่แล้ว +1

      Glad you found it useful!
      Advent of Vue #17 is the lsat one - the organizers didn't have enough puzzles lined up, apparently. Still a good effort - making 17 puzzles is tough. I have lots of other ideas for content, so no problem - stay tuned!

    • @_the_one_1
      @_the_one_1 ปีที่แล้ว +1

      @@LachlanMiller always looking forward to your content.
      Thank you

  • @florianbopp187
    @florianbopp187 ปีที่แล้ว

    Very nice solution, thanks! The only thing I slightly disliked, is using a while loop with an increment variable. A for loop, which is basically just syntactic sugar for a while loop where you need to increment (or any other operation) a variable on each iteration, would be better from a stylistic point. Making the function more readable without needing to look for where the variable is being modified.

    • @LachlanMiller
      @LachlanMiller  ปีที่แล้ว +1

      I'm on your side here. Initially I thought the while loop was cute and concise, but I almost always regret using one.
      Better implementation here: stackoverflow.com/questions/63777468/randomizing-a-two-dimensional-array-inside-a-loop. Uses a for loop, and also uses the optimization I mentioned (Durstenfeld shuffle).