Python Data Types

Python Data Types

Hi there and welcome back. Working late tonight and I’m a quarter through, my coffee that is. Consulting work on the other hand, I’ve got a ways to go. In an earlier post I said I was going to be in “Ruby Land”, well there was an exotic land nearby and I just couldn’t resist – it’s called “Python Land”. “Ruby Land” was a bit more playful, it had jesters, castles, shiny gems and cute (yeah I said cute) little monsters of all sorts. But here in “Python Land” are a bunch of majestic data crunching machines, engineered meticulously for their purpose – perhaps to understand mankind.

Anyway I’ve decided to take on Python along with Ruby because I have this super weird tendency to contrast things, but what I really want to say is that I want to connect them, conceptually. If I had it my way I’d want to connect everything but that wouldn’t leave any room for curiousity and self discovery now would it. Alright moving onto Python…

Continue reading “Python Data Types”

Move Last Node to Front of Linear Linked List

Python - Move Last Node to Front of Linear Linked List

What’s up everyone?!  I hope everyone’s been doing well as always. Today I am going to work on another linear linked list problem.

The prompt is: Write a function to move the last node to the front of a linear linked list. You could do this iteratively or recursively, I’m just going to go with iteratively for this one.

    # move last to front
    def moveLastToFront(self):

        current = self.head
        previous = None
        temp = None

        # empty or single node
        if not current or not current.next:
            return

        # traverse the list
        while current is not None and current.next is not None:
            temp = current
            previous = current
            current = current.next

        previous.next = None

        # you could write your own push function here
        self.addBeginning(temp.data)

Of course there are much more efficient ways of writing this. I would say the trick is how to keep track of the last node and the node before last, that way you do not lose the data that you’re trying to move. If you have questions, feel free to post in the comments below!

Ruby Built-In Data Types

Ruby Built-In Data Types

Hello and welcome back to Project Immerse LLC – your #1 leading source for epic knowledge. That sounded epic for epic’s sake by the way. Alright, let’s get right to it.

I was thinking of creating a completely separate post for this, but I figured this would be a monumental moment to celebrate my transition into “Ruby Land”. Now, I’m not leaving “PHP Land” nor will I ever, it’s just I’ve spent a lot of time there. PHP is an amazing language, it’s been through some rough stuff over the years but PHP 7 shows us just how resilient PHP really is. I also have a handful of pet projects written in PHP so activity won’t cease there.

I was first introduced to Ruby by a junior developer, an intern, a mathematician. Can’t mention this persons’s name, but if you’re reading this – thank you for handing me that Ruby book. I wish I hadn’t tossed it, but I did because I knew I’d have it all in memory. I think you would appreciate that nerdy pun.

Continue reading “Ruby Built-In Data Types”