U E D R , A S I H C RSS

UglyNumbers/DamienRice (rev. 1.1)

Ugly Numbers/Damien Rice

def ugly(pos):
    count = 0
    uglys = [2,3,5]
    minVal = 0
    while count != pos-1:
    	uglysCnfrm = {}

        minVal = min(uglys)
        #print 'minVal : ', minVal, uglys
        if uglys.count(minVal*2)==0:
            uglys.append(minVal*2)
        if uglys.count(minVal*3)==0:
            uglys.append(minVal*3)
        if uglys.count(minVal*5)==0:
            uglys.append(minVal*5)

        uglys.remove(minVal)
        uglysCnfrm[minVal] = True
        count += 1

        #print minVal, count, uglys
    print minVal


if __name__=='__main__':
    ugly(1550)
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:19
Processing time 0.0167 sec