-
Notifications
You must be signed in to change notification settings - Fork 0
/
fractalTree.fs
68 lines (53 loc) · 1.57 KB
/
fractalTree.fs
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
open System
let data = Console.ReadLine()
let mutable max = 5
let mutable scope = 19
let columns = 100
let mutable i = 1
let mutable j = 1
let dash() =
while i <= columns do
printf "_"
i <- i + 1
done
printfn ""
let body() =
while max > 0 do
let rows = (( ** ) (2 |> double) ((5 - max) |> double) |> int)
i <- 1
while i <= rows do
j <- 1
while j <= 100 do
let left = (j - scope) % (4 * rows) - (i - 1)
let right = (j - scope + (2 * rows) + i - 1) % (4 * rows)
if max <= (data |> int) && (j - scope) >= 0 && (j + scope) <= columns then
if left = 0 || right = 0 then
printf "1"
else
printf "_"
else
printf "_"
j <- j + 1
done
i <- i + 1
printfn ""
done
i <- 1
while i <= rows do
j <- 1
while j <= columns do
let m = (j - scope + (3 * rows)) % (4 * rows)
if max <= (data |> int) && (j - scope) >= 0 && (j + scope) <= columns && m = 0 then
printf "1"
else
printf "_"
j <- j + 1
done
i <- i + 1
printfn ""
done
max <- max - 1
scope <- scope + rows
done
dash()
body()