From 99783e7acaa3e8d3ac1a8564c69fac08ba45b080 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 27 Dec 2022 13:35:57 +0000 Subject: - Added solutions by Feng Chang. - Added blog post by Roger Bell_West. - Added solutions by Mark Anderson. - Added solutions by Thomas Kohler. - Added solutions by David Ferrone. - Added solutions by W. Luis Mochan. - Added solutions by Carlos Oliveira. - Added solutions by Robbie Hatley. - Added solutions by Luca Ferrari. - Added solutions by Stephen G. Lynn. - Added solutions by Robert DiCicco. --- challenge-197/robert-dicicco/julia/ch-1.jl | 77 ++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 challenge-197/robert-dicicco/julia/ch-1.jl (limited to 'challenge-197/robert-dicicco/julia') diff --git a/challenge-197/robert-dicicco/julia/ch-1.jl b/challenge-197/robert-dicicco/julia/ch-1.jl new file mode 100644 index 0000000000..17a17ebe38 --- /dev/null +++ b/challenge-197/robert-dicicco/julia/ch-1.jl @@ -0,0 +1,77 @@ +#!/usr/bin/env julia + +#= + +AUTHOR: Robert DiCicco + +DATE : 2022-12-26 + +Challenge 197 Move Zero ( Julia ) + +=# + +using Printf + +  + +lists = [[1, 0, 3, 0, 0, 5],[1, 6, 4],[0, 1, 0, 2, 0]] + +  + +for list in lists + + i = 1 + + left = Int64[] + + right = Int64[] + + @printf("Input: @list = %s\n", list) + + while i <= length(list) + + if list[i] > 0 + + push!(left,list[i]) + + else + + push!(right, list[i]) + + end + + i += 1 + + end + + println("Output: ", cat(left,right,dims=1),"\n") + +end + +  + +#= + +----------------------------------------------------- + +SAMPLE OUTPUT + +julia .\MoveZero.jl + +Input: @list = [1, 0, 3, 0, 0, 5] + +Output: [1, 3, 5, 0, 0, 0] + +  + +Input: @list = [1, 6, 4] + +Output: [1, 6, 4] + +  + +Input: @list = [0, 1, 0, 2, 0] + +Output: [1, 2, 0, 0, 0] + +=# -- cgit