+ 12
CHALLENGE🔥🔥🔥: Sam wants to select a username to register on a website. The rules for selecting username:
1. The minimum length of the username must be 5 characters and the maximum may be 10. 2. It should contain at least one letter from A-Z 3. It should have at least one digit from 0-9 4. It should have at least one character from amongst @#*= 5. It should not have any spaces Write a program which accepts 4 usernames (one username per line) as input and checks whether each of them satisfy the above mentioned conditions. If it does, the program should print PASS (in uppercase) else print FAIL Happy Coding😉
18 Antworten
+ 8
@George, here's my attempt:
https://code.sololearn.com/c3F9veQpazci/?ref=app
+ 9
@Ipang both uppercases(A) and lowercase(a) can be used and 1_B@# should be a PASS since it an underscore(_) not a space( )
Thanks for the correction.
Happy Coding 😉
+ 8
@lpang yeah only the four characters are required for instance:
Suppose the following usernames are supplied to the program:
1234@a
ABC3a#@
1Ac@
ABC 3a#@
1_B@#
Then the output should be:
PASS
PASS
FAIL
FAIL
FAIL
+ 5
Hi @George Victor, I just need to confirm about point 4, are those four the only characters needed to be checked for existence? how about hyphen, underscore, tilde or period? are they not valid to be in a username?
Thanks : )
+ 4
@George, I am sorry I need to ask again, does alphabet letter case matter? I mean, if there exists only lowercase, and no uppercase, is that valid for name or no? also for that last one, why it failed the test?
1Ac@ <- FAILED - too short
ABC 3a#@ <- FAILED - contains space
1_B@# <- Why FAILED? it has letter, number, both @ and #
Thanks
+ 4
@George thanks for the confirmation, I will try to do this and get back to you later : )
+ 4
hey @Ipang
what is that npos (std::string::npos)
can u explain it to me ^_^
+ 3
Hey, George !
My pythonism :
https://code.sololearn.com/cdZav9g946Ir/#py
+ 3
@George
rules are.
1 lower
1 upper
1 number
1 special "@#*="
5 or more.
my code works.
tested both comp and phone.
+ 3
Not the first C++ attempt, but whatever.
https://code.sololearn.com/cjz32jBFzt5j/?ref=app
Just made a password generator!
https://code.sololearn.com/cU9cOjFDP6GA/?ref=app
+ 2
https://code.sololearn.com/c0B3Erq75q39/?ref=app
+ 2
Had a go at this, and made as much sense of the rules as I could:
https://code.sololearn.com/cv2aCbGw5uD0
+ 2
Hey @CuRSeD, it is a constant that we can use to verify whether or not the character we want to find exists in some string where we search for the character. The string class' find() method returns that constant when the character is not found in the string.
[Find method of string class]
http://en.cppreference.com/w/cpp/string/basic_string/find
[About the npos constant]
http://en.cppreference.com/w/cpp/string/basic_string/npos
P.S. Sorry I forgot to set the code public, you could've commented on it instead writing in here if I had : )
Hth, cmiiw
+ 1
https://www.sololearn.com/discuss/949767/?ref=app help me on this
+ 1
Sam wants to select a username in
order to register on a website.
2
The rules for selecting a username are:
4
5
m ON
8
9
10
1. The minimum length of the
username must be 5 characters and
the maximum may be 10.
2. It should contain at least one letter
from A-Z
3. It should contain at least one digit
from 0-9
4. It should contain at least one
character from amongst @#*=
5. It should not contain any spaces
11
13
14.
15
16
17
Write a program which accepts 4
usernames (one username per line) as
input and checks whether each of
them satisfy the above mentioned
conditions
19
0
An7*#0y
0
jo63*×y