FAQ
Hi,

Thanks everyone who answered my question.

I've now formally define the problem as:

*The words reverse problem*

Given a string say "I am a human being" the output will reverse words but
nothing else, i.e., it should reverse all
alphanumeric<http://www.cplusplus.com/reference/cctype/isalnum/>
within
each word but otherwise preserve everything. Eg: output should be "I ma a
namuh gnieb".

NB,

- No build-in string reverse function or any form of loop statement except
the
single one that iterates through the given string in a single pass should be
used. I.e., the program should finishes in O(N) time instead of O(2N) time.

- Pay attention to what the "reverse words but nothing else" requirement
implies. Design more test data to proof that the requirement is not
violated.

I’ve post my own answer at
http://sfxpt.wordpress.com/2014/04/26/the-words-reverse-problem/, including
my own test cases and answers.

BTW, rambling off topic,

It falls within the criteria of the problems that I’m looking for

    - *Interesting*. Balance tree might interest some people but not most of
    them.
    - *Easy definition*. This one and my last
post<http://sfxpt.wordpress.com/2014/04/12/data-structures-algorithms-programs/>,
    they are almost self-explanatory.
    - *Self-sufficient*. No need to depend on external data to function.
    - *Simple*. Easy to understand what to do, and not too long to finish it.
    - *Revealing*. Though simple enough, yet it is also hard enough to
    reveal how good the candidate is of his/her programming skills.

If you know such interesting problems, please share.

Thanks

On Thu, Apr 24, 2014 at 6:05 PM, Tong Sun wrote:

I was trying to learn go with *the word **reverse *problem BTW. . .
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Michael Jones at Apr 26, 2014 at 6:33 pm

    On Sat, Apr 26, 2014 at 11:21 AM, Tong Sun wrote:

    the program should finishes in O(N) time instead of O(2N) time.

    If you want to be formal, or have O(n) mean anything sensible, then O(2n)
    is O(n).

    As far as other problems, who is your intended audience? For a set like
    {children, teens, STEM freshman, arts majors, older adults} you might seek
    different types of problem settings such that the context would make sense
    to them.

    I like math problems because they bring understanding. Data movement
    problems are also good, because they teach the notions of "data in memory,
    moving around, order of storage and order of access." Word problems can be
    fun for more introductory cases, say non-technical people. Show them how to
    permute letters and try them against a word list to see what Boggle or
    SCRABBLE words can be made. Another could be "find words that spell out
    your phone number." Such examples often resonate with everyday people more
    than "simulate drawing colored balls from an urn."

    --
    *Michael T. Jones | Chief Technology Advocate | mtj@google.com
    <mtj@google.com> | +1 650-335-5765*

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Tong Sun at Apr 26, 2014 at 7:56 pm

    On Sat, Apr 26, 2014 at 2:33 PM, Michael Jones wrote:

    the program should finishes in O(N) time instead of O(2N) time.


    If you want to be formal, or have O(n) mean anything sensible, then O(2n)
    is O(n).
    I know what you mean. However, if you are pointing out an expression is
    wrong, then please at least say what is correct, because we are talking
    about implementation details here, not only the conceptual science.
    When implementation details is concerned, there is a huge difference
    between finishing in a single loop than in two or hundreds of loops. So how
    you differentiate that please?

    Thanks

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Minux at Apr 26, 2014 at 8:03 pm
    On Sat, Apr 26, 2014 at 3:56 PM, Tong Sun wrote:
    On Sat, Apr 26, 2014 at 2:33 PM, Michael Jones wrote:

    the program should finishes in O(N) time instead of O(2N) time.


    If you want to be formal, or have O(n) mean anything sensible, then O(2n)
    is O(n).
    I know what you mean. However, if you are pointing out an expression is
    wrong, then please at least say what is correct, because we are talking
    about implementation details here, not only the conceptual science.
    When implementation details is concerned, there is a huge difference
    between finishing in a single loop than in two or hundreds of loops. So how
    you differentiate that please?
    the big-O notation is for describing asymptotic growth rate of some
    resource (time, space, etc)
    versus the size of input, so O(2n) = O(n).

    If you want to explicitly talk about constant factors, don't use that
    notation.
    you can say, for example, this loop needs 2n iterations for input of size
    of n, etc.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Tom Payne at Apr 26, 2014 at 6:34 pm
    These sorts of problems are really fun to solve and are often used as
    programming interview questions. Googling for "programming interview
    questions" will give you hundreds of similar problems. Personally, I've
    found
       http://oj.leetcode.com/
    to be a good source of fun problems, but there are many others.

    On 26 April 2014 20:21, Tong Sun wrote:

    Hi,

    Thanks everyone who answered my question.

    I've now formally define the problem as:

    *The words reverse problem*

    Given a string say "I am a human being" the output will reverse words but
    nothing else, i.e., it should reverse all alphanumeric<http://www.cplusplus.com/reference/cctype/isalnum/> within
    each word but otherwise preserve everything. Eg: output should be "I ma a
    namuh gnieb".

    NB,

    - No build-in string reverse function or any form of loop statement except
    the
    single one that iterates through the given string in a single pass should
    be
    used. I.e., the program should finishes in O(N) time instead of O(2N) time.

    - Pay attention to what the "reverse words but nothing else" requirement
    implies. Design more test data to proof that the requirement is not
    violated.

    I’ve post my own answer at
    http://sfxpt.wordpress.com/2014/04/26/the-words-reverse-problem/,
    including my own test cases and answers.

    BTW, rambling off topic,

    It falls within the criteria of the problems that I’m looking for

    - *Interesting*. Balance tree might interest some people but not most
    of them.
    - *Easy definition*. This one and my last post<http://sfxpt.wordpress.com/2014/04/12/data-structures-algorithms-programs/>,
    they are almost self-explanatory.
    - *Self-sufficient*. No need to depend on external data to function.
    - *Simple*. Easy to understand what to do, and not too long to finish
    it.
    - *Revealing*. Though simple enough, yet it is also hard enough to
    reveal how good the candidate is of his/her programming skills.

    If you know such interesting problems, please share.

    Thanks

    On Thu, Apr 24, 2014 at 6:05 PM, Tong Sun wrote:

    I was trying to learn go with *the word **reverse *problem BTW. . .

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Nicolas Riesch at Apr 26, 2014 at 9:17 pm
    Some remarks about your program:

    1) Your reverseIt() function is recursive and calls itself.
        Iteration is better in this case.

    2) Besides, you create temporary string with string(rs[start]), which
    becomes work for the garbage collector.
        Working with byte slice buffers as much as possible when doing string
    transformation avoids creating temporary strings.


    This is my version:
    http://play.golang.org/p/a_EfvtoqYA

    If you ask me, I have been learning Go for 5 months, and it took me 3 hours
    to write this little program.
    It always takes time to devise the simplest solution.
    But it was a good exercise for me, and I think the result is quite good ;-)



    Le samedi 26 avril 2014 20:21:43 UTC+2, Tong Sun a écrit :
    Hi,

    Thanks everyone who answered my question.

    I've now formally define the problem as:

    *The words reverse problem*

    Given a string say "I am a human being" the output will reverse words but
    nothing else, i.e., it should reverse all alphanumeric<http://www.cplusplus.com/reference/cctype/isalnum/> within
    each word but otherwise preserve everything. Eg: output should be "I ma a
    namuh gnieb".

    NB,

    - No build-in string reverse function or any form of loop statement except
    the
    single one that iterates through the given string in a single pass should
    be
    used. I.e., the program should finishes in O(N) time instead of O(2N) time.

    - Pay attention to what the "reverse words but nothing else" requirement
    implies. Design more test data to proof that the requirement is not
    violated.

    I’ve post my own answer at
    http://sfxpt.wordpress.com/2014/04/26/the-words-reverse-problem/,
    including my own test cases and answers.

    BTW, rambling off topic,

    It falls within the criteria of the problems that I’m looking for

    - *Interesting*. Balance tree might interest some people but not most
    of them.
    - *Easy definition*. This one and my last post<http://sfxpt.wordpress.com/2014/04/12/data-structures-algorithms-programs/>,
    they are almost self-explanatory.
    - *Self-sufficient*. No need to depend on external data to function.
    - *Simple*. Easy to understand what to do, and not too long to finish
    it.
    - *Revealing*. Though simple enough, yet it is also hard enough to
    reveal how good the candidate is of his/her programming skills.

    If you know such interesting problems, please share.

    Thanks


    On Thu, Apr 24, 2014 at 6:05 PM, Tong Sun <sunto...@gmail.com<javascript:>
    wrote:
    I was trying to learn go with *the word **reverse *problem BTW. . .
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 26, '14 at 6:21p
activeApr 26, '14 at 9:17p
posts6
users5
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase