From 63d718f642de2b165f3c5a2f2232b26c5b93d95f Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 4 Oct 2022 16:35:11 +0100 Subject: - Added guest contribution by Robert DiCicco. --- challenge-185/robert-dicicco/ruby/ch-2.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 challenge-185/robert-dicicco/ruby/ch-2.rb diff --git a/challenge-185/robert-dicicco/ruby/ch-2.rb b/challenge-185/robert-dicicco/ruby/ch-2.rb new file mode 100644 index 0000000000..0e7cdb6235 --- /dev/null +++ b/challenge-185/robert-dicicco/ruby/ch-2.rb @@ -0,0 +1,31 @@ +#!ruby.exe + +# AUTHOR: Robert DiCicco +# DATE: 2022-10-04 +# Challenge 185 Mask Code ( Ruby ) + +inp = ['ab-cde-123', '123.abc.420', '3abc-0010.xy', '1234567.a', 'a-1234-bc', 'a.b.c.d.e.f'] + +for code in inp do + + cnt = 0; # where we are in the string + + fnd = 0; # count of characters changed + + while fnd < 4 do + + if (code[cnt,1] =~ /[0-9]|[a-z]/) + + code[cnt] = 'x' + + fnd += 1 + + end + + cnt += 1 + + end + + puts code + +end -- cgit