Code coach challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Code coach challenge

It failed 3 test cases. Tried to complete it using regex alone but it failed to match the punctuations. #third if statement #if pa.match? /[@#

amp;*!%]/ print "Strong" #doesn't match https://code.sololearn.com/cA654G3rTYnA/?ref=app

4th Jun 2020, 12:27 PM
Justus
Justus - avatar
2 Answers
+ 8
input = gets.chomp def check_special_char(input) freqs = {} y = 0 freqs.default = 0 input.each_char{|char|freqs[char]+=1} ["!", "@", "#", "
quot;, "%", "&", "*"].each{|x| y+=freqs[x]} return y end def check_numbers(input) freqs = {} y = 0 freqs.default = 0 input.each_char{|char|freqs[char]+=1} ("0".."9").each{|x| y+=freqs[x]} return y end special = check_numbers(input) number = check_special_char(input) if input.length > 6 && special >1 && number >1 puts "Strong" else puts"Weak" end
4th Jun 2020, 12:29 PM
ÃKR
ÃKR - avatar
+ 1
AKR thanks but I want to know what's wrong with mine
4th Jun 2020, 12:39 PM
Justus
Justus - avatar