Tag Archives: featured

The FizzBuzz Question?

To be honest, this is new to me and stumbled across FizzBuzz being an interview question for Software Engineering positions on a medium post by Valeri Alexiev entitled “A Software Engineering survival guide”. Thought I would attempt to tackle it personally, seeing as I’m currently learning Python.

What is FizzBuzz?

Put simply, a kids game. Imran Ghory came up with a class of developer interview questions based on FizzBuzz, a kids game, where you count from 1-100, however on the multiples of three you call out ‘Fizz’, and on the multiples of five you call out ‘Buzz’ and on a number where its a multiple of both three and five you holla ‘FizzBuzz’.

An example of one of the FizzBuzz questions:

Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”. – Imran Ghory

Overthinking

My attempt at answering the FizzBuzz question above, I thought it best to store it in a list but, in reality, I was over thinking it. In my solution, there is way more I need to explain, can be a little confusing with how I chose to reference the index of the list. My attempt is an example of brute forcing some code to get the job done but doesn’t help moving forwards.

output = list(range(1,101))		# This list will be updated and the output at the end

ref = list(range(0,100))			# Used as a reference for the index

for num in ref[2::3]:				# Start after index 2 and count up in 3s
    output[num] = ["Fizz"]

for num in ref[4::5]:				# Start after index 4 and count up in 5s
    if output[num] == ["Fizz"]:
        output[num] = ["FizzBuzz"]
    else:    
        output[num] = ["Buzz"]

output

After feeling like I succeeded by getting the correct output, I decided to try and do the same in PowerShell by attempting to reuse my code but became stuck as there is not an alternative to the Python range() sequence type in PowerShell that would count in multiples.

So, over to google to look for a PowerShell solution. I found a blog post by Devin Leaman. After taking a peek at their code, it dawned on me that I could use the % (remainder) operator.

For a great explanation about how to tackle the FizzBuzz question, this Tom Scott video on YouTube is worth a watch.

Refined

Using this new found information by losing the List sequence type and making use of the remainder operator you get the below which is way more elegant than what I came up with initially and it translates to PowersShell.

Python

for num in range(1,101):
    output = ""
  
    if num % 3 == 0: output += "Fizz"
    if num % 5 == 0: output += "Buzz"
    if output == "": output = num
  
    print(output)

PowerShell

ForEach-Object ($num in 1..100)
{
    $output = ""
  
    if ($num % 3 -eq 0) { $output += "Fizz" }
    if ($num % 5 -eq 0) { $output += "Buzz" }
    if ($output -eq "") { $output = $num }
  
    Write-Output $output
}

Hope you are visiting after attempting the question yourself 😀

Linux P2V CentOS 4/5/6 VMware Converter

Recently I have been working on a project that had quite a few physical Linux servers, mainly of the the CentOS distribution. I have done the odd one here and there in the past but never really documented the process and with me attempting to update my blog more frequently what better place to document it.

First I will give a brief overview of the process then will detail the how-to. This post is for physical to virtual (P2V), I did have to tackle a few virtual to virtual (V2V) that were based on KVM to VMware which I will also document.

Overview

The version of Converter used during this project was 5.5.0 build 1362012 and CentOS versions 4.9, 5.1 and 6.5 x64. The sole use of converter may work on your combination of Converter, ESX and CentOS but in my case I had to create a new initial RAM disk as the converted VM would kernel panic due to disk configuration changes.

  1. Document kernel version
  2. Use VMware Converter to convert machine
  3. Create a new initial RAM disk
  4. Configure Network Connection
  5. Install VMware Tools

Continue reading Linux P2V CentOS 4/5/6 VMware Converter

Avamar MOSS GLR Plugin

I was recently setting up MOSS (Microsoft Office Sharepoint Sever) for GLR (Granular Level Restores) using the Avamar plugin. When I installed the MOSS plugin and selected the GLR component it fails the installation with the following error also shown above.

AvFSCreateProcArg: Command ‘”C:\Program Files\avs\bin\axionfs.exe” /regserver’ failed, exitCode=-2147024891:80070005

This is due to UAC (User Account Control) in Windows 2008 / 2008 R2 which can prevent software from being installed with administrator privileges, unless an administrator authorizes the elevated privileges. So the GLR component fails to install because of inadequate permissions for several custom actions. These custom actions are related to AvFS (Eldos).

==============================

There are 2 workarounds:


1. Turn off UAC.

Do so as follows. Start -> Control Panel. Select User Accounts and User Accounts again. Select Change User Account Control settings. Drag slider to “Never notify”. Reboot. Run the MOSS VSS MSI installer from the Avamar Server, e.g. AvamarMossVSS-windows-x86_64-6.0.1xx-xxx.msi

2. Open command window and run as administrator.

Download the MOSS VSS installer MSI file from the Avamar server, e.g. AvamarMossVSS-windows-x86_64-6.0.1xx-xxx.msi. Start -> Right-click on the Command Prompt icon. Choose Run as Administrator. CD to the directory containing the downloaded MOSS VSS MSI file. Run the MOSS VSS MSI file from the command prompt to perform the installation.

==============================

Full instruction are detailed in the link below, page 12 onwards. For some reason I missed this and suffered the hard way. Whats that saying, RTFM 🙂

EMC Avamar Microsoft SharePoint Client 5.0 User Guide