Star Tours

Star Tours, an attraction at Disneyland, was recently revamped and updated with new technology after being a popular attraction for decades. The new ride, set during the time between the new and old trilogies, is now 3D, and has a segmented story that is randomly selected each time resulting in a slightly different experience.

There 5 elements that are randomly selected and put together:

  • The opening sequence has 2 variations
  • The first planet that is visited has 3 variations
  • The rebel alliance messenger scene has 3 variations
  • And the final destination has 3 variations.

This creates a total of 54 combinations for this attraction.

Naturally, to maximize the enjoyment of the experience, I created a check-list with all possible combinations to keep track of my progress each time I go to Disneyland.

Hopefully I can experience all combinations before my Disneyland pass expires, however I find this highly dubious since I visit far less frequently than once a week…

Shipping Containers

Shipping-Container-Width

The other day I was stuck in some traffic while out on a trip with my brother and dad. The freeway was moving at about 5 MPH due to an accident, and we were behind a semi-truck towing a shipping container. Naturally, with nothing better to do, we looked up shipping container information online to find out how much they cost, size, weight, etc. and ran across the ISO 6346 specification for the serial numbers found on shipping containers.

The serial number found on shipping containers follow a strict format. The first 3 characters are the owner code, and are only letters. The 4th digit is the category identifier, which at this moment the only category is “U” for freight container. The remaining 6 characters are the serial number which will only be comprised of digits. After the 10 character serial number, there is a check digit, usually shown as a number in a box to the right.

Containernumber

The check digit is calculated by taking each character of the serial number, and assigning a value to the character and multiplying that value by 2 to the power of its location. Digits retain their face value, 0-9, while letters are given an incrementing value starting at 10, with the exception of multiples of 11 which are skipped (a=10, b=12, c=13, d=14… z=38). All of these values are then added together, divided by 11, truncated to an integer, multiplied by 11, and then subtracted from the original total. This is basically a fancy way of saying take the modulus 11 of the total.

We passed the remainder of our time in the traffic by verifying by hand that all the shipping container check numbers were calculated correctly. When I got home, I wrote this Python program to calculate it for me the next time I may ever need to generate or check a shipping container check digit. It asks for input, then uses a regular expression to validate the format. It then calculates and returns the check digit.

#!/usr/bin/python
import re
 
ShippingNumber = raw_input("Enter Container Code (eg. PSSU210948): ")
 
if not re.compile('\D{4}\d{6}').match(ShippingNumber):
    print "Invalid, please ensure code follows ISO 6346 specifications."
    quit()
 
Total=0
for i in range(len(ShippingNumber)):
    Value=ShippingNumber[i]
    if not Value.isdigit():
        Value=ord(Value.lower())-ord('a')+10
        Value+=Value/11
Total+=int(Value)*2**i
 
print "Check Digit:", str(Total%11%10)

© 2007-2015 Michael Caldwell