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.
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.
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.
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?
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.