Life hack 001

I was shown this life hack today, so I thought I would share it. A plastic container, like the ones you get inside chocolate eggs that all so contain a surprise... (and something to play with) make handy containers for earphones.  That is all.


Extra geek experience points for anyone who remembers this...

The A-Z of geek: H is for Hobgoblin

Described in the superdecade games dictionary as noun: Mischievous imp, this post is about a game for the BBC microcomputer by David Parsons.

H is for Hobgoblin

In this game you have three lives to recover 'The Golden Orb of Altoris' by marching headlong to the right of the screen, avoiding ghouls and ghosts who can kill with one touch. The gameplay involves a great deal of precisely-time jumps to avoid spike-tipped pits and an endless hail of arrows fired from zombie Robin Hood type characters. You are armed only with a set of infinite throwing knives, a fairly useless suit of plate-armour and a rather tidy ginger beard.

Oh no, a baddy! JUMP! No fire! Quick!

Hobgoblin is a clone of the more-popular Ghouls 'n Ghosts available from Capcom for a variety of platforms.

Success in Hobgoblin demands careful attention to detail - for example not dying - as well as upgrading one's weapons so as to better squish the army of undead that are perpetually waiting somewhere to the right of the screen (as well as occasionally to the left!).

The old 'climb on a rock' trick
Particularly difficult sections involve precise jumping and picking your fights very carefully. One slip and you are inconveniently teleported several screens to the left where you are forced to attempt the difficult section again, only with downgraded weapons (and, of course, your trusty beard).

Video Time:


Complete walkthrough

The A-Z of geek: G is for Game of Life

From simple rules can arise incredible complexity.

There are those who have spent entire careers exploring it. All programmers should be familiar with it. I once spent an entire night coding it on a BBC microcomputer. It is, of course, recreation mathematics time, because....

G is for Game of Life

Conway's Game of Life has been described as a 'zero-player game'. In Game of Life cells exist on a two-dimensional game board who live or die based on four simple rules:
  1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies, as if by over-population.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

The resulting effect is something that resembles life in a petri dish. Some patterns repeat themselves, as though moving across the canvas like spacecraft. Others reach stable or oscillating states, and other configurations complete vanish after a few generations. It is also possible to build logic gates and thus create a Turing Machine using the rules of Game of Life, that is you can actually perform calculations within Game Of Life that could be performed on any other computer.

Game of Life sims you can play right now:

Bitstorm
pmav.eu JavaScript Game of Life
Kongregate
Emergent Universe
Open source Life


Video time:

Mind-blowing Game of Life video


Conway on Conway's Game of Life (Numberphile)

Number converter in Python

Just because I was set this challenge this morning, I have written my first attempt at a number converter in Python 3. You simply pass a positive integer and the program returns that number in words.


For example, if you pass 1234, it will return "one thousand two hundred and thirty-four".

The program works for all positive integers up to ten to the power 48, which should be good enough for most practical purposes.

The code is listed below, or you can download it from OneDrive.


def numberConvert( num ):
    # pass a string containing a positive integer
    # will return the number as a string of words
    # for example 1234 will return
    # "one thousand two hundred and thirty-four"
    number = str(num)
    digitlist = []
    groupedlist = []
   
    for digit in number:
        digitlist.append(digit)
    #puts text into grouped list eg
    #567893 --> ['893', '567']
    while len(digitlist)>0:
        s = ""
        c = 0
        while c<3 and len(digitlist)>0:
            s = s + digitlist.pop()
            c += 1
        groupedlist.append(s[::-1])
    out = ""
    power = 0
    a = ["thousand", "million", "billion", "trillion", "quadrillion", "quintillion", "sextillion", "spetillion", "octillion", "nonillion", "decillion", "undecillion", "duodecillion", "tredecillion", "quattuordecillion", "quidecillion"]
    for item in groupedlist:
        if power >0:
            out = parseNumber(item) + " "+ a[power-1] + " "+out
        else:
            out = parseNumber(item)
        power += 1
    return out
def parseNumber( number ):
    #pass a 3 digit string , eg '456'
    if len(number) == 1:
        return(parseDigit(number))
    elif len(number) == 3:
        if number[0:1] != '0':
            if int(number[1:3]) != 0:
                return(parseDigit(number[0:1])+" hundred and "+parseTwoDigit(number[1:3]))
            else:
                return(parseDigit(number[0:1])+" hundred ")
        else:
            if int(number[1:3]) != 0:
                return("and "+parseTwoDigit(number[1:3]))
            else:
                return(parseTwoDigit(number[1:3]))
    else:
        return(parseTwoDigit(number))
              
def parseDigit( number ):
    #deals with one digit numbers
    a = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
    return a[int(number)]
def parseTwoDigit( number ):
    #deals with two digit numbers
    a = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
    b = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
    if (number[0:1]) == '1':
        return(b[int(number[1:2])])
    elif (number[0:1]) == '0':
        return(parseDigit(number[1:]) )
    else:
        if number[1:] != '0':
            return(a[int(number[0:1])-2]+ "-" +parseDigit(number[1:]) )
        else:
            return(a[int(number[0:1])-2])
#test program
while True:
    num = int(input("Enter integer: "))
    print(numberConvert(num))

Label