diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-10-04 16:35:11 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-10-04 16:35:11 +0100 |
| commit | 63d718f642de2b165f3c5a2f2232b26c5b93d95f (patch) | |
| tree | 7f642b8aad7c3cb0f256438e52e538155f4c78e5 | |
| parent | eec75c81b329ee794cb6703c5f04e21574e55e7a (diff) | |
| download | perlweeklychallenge-club-63d718f642de2b165f3c5a2f2232b26c5b93d95f.tar.gz perlweeklychallenge-club-63d718f642de2b165f3c5a2f2232b26c5b93d95f.tar.bz2 perlweeklychallenge-club-63d718f642de2b165f3c5a2f2232b26c5b93d95f.zip | |
- Added guest contribution by Robert DiCicco.
| -rw-r--r-- | challenge-185/robert-dicicco/ruby/ch-2.rb | 31 |
1 files changed, 31 insertions, 0 deletions
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 |
