zoukankan      html  css  js  c++  java
  • 【leetcode❤python】 299. Bulls and Cows

    #-*- coding: UTF-8 -*-
    class Solution(object):  
        def getHint(self, secret, guess):  
            """
            :type secret: str
            :type guess: str
            :rtype: str
            """  
            countA,i,numList=0,-1,[[0,0] for j in range(10)]  
            print numList
            while 1:  
                i+=1  
                try:  
                    if secret[i]==guess[i]:countA+=1  
                    else:  
                        numList[int(secret[i])][0]+=1  
                        numList[int(guess[i])][1]+=1  
                except:  
                    break
            
            return "%sA%sB"%(countA,sum(min(i,v) for i,v in numList))

  • 相关阅读:
    IfcFeatureElementAddition
    IfcOpeningElement
    IfcRelNests
    IfcElementAssemblyType
    IfcProjectionElement
    IfcFeatureElement
    IfcRelDefines
    Win10 Anaconda配置tensorflow
    Anaconda升级
    Anaconda 台式机环境
  • 原文地址:https://www.cnblogs.com/kwangeline/p/6059520.html
Copyright © 2011-2022 走看看