add colorizer test
This commit is contained in:
parent
50dc6c3c66
commit
ebac2cfa10
2 changed files with 2569 additions and 0 deletions
|
@ -0,0 +1,26 @@
|
|||
# n-queens (nqueens) solver, for nsquaresx-by-nsquaresy board
|
||||
|
||||
struct Queen
|
||||
x::Int
|
||||
y::Int
|
||||
end
|
||||
hitshorz(queena, queenb) = queena.x == queenb.x
|
||||
hitsvert(queena, queenb) = queena.y == queenb.y
|
||||
hitsdiag(queena, queenb) = abs(queena.x - queenb.x) == abs(queena.y - queenb.y)
|
||||
hitshvd(qa, qb) = hitshorz(qa, qb) || hitsvert(qa, qb) || hitsdiag(qa, qb)
|
||||
hitsany(testqueen, queens) = any(q -> hitshvd(testqueen, q), queens)
|
||||
|
||||
function trysolve(nsquaresx, nsquaresy, nqueens, presqueens = ())
|
||||
nqueens == 0 && return presqueens
|
||||
for xsquare in 1:nsquaresx
|
||||
for ysquare in 1:nsquaresy
|
||||
testqueen = Queen(xsquare, ysquare)
|
||||
if !hitsany(testqueen, presqueens)
|
||||
tryqueens = (presqueens..., testqueen)
|
||||
maybesol = trysolve(nsquaresx, nsquaresy, nqueens - 1, tryqueens)
|
||||
maybesol !== nothing && return maybesol
|
||||
end
|
||||
end
|
||||
end
|
||||
return nothing
|
||||
end
|
2543
extensions/vscode-colorize-tests/test/colorize-results/test_jl.json
Normal file
2543
extensions/vscode-colorize-tests/test/colorize-results/test_jl.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue