Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
El algoritmo de backtrcing no funcionó correctamente

He escrito en Python Sudoku solver y backtarcing problemas... Y en la segunda Capa soduko está deshabilitado.

 function find(){ for (let x=0;x<mat.length;x++){ let y y = mat[x].findIndex((e)=>e===0) if (y!=-1){ return [x,y] } } } function is_valid(x,y,num){ if (mat[x].filter(target => target===num).length >=2){ return 0 } for(let i=0;i<mat.length;i++){ if (i === x){ continue } if (mat[i][y] === num ){ return 0 } } let X = x - x % 3 let Y = y - y % 3 let N = 0 for (let i =0;i<3;i++){ for (let j =0;j<3;j++){ if(mat[i+X][j+Y]== num){ N+=1 } if (N==2){ return 0 } } } return 1 } function solve(){ try { [x,y] = find() }catch{ alert('solve') return 1 } for (let i = 1 ;i<10;i++){ mat[x][y] = i; console.log(mat[x]) if (is_valid(x,y,i)){ solve() } } mat[x][y]=0 } solve()

¿Cuál es mi problema de código? Primero quiero poner el valor en el soduko y luego verificar si el valor es válido o no ... y resolverlo

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!