r/dailyprogrammer • 2 0 • Oct 09 '15

[Weekly #24] Mini Challenges

So this week, let's do some mini challenges. Too small for an easy but great for a mini challenge. Here is your chance to post some good warm up mini challenges. How it works. Start a new main thread in here.

if you post a challenge, here's a template from /u/lengau for anyone wanting to post challenges (you can copy/paste this text rather than having to get the source):

**[CHALLENGE NAME]** - [CHALLENGE DESCRIPTION]

**Given:** [INPUT DESCRIPTION]

**Output:** [EXPECTED OUTPUT DESCRIPTION]

**Special:** [ANY POSSIBLE SPECIAL INSTRUCTIONS]

**Challenge input:** [SAMPLE INPUT]

If you want to solve a mini challenge you reply in that thread. Simple. Keep checking back all week as people will keep posting challenges and solve the ones you want.

Please check other mini challenges before posting one to avoid duplications within a certain reason.

Many thanks to /u/hutsboR and /u/adrian17 for suggesting a return of these.

81 Upvotes

117 comments sorted by

View all comments

Show parent comment

2

u/adrian17 1 4 Oct 09 '15

Very cool! Two things I would change:

  • find_file doesn't convey what the function does very clearly. Maybe just change to find_in_file?
  • change enumerate(fd.readlines()): to enumerate(fd): - readlines can read the whole file to memory, while simple iteration will avoid that.

1

u/FlammableMarshmallow Oct 09 '15

Well, find_file has some nice docs (IMO).. so they could do help(find_file)..

I knew about enumerate(fd) but I didn't think it would work.