Code Golf! Password Generator

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

35 Replies - 6649 Views - Last Post: 30 June 2015 - 08:35 AM

#16 daniil  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-June 15

Re: Code Golf! Password Generator

Posted 10 June 2015 - 07:14 AM

Spoiler

Was This Post Helpful? 0
  • +
  • -

#17 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Code Golf! Password Generator

Posted 10 June 2015 - 07:45 AM

rgfirefly24

View Postrgfirefly24, on 09 June 2015 - 09:29 PM, said:

I decided to go with a linq approach. If I come up with a better solution, am I allowed multiple submissions?

Spoiler


Hi, your code didn't satisfy all requirements. Here's the message from my unit test:

Quote

Assert.IsTrue failed. Does not include a digit Character


I believe that the issue is that you're not guaranteeing that you include at least one character from each class.



RoyTheReaper

View PostRoyTheReaper, on 09 June 2015 - 10:40 PM, said:

Crap...can I edit it? The .Substring was needed for a previous iteration of my generator.
This is my edited (if allowed) version.

Spoiler


Hi, your code also does not satisfy all requirements. Here's the message from the unit test:

Quote

Assert.IsTrue failed. Includes a non-specified character.


This means that you've included a character not from one of the four classes. I believe when I checked it was a ` (backtick) character.

Please submit again!



bitspill

View Postbitspill, on 10 June 2015 - 03:44 AM, said:

In the case you feel the other may be stretching the rules this version should comply entirely.

Spoiler


Hi, this also did not pass validation. The error I got was:

Quote

Assert.IsTrue failed. Does not include a digit Character


But re-running it gives different errors. I believe the problem is not making sure you include at least one character from each class.



baavgai

View Postbaavgai, on 10 June 2015 - 07:53 AM, said:

I look forward to reviewing the others now. Nothing fancy here.

Fore:
Spoiler


This passes all unit tests!

Your score is:
277



daniil

View Postdaniil, on 10 June 2015 - 09:14 AM, said:

Spoiler


Hi,

Your code doesn't compile as shown. I've added parens around the char keyword (for the cast) and capitalized r.Next (methods are case sensitive). With those changes, it fails unit tests with the following message:

Quote

Assert.IsTrue failed. Includes a non-specified character.


Thanks, feel free to submit again!




Just as a heads up, I've included my unit test in the first reply. If you'd like, you can validate your own code with that to be sure it will pass. I will still check it for anyone though, don't worry if you feel like submitting unvalidated code.
Was This Post Helpful? 1
  • +
  • -

#18 bitspill  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 5
  • Joined: 09-June 15

Re: Code Golf! Password Generator

Posted 10 June 2015 - 08:12 AM

Since it was said we shouldn't worry about security of the password the following should fix my previous errors

Spoiler

Was This Post Helpful? 0
  • +
  • -

#19 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Code Golf! Password Generator

Posted 10 June 2015 - 08:27 AM

View Postbitspill, on 10 June 2015 - 10:12 AM, said:

Since it was said we shouldn't worry about security of the password the following should fix my previous errors

Spoiler


Clever workaround. That very much would not pass a security review, but I specifically mentioned not to worry about repeated patterns other than spitting out the same password over and over again. That's what this whole thing is about. Find the smallest algorithm that will satisfy the requirements.

Your score:
404
Was This Post Helpful? 1
  • +
  • -

#20 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Code Golf! Password Generator

Posted 10 June 2015 - 09:11 AM

Just for fun, I re-implemented my original logic in F#:

Spoiler


Not really score-able, since it doesn't conform to the template. But when I strip whitespace, it's 191 characters. That's less than the current leader, and that's without subtracting the "template score".
Was This Post Helpful? 0
  • +
  • -

#21 bitspill  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 5
  • Joined: 09-June 15

Re: Code Golf! Password Generator

Posted 10 June 2015 - 09:20 AM

Untested but should work in theory...

Spoiler

Was This Post Helpful? 0
  • +
  • -

#22 RoyTheReaper  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 09-June 15

Re: Code Golf! Password Generator

Posted 10 June 2015 - 10:05 AM

Yup, I forgot to block the back tick...

Spoiler

Was This Post Helpful? 0
  • +
  • -

#23 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13485
  • View blog
  • Posts: 53,857
  • Joined: 12-June 08

Re: Code Golf! Password Generator

Posted 10 June 2015 - 10:08 AM

Those darn back ticks. Getcha every time.

Spoiler

Was This Post Helpful? 0
  • +
  • -

#24 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Code Golf! Password Generator

Posted 10 June 2015 - 10:16 AM

My unit test is saying that the output is too long on that one. In fact, when I run it I get strings varying between 16 and 18 characters long.
Was This Post Helpful? 0
  • +
  • -

#25 RoyTheReaper  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 09-June 15

Re: Code Golf! Password Generator

Posted 10 June 2015 - 11:13 AM

View PostCurtis Rutland, on 10 June 2015 - 10:16 AM, said:

My unit test is saying that the output is too long on that one. In fact, when I run it I get strings varying between 16 and 18 characters long.


For me or bitspill? I finally actually compiled and tested mine and always got 16 characters.
Was This Post Helpful? 0
  • +
  • -

#26 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13485
  • View blog
  • Posts: 53,857
  • Joined: 12-June 08

Re: Code Golf! Password Generator

Posted 10 June 2015 - 11:19 AM

@roy - bitspill's is not generating correct lengths.
Was This Post Helpful? 0
  • +
  • -

#27 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Code Golf! Password Generator

Posted 10 June 2015 - 11:40 AM

View PostRoyTheReaper, on 10 June 2015 - 12:05 PM, said:

Yup, I forgot to block the back tick...

Spoiler


It passes now. Your score is:

210
Was This Post Helpful? 0
  • +
  • -

#28 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 5073
  • View blog
  • Posts: 13,697
  • Joined: 18-April 07

Re: Code Golf! Password Generator

Posted 10 June 2015 - 02:20 PM

I was never a big fan of code golf. I always feel it teaches the wrong principles by making things cryptic to save space. But whatever, I thought this was an interesting challenge so my submission below. And yes it bends the rules really hard.

Spoiler


Probably will think of a way of cutting it down further after I post this, but oh well. :)
Was This Post Helpful? 0
  • +
  • -

#29 bitspill  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 5
  • Joined: 09-June 15

Re: Code Golf! Password Generator

Posted 11 June 2015 - 12:09 AM

It seems the cast was misplaced and some parenthesis were required.

Spoiler

Was This Post Helpful? 0
  • +
  • -

#30 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5101
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Code Golf! Password Generator

Posted 11 June 2015 - 07:34 AM

View PostMartyr2, on 10 June 2015 - 04:20 PM, said:

I was never a big fan of code golf. I always feel it teaches the wrong principles by making things cryptic to save space. But whatever, I thought this was an interesting challenge so my submission below. And yes it bends the rules really hard.

Spoiler


Probably will think of a way of cutting it down further after I post this, but oh well. :)/>


Score:
182

And I agree with you; this doesn't really teach good habits in general. But as I mentioned earlier, it's very easily scored in a qualitative way. Plus, I needed to quickly come up with a challenge and Code Golf is the best I could do :P

Great submission, thanks for participating.

View Postbitspill, on 11 June 2015 - 02:09 AM, said:

It seems the cast was misplaced and some parenthesis were required.

Spoiler


Fails with: "Assert.IsTrue failed. Includes a non-specified character."
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3