Last month’s Exercise demonstrated a filename-extractor, but it cheated: The filename was always the same: same text, same length. That’s not always the case in the real world.
Continue reading
Category Archives: Exercise
Right String
A recent web page programming puzzle reminded me of an old BASIC language function, RIGHT$. The “right-string” function returns the rightmost n characters from a string. Such a function would have helped me greatly in my web page programming task.
Continue reading
The URL Decoding Filter
Last month’s Exercise was to write a filter that converts ASCII text into a percent-encoded format. This month, you’re task is to reverse the process: White a filter that converts a percent-encoded string back into the original ASCII.
Continue reading
The URL Encoding Filter
URL encoding is a method of translating ASCII codes (not just text or URLs) into what’s often referred to as percent encoding. You’ve probably seen this format on your web browser’s address bar or in a search engine’s text. The encoding format is necessary to preserve the original content as plain text.
Continue reading
Change Due
Consider the penny. It’s one cent, which was once a worthy sum before the government devalued the currency to the point where trays of pennies linger unwanted on convenience store checkout counters across the land. Why not do away with the penny?
Continue reading
The Perfect Shuffle
A perfect shuffle occurs when you shuffle a deck of cards so that all the cards from the second half of the deck are perfectly interspliced between the cards in the first half of a deck. Such a shuffle is illustrated in Figure 1.
Continue reading
Day-of-the-Year Calculation
Today is May 1st. It’s the 121st day of the year 2017. In 2016, May 1 was the 122nd day of the year, because 2016 was a leap year. You can look up this information on a calendar or, more disappointingly, use Google. You can also write code that does the calculation for you, which is this month’s Exercise.
Continue reading
Calculating the Date of Easter
Of all the annual holidays, Easter is the most difficult date to predict. It’s always a Sunday, but which one? It could land in March or April. Most people look at a calendar or (these days) use Google to find out when Easter occurs. Yet, you can write a program that tells you exactly when Easter falls.
Continue reading
Detailed Examination of a CSV File
The brutal winter continues in my area, with no end in site! I saved weather data collected for 31 days from December to January in a CSV file. This file was used in last month’s Exercise. For this month’s Exercise, your job is to read the same data file, but also to report on the results.
Continue reading
The CSV File
Of all the common file formats, the CSV is probably the oldest one still in use. It’s a plain text file, so the formatted data appears is readable by humans: Each line is a record. Each field is separated by a single comma.
Continue reading