Powershell
Powershell
Onwards, to Project Euler problem #3. The problem is defined as below: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? So, basically, we need to find out which factors make up a certain number. The easiest way to do this is simply by trial division. A very naïve implementation would be something like this: function Get-PrimeFactors ([long]$number)
{
while ($number -gt 1)
{
for($i...
The first few Project Euler problems are actually pretty trivial to brute force, but sometimes they have a smart solution. All in all, coming up with a semi-smart title for the post is usually harder than the problem itself. But I don’t want to leave anything out, so I’ll just continue on with problem #2: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ......
I am not at all sure how far I will get with this, but I am going to try. So far I have solved the first 7 problems from Project Euler, using PowerShell. I will, whenever I solve a problem, take my time to write about my solution and what I’ve learned about math and PowerShell. It should be a good read for anyone not particularly a wizard at math, because I don’t have a math major either. Everything I write here should be in reasonably understandable terms, because I need to understand it too! Either way, let’s start...
Here’s a scenario: you are writing install scripts which configure your IIS instance, or a deployment script that deploys an application which depends on a certain .NET version. Ideally, you’d want to detect the absence of your required framework and have an option to install said framework. Here’s a start on how to get this done using PowerShell. First off, we need to find out how to detect which frameworks are installed. Luckily, StackOverflow came to the rescue. THIS question, and in particular the first answer, details on how to detect which frameworks are installed, by querying the registry....
When I have to use SVN for version control (I am more of a Git fanboy nowadays), I use my tags to identify releases. And if we take a look at the Subversion red bookI’m not the only one: Another common version control concept is a tag. A tag is just a “snapshot” of a project in time. In Subversion, this idea already seems to be everywhere. Each repository revision is exactly that—a snapshot of the filesystem after each commit. However, people often want to give more human-friendly names to tags, such as...