It is currently Sun Dec 22, 2024 8:32 pm

Here's what HG told me...

For game and non-game related chatter, links, and other goodies, go here.

Here's what HG told me...

Postby Zancarius » Thu Apr 17, 2008 5:23 pm

I made the mistake of stating that he was insulting my mum in binary. Looks like I was wrong. How'd I know?

Code: Select all
#!/usr/bin/env python

# String, split into octets and left-padded with zeros.
str = "00101010 10001001 00100001 11100101 00111001"

# Create an array of the input
arr = str.split(' ')

# The processed integers will go in this list
numbers = []

# Each 8 characters (0 or 1) is considered an octet. We're going to loop through each one here.
for octet in arr:

    # Set some temporary variables.
    out = 0
    multiplier = 128

    # Loop through each character in a single octet.
    for num in octet:
        # "out" gets turned into the number times multiplier. The multiplier changes depending on the position in the string.
        out += int(num) * multiplier

        # Divide multiplier by 2 using bitwise arithmetic. Using multiplier = multiplier / 2 achieves the same effect.
        # This works because shifting each bit right by 1 effectively divides by two.
        multiplier = multiplier >> 1
    numbers.append(out)

# Print it!
for number in numbers:
    print chr(number),


To run this, you'd need Python. Just paste it into a new text file and run it with the interpreter (won't get into that here, but if you installed the Windows version, a double-click should work).
I gave that lich a phylactery shard. Liches love phylactery shards.
User avatar
Zancarius
Site Admin
 
Posts: 3907
Joined: Wed Jul 05, 2006 3:06 pm
Location: New Mexico
Gender: Male

Postby Snobal » Thu Apr 17, 2008 5:42 pm

Thal... I love you and you're programming awesomeness


Me trying to program:

Image


By the way...


Code: Select all
0101100101101111011101010111001000100000011011010111010101101101
Image
Image
User avatar
Snobal
Officer
 
Posts: 1171
Joined: Wed Jul 05, 2006 7:48 pm
Location: This hell hole, Georgia
Gender: Not specified


Return to General Chat

Who is online

Users browsing this forum: No registered users and 10 guests