Daily Challenge #99

Hi, today will be an easy one. Create a procedure (function) that generate randomized password.
Input will contain

  • (Num) Length of result
  • Exclude character (String) // if it is empty nothing is excluded.
  • CanBeRepeated (Boolean) // if true character can be repeated, otherwise not.

The generator by default contain (a-z) both upper and down case, 0-9, !@#$%^&*()

If length of result is less than 1, return “error”

Edit: In post 5 @Mohamed_Tamer found if can be repeated is false, it will crash if length is greater than 77. You should set condition to return “error” as well.

Happy koding!

5 Likes

BTW, there must add a note for the max length.Because for example when i try using my procedure with length 50 and CanBeRepeated set to false the app crashes?But it works successfuly for 1000 character if CanBeRepeated equals true.

Only one character or more than one ?

1 Like

Exclude character means all character in the string should not appear in the result.

That’s means the character can/cannot be repeated.

Length of the result = max length
I don’t understand.

1 Like

You didn’t understand me.I mean that:
If we set CanBeRepeated to false
And set the pass length to any number more then the number of characters we have which are those:

The app will crash because the meaning of that i set length to 80 and set CanBeRepeated to false.So the password will contain 80 different charectars Although there aren’t except 77 letter only so the app will go in an infinite loop which will cause it to crash.you can try using your procedure by setting its length to 80 and CanBeRepeated to false.
So there must be limit for the password length.
EDIT: i realized that they are 77 sorry :sweat_smile:

I see. I think I should set the limit.
Then,

Error should be returned as well to prevent crashing.
will be added to the first post

1 Like

I didn’t understand this.You mean that if we have excludeCharacter like this : “String”
So the password can’t contain S and t and r and i and n and g ! That means that it can’t be like that : hSjig6t)rfdn ?
Or, the password can’t contain the word String with all of it’s letter in a consecutive order.That means that it can’t be like that String89u798{ ?

1 Like

BTW, that means that the app may crash too because many characters may be removed.So the limit maybe 70 sometimes for example and 13 Sometimes?:thinking:

1 Like

I believe the same, it depends on the numbers of characters that will be removed

1 Like

Correct. Every character in exclude input must not appear.

1 Like

Btw, please expect all character in exclude input must be in the range I have given.
No need to catch error in that case

1 Like

You mean those:

Or you mean the range of 77 letters. my procedure was getting the max limit according to the exclude letters length.So it has no errors :man_shrugging:

Here is my procedure.it has no errors because it get the limit by subtracting the length of the letters that will be excluded.3 blocks can be reduced by setting the limit to a static number which is 77 ( if you want i can remove them :wink:).But the app will crash for the large numbers.That doesn’t happen in this procedure.:
But unfortunately,It has 51 blocks :sob:

Blocks


I don’t know why this black box?

Also another 3 blocks can be reduced by making the Exclude character input as a list.And not converting it.

2 Likes

Great, let’s wait for others

![|220x164](upload://2w14AwHbruI20kIOcxyIqVlyvq0.mp4)
1 Like

Here is my try
99

36 Blocks

Saw this just now :

Here is an updated one:

41 Blocks (Immune to this condition)

4 Likes

@Ansh_Anand, you solution doesn’t work with exclude input, so @Mohamed_Tamer wins!

Here is my own solution

2 Likes

Thanks very much :heart: i’m really happy because this is my first daily challenge that i win in :upside_down_face: BTW, congrats to @Ansh_Anand also. :partying_face:

1 Like

Congrats @Mohamed_Tamer

I didn’t understand? Please elaborate so I can learn.

Thanks :slightly_smiling_face:

See here.:

I believe that my program does that
str input is excluded