2012年10月28日星期日

TUT-FIVE


This week's quiz was on operations and conditions. I was used to substrings way back when I was programming in JAVA.

The "last-half" function is what stumped me. This function is supposed to show the last half of a word. The problem is the definition of "half." If a word had an odd number of letters, I had to decide if I should round up or round down the number of letters

(ex. "bunny" -> "bun" /  "bu")

It was a relatively easy quiz, although the conditions part of the tutorial was really odd.

For example, a function had to determine if two words were "greater" than each other. At first, I thought it was determined by the number of characters a string had, but I was wrong. It was actually based on alphabetical order. By that logic, "b" is greater than "a."

This also got me thinking that this logic would be useful later for organizing words in alphabetical order.

没有评论:

发表评论