Пример #1
0
 def puts(self, r):
     stdout = sys.stdout.write
     type_ = type(r)
     if type_ == list:
         [puts(i, stream=stdout) for i in r]
     elif type_ == dict:
         for key in r:
             puts(min_width(colored.blue(key), 25) + r[key])
     else:
         puts(str(r), stream=stdout)
Пример #2
0
    def print_column(text, size):
        """
        Displays text in the column with a specified width

        :param text: message string
        :type text: str
        :param size: width of the column
        :type size: int
        :return:
        """
        puts(min_width(text, size), newline=False)
Пример #3
0
#   Number of "Fit"'s is the answer.
#

from clint.textui import progress, colored, min_width
import sys

magic = []

def square_add(num, list):
    num = str(num)
    digits = {}
    for i, digit in enumerate(num):
        digits[i] = digit

    sum = 0
    for x in digits:
        sum += int(digits[x]) * int(digits[x])

    list.append(str(sum))
    return list

for i in progress.bar(range(1, 10000000, 1)):
    nums = []
    nums.append(str(i))
    while nums[-1] != '89' and nums[-1] != '1':
        square_add(nums[-1], nums)
    if nums[-1] == '89':
        magic.append(nums[0])
    nums = []
    sys.stderr.write(min_width('Fit [%s] ' % str(len(magic)), len('Fit [%s] ' % str(10000000))))
Пример #4
0
 def format_line(command, w):
     return "%s%s" % (min_width(command.name, w),
         command.description)
Пример #5
0
 def format_line(command, w):
     return "%s%s" % (min_width(command.name, w),
         command.description)