Tag Archives: example

Find happy numbers in C#

Before I show you the code, let me explain what happy numbers are. Happy Numbers To find happy numbers, start with any integer. Replace it with the sum of the squares off its digits. Repeat the process until the numbers … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , | Leave a comment

Draw words on a circle in WPF and C#

This example shows one way that you can draw words on a circle in WPF. Note that it does not show how to draw words where each character is rotated to follow the circle’s curve. Each word is rotated as … Continue reading

Posted in algorithms, graphics, mathematics | Tagged , , , , , , , , , | Leave a comment

Draw a hyperbolic spiral in C#

A hyperbolic spiral, which is also called an reciprocal spiral, is the inverse of an Archimedes spiral. It uses the equation r = A / θ to generate points on a spiral. This spiral has a couple of interesting properties. … Continue reading

Posted in algorithms, graphics, mathematics | Tagged , , , , , , , , , | Leave a comment

Draw a logarithmic spiral in C#

The post Draw an Archimedes spiral in C# uses the equation r = A˙θ to generate the points on a spiral. This example is almost exactly the same except it uses the equation to r = A˙eB˙θ to generate its … Continue reading

Posted in algorithms, graphics, mathematics | Tagged , , , , , , , , , | Leave a comment

Draw a filled spiral in C#

My post Draw an Archimedes spiral in C# explained how to draw multiple Archimedes spirals starting at a common center point. This post shows how you can fill the spaces between the spirals with colors. The basic idea is to … Continue reading

Posted in algorithms, graphics, mathematics | Tagged , , , , , , , , , , | 2 Comments

New Book: The Modern C# Challenge

My latest book, The Modern C# Challenge, is now available. It’s a collection of 100 programming challenges that let you test your ability in a wide variety of programming topics, many of which are not usually covered in traditional programming … Continue reading

Posted in algorithms, books, files, mathematics, puzzles | Tagged , , , , , , , , , , , , , , , , , , , , , , , | 1 Comment

Draw an Archimedes spiral in C#

An archimedes spiral is defined by the polar coordinate equation r = A * θ. It’s just as simple as that, and this would be a significantly shorter post except for one question: how do you know how big you … Continue reading

Posted in algorithms, graphics, mathematics | Tagged , , , , , , , , , | 2 Comments

Make a custom component in C#

There are a couple of ways that you can approach this problem. In this post, I’ll describe two: subclassing from Component and making a control that is invisible at runtime. Subclassing From Component To make a true component, simply make … Continue reading

Posted in controls | Tagged , , , , , , , | 1 Comment

Tile a board with colored trominoes in C#

The post Tile a board with trominoes in C# explains how to tile a board with a missing square with trominoes. This post shows how to color the trominoes so no two adjacent ones share the same color. The four-color … Continue reading

Posted in algorithms, drawing, graphics, mathematics, recursion | Tagged , , , , , , , , , , , , , , , , , , | 1 Comment

Tile a board with trominoes in C#

Trominoes are polyominoes of order three. That means they are polygons made up of three equal sized squares joined at their edges. There only are two kinds of trominoes: three squares joined in a line and three squares joined in … Continue reading

Posted in algorithms, drawing, graphics, mathematics, recursion | Tagged , , , , , , , , , , , , , , , , , | 1 Comment