aboutsummaryrefslogtreecommitdiff
path: root/challenge-333/hvukman/f#/333_p2.fs
blob: 1b6209313d0342675f15a837492df94b96a83c4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 333 part 2

let input_1 = [| 1;0; 2; 3; 0; 4; 5; 0 |]
let input_2 = [| 1; 2; 3 |]
let input_3 = [| 1; 2; 3; 0 |]
let input_4 = [| 0; 0; 0; 0 |]
let input_5 = [| 1; 2; 0; 3; 4 |]
let inputs_2 = [ input_1; input_2; input_3; input_4; input_5 ]

// if 0 double else x; then truncuate to length of x
let dup (x:int array) = Array.collect (fun x -> match x with 
                                                  |0 -> [|0;0|]
                                                  |_ -> [|x|] ) x |> Array.take (Array.length x)               
    
for i in (inputs_2) do
    for j in dup(i) do
        printf "%i " j
    printf "%s\n" ""