mazha's profileA New AgePhotosBlogListsMore Tools Help

Blog


    2/13/2006

    [PC_10] what are you looking at?

    一进去就看到上关画出来那头牛的真面目了,满帅的哈哈~~
    然后一个问题: len(a[30])=? 源文件什么提示都没有~
    点一下牛图片有个txt文件: a = [1, 11, 21, 1211, 111221,  是道数列题。
    我现在当然知道是怎么做,可当时和 RhythmBox 刚开始做这题的时候为了找 a 的规律冥思苦想了好几天呢~
    后来公务员考试期间拿这道题考 glitter 和 tomcat ,得知这个竟是 google 的一道面试题,~>.<~ 看来牟希望去 google 了么~~~
     
    呵呵,还有,当时寝室都在准备考研,为了不把精力浪费在 PythonChallenge 上,寝室里一度发誓不写python的,不过最后到底抵挡不住 python challenge 的诱惑,于是我用 c 写了程序过了这关~
     
    那好吧,现在把 python 的代码补上~~ :)

    [code]

     
     a = ['1']
     ss = ''
     
     for k in range( 31 ):
         s = a[-1] + '$'
         c = s[0]
         count = 0
         for j in range( len(s) ):
             if s[j] == c :
                 count += 1
             else :
                 ss = ss + str( count ) + c
                 c = s[j]
                 count = 1
         a.append( ss )
         ss = ''
     
     print len(a[30])
     

     
    结果:5808

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://bg5hfc.spaces.live.com/blog/cns!E67CCF4FFB0BE86!1146.trak
    Weblogs that reference this entry
    • None