Programming a Backtracking Sudoku Solver in Scala

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 พ.ย. 2024

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

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

    Thanks! Interesting Sudoku solution on Scala

    • @rockthejvm
      @rockthejvm  2 ปีที่แล้ว

      Glad you liked it!

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

    Hey, thanks for the video. How would you change the code using immutable board, maybe using Vectors?

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

      1. pass it as argument to the backtracking method
      2. instead of mutating the board, pass a new (changed) argument in the recursive calls

  • @ezzaron2328
    @ezzaron2328 2 ปีที่แล้ว

    Thank you, if I wanted the solve to return an array, would I map it?

    • @rockthejvm
      @rockthejvm  2 ปีที่แล้ว

      Clone the array, run the algorithm on it, then return the filled array. The thing is that Sudoku can have multiple solutions, so you need to return an array of 2D arrays.

  • @EnergyCreator05
    @EnergyCreator05 2 ปีที่แล้ว

    Would backtracking be possible with immutable Board?

    • @rockthejvm
      @rockthejvm  2 ปีที่แล้ว

      Of course - along with the coordinate change, you'll also change the Board.

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

    Is this Scala related to Scala from the Amiga circa 1990?

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

    Seriously? Using count instead of contains, apply instead of just brackets, and overall inefficient and unreadable code?

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

      Definitely possible to make it more concise. Feel free! This is a video for beginners who might not get all the compactness at once.

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

      Naah, this is pretty much readable. Perhaps, you haven't seen legacy scala code running in production and mostly written by java devs.