-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoordinates.jl
More file actions
51 lines (47 loc) · 1.14 KB
/
coordinates.jl
File metadata and controls
51 lines (47 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using PrettyTables
mines = rand(1:64, 1, 9)
println(mines)
function checkuniq(mine)
#println(mines)
while !(allunique(mine))
mine = rand(1:64, 1, 9)
return mine
end
end
function coords(c)
if c % 8 == 0
y = 8
x = c ÷ 8
else
y = c % 8
x = (c ÷ 8) + 1
end
return x, y
end
function user_input()
println("Enter a number from 1:64:")
u_input = parse(Int, readline())
return u_input
end
if !(allunique(mines))
mines = checkuniq(mines)
println(mines)
for i in mines
println("The coordinates of mine at square ", i, " is ", coords(i))
end
else
println("All mines are unique in first pass")
end
grid = Array{Union{String, Int32}}(undef, 8, 8)
grid .= " "
#grid = pretty_table(arr, noheader=true, hlines=1:8)
inputs = zeros(Int32, 8, 8)
inpval = user_input()
coordinates = Int32[]
coordinates = coords(inpval)
println(coordinates)
inputs[coordinates[1],coordinates[2]] = 2
#pretty_table(inputs; noheader=true, hlines=1:8)
grid[coordinates[1],coordinates[2]] = inputs[coordinates[1], coordinates[2]]
#grid[4,5] = inputs[4,5]
pretty_table(grid, noheader=true, hlines=1:8)