From 787cb33b3af40ad2061b6401c37f4224f324f184 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 7 Nov 2022 19:34:46 +0000 Subject: - Added more guest contribution by Robert DiCicco. --- challenge-190/robert-dicicco/julia/ch-1.jl | 87 ++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 challenge-190/robert-dicicco/julia/ch-1.jl 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 -- cgit