I get bored all the time and always want to find something to code. Unfortunately, I am too easy to lose focus for things are not tiny. If something requires more than 100 lines and I don’t plan to use it, then it’s too big for me.

So, I decided to start a series which features a tiny problem in each post and most likely requires only a few lines of code. It may be a practical thing, a real problem I encounter, or just for fun. The problem may also be something you have seen before, but you just think it’s too simple to even bother solving it. Now it’s time to really do it.

The first CodeSth: Blank Grid Table

If you have questions or ideas about the series, feel free to ask or to suggest the idea. I may post new CodeSth with your idea.

1   Purposes

  • For killing time.
  • For reading people’s code.
  • For a chance to learn other ways of coding or to utilize in ways you have never thought of.
  • For re-invent the wheel. Many needs may be fulfilled by the standard library or other libraries. But have you ever written on your own? Why not try it by yourself?

2   Rules

  • There is no actual rules since this is not for competition.

  • There is no limit on what language you could use as long as it’s real.

  • There is no real correct answer, no 100% way to solve the problem.

    • You may use the standard library in the language.
    • You may not use the standard library, re-invent the wheel is totally okay.
  • However, you should provide a code which people can copy-and-paste, then the example output will be printed out, without adding addition code. For example, as test input 3 5 is supplied and your code should:


    def the_func(a, b):

    pass # do something

    the_func(3, 5)

    The last line, invoking the function with test input, will print out the output. So others don’t have to type that to see if your code actually can at least output the example output with test input.

    Please must include every header files or module is needed. That’s no fun on filling in the missing parts.

  • Code comment isn’t necessary, but it would be better with comments when the code is not easy to understand.

  • Every submission should be in its own comment, and comment to a submission should be replied to the submission’s comment.

  • You can add as many as you like even for same language. That being said, if using different approaches, then they should be in their own comments.

  • If the code isn’t written by you, you need to specify and you must have the permission to post the code.

3   Maintain the submission

  • The first line should be <b>Language</b>, e.g. <b>Python</b>. If it requires more, such as specific OS or library, they should be appended, so people can skim over and see the differences quickly.
  • Since comment is in HTML, you need to perform HTML escape on your source code, and wrapped with <pre><code>, so syntax highlighting would work. There are some tool online, if you can’t hand escaped your code.
  • Maintain a changelog when you edit your submission and adopt people’s suggestions.

Related Disqus documentations:

4   Voting

You may use voting to show what you like or dislike.