def summaryRanges(self, nums):
        ret = []
        n = len(nums)
        if n < 1:
            return ret

        bgn = nums[0]
        pre = nums[0]
        for i in xrange(1, n):
            if nums[i] != pre+1:
                if pre != bgn:
                    ret.append("%d->%d"%(bgn, pre))
                else:
                    ret.append("%d"%bgn)
                bgn = nums[i]

            pre = nums[i]

        # clean up
        if pre != bgn:
            ret.append("%d->%d"%(bgn, pre))
        else:
            ret.append("%d"%bgn)

        return ret
Turn the power on or off.
dataset/ETHPy150Open algorhythms/LeetCode/228 Summary Ranges.py/Solution.summaryRanges--crossover with--dataset/ETHPy150Open openstack/ironic/ironic/drivers/modules/seamicro.py/Power.set_power_state