aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2022-11-07 19:34:46 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2022-11-07 19:34:46 +0000
commit787cb33b3af40ad2061b6401c37f4224f324f184 (patch)
tree562c042a46b79a2ac0a9e47b246d9fae44e4b2a1
parent932f8001da0046a9da141a3ee9b149199e8187e3 (diff)
downloadperlweeklychallenge-club-787cb33b3af40ad2061b6401c37f4224f324f184.tar.gz
perlweeklychallenge-club-787cb33b3af40ad2061b6401c37f4224f324f184.tar.bz2
perlweeklychallenge-club-787cb33b3af40ad2061b6401c37f4224f324f184.zip
- Added more guest contribution by Robert DiCicco.
-rw-r--r--challenge-190/robert-dicicco/julia/ch-1.jl87
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