8 votes

Topic deleted by author

3 comments

  1. Rocket_Man
    Link
    I wanted to try this out in C# and thought I was clever until I got to the end and my string implementation was disallowed. Oh well, it's an interesting little puzzle. But I think another lesson...

    I wanted to try this out in C# and thought I was clever until I got to the end and my string implementation was disallowed. Oh well, it's an interesting little puzzle. But I think another lesson is to actually look at what you're working with. I'm just now familiarizing myself with C# and didn't realize all objects have a toString method.

    My first step in addressing the problem was to actually look at the bulit in integer type documentation. For all I know it would have a count method. That's where I found ToString and came up with a simple solution.

    5 votes
  2. [2]
    cstby
    Link
    What makes this your favorite problem? In practice, wouldn't one coerce the integer to a string and then return the length of the string?

    What makes this your favorite problem? In practice, wouldn't one coerce the integer to a string and then return the length of the string?

    2 votes
    1. [2]
      Comment deleted by author
      Link Parent
      1. cstby
        Link Parent
        Yes, the students haven't learned about strings yet, so solutions involving strings are disallowed. I understand that putting constraints around a problem can make it more interesting to solve. In...

        Yes, the students haven't learned about strings yet, so solutions involving strings are disallowed.

        I understand that putting constraints around a problem can make it more interesting to solve. In this case, I'm wondering if anyone else feels it's a little contrived.

        2 votes