The C language is weak when it comes to strings. Even the paltry assortment of string.h manipulation functions lacks quite a few tricks that are readily available to other languages. Among them is a function to reverse a string. So why not code your own?
Continue reading
Author Archives: dgookin
Vertical Table Output
Generating a table where the items march left-to-right and then down the page is uncomplicated with stream output. What’s more difficult is outputting a table where the data drops in columns top-down before going left-to-right. Performing this feat requires no screen/cursor manipulation, only clever coding.
Continue reading
Generating a Table from Stream Output
This month’s Exercise searched for and output the first 100 cyclops numbers. But instead of spewing them out in a long column, my solution set them in a table. The values marched across the screen in neat rows. This trick is rather easy to accomplish, but in my solution I wanted some flexibility with the column number.
Continue reading
Cyclops Numbers – Solution
I hope this month’s Exercise didn’t terrify you. I remember seeing The Seventh Voyage of Sinbad when I was a kid. The cyclops bothered me so much I asked my mom questions about him for a month.
Continue reading
Integer Size Values – Again
In a post from 2020, I wrote about various integer size values. Seems they don’t consistently sport the same bit width. Just recently, I’ve obtained some updated information and valuable insight into the bit width question.
Continue reading
Cyclops Numbers
Difficulty: ★ ★ ★ ☆
Oh, leave it to the propeller heads to devise a clever and fun name for something the rest of us never pay attention to. This time it’s a cyclops number, which is any decimal integer value with an odd number of digits and a big fat zero in the middle — like a cyclops’ eye.
Continue reading
Help Me Figure Out This Trick
Occasionally the Wizards of C concoct a mad method to perform some magical feat on a number. This sorcery cannot be explained using those scant, basic math concepts known to me. So perhaps you’d like to invest a few moments to review what I consider to be one of the most insane ways to discover the maximum power of two that can divide any integer.
Continue reading
Counting the Digits
I am not a math genius, as any math genius who reviews my work is happy to tell me. Even so, when programming I’m often faced with math challenges where a math education would benefit. My most recent puzzle is how to count the number of digits in a value without first converting the value into a string.
Continue reading
Converting Month Strings to Integers
I saw this problem on stackoverflow: How can you take a month string and convert it into an integer value, one through 12? The student submitting the query used a long if-else if-else construction. I have a better idea.
Continue reading
From ‘A’ and ‘a’ to ‘Z’ and ‘z’ – Solution
I don’t believe one definitive solution exists for this month’s Exercise: Output a string of upper- and lowercase letters. No, the challenge is more to discover different insights a coder has to a specific problem.
Continue reading