diff options
| -rw-r--r-- | challenge-190/robert-dicicco/julia/ch-1.jl | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/challenge-190/robert-dicicco/julia/ch-1.jl b/challenge-190/robert-dicicco/julia/ch-1.jl new file mode 100644 index 0000000000..c506d00621 --- /dev/null +++ b/challenge-190/robert-dicicco/julia/ch-1.jl @@ -0,0 +1,87 @@ +#!/usr/bin/env julia + +#= + +AUTHOR: Robert DiCicco + +DATE: 2022-11-07 + +Challenge 190 Capital Detection ( Julia ) + + + +You are given a string with alphabetic characters only: A..Z and a..z. + +Write a script to find out if the usage of Capital is appropriate + +if it satisfies at least one of the following rules: + + + +1) Only first letter is capital and all others are small. + +2) Every letter is small. + +3) Every letter is capital. + + + +SAMPLE OUTPUT + +Input: $s = "Perl" + +Output: 1 + + + +Input: $s = "TPF" + +Output: 3 + + + +Input: $s = "PyThon" + +Output: 0 + + + +Input: $s = "raku" + +Output: 2 + +=# + + + +using Printf + +words = ["Perl", "TPF", "PyThon", "raku"] + + + +for s in words + + @printf("Input: \$s = \"%s\"\n",s) + + if occursin(r"^[A-Z][a-z]*$", s ) + + @printf("Output: 1\n") + + elseif occursin(r"^[a-z]*$", s) + + @printf("Output: 2\n") + + elseif occursin(r"^[A-Z]*$", s) + + @printf("Output: 3\n") + + else + + @printf("Output: 0\n") + + end + + println(" ") + +end |
