Trying to figure out a version that dosn't use a list or map to remember what's been, I've created this mess in python, that is limited to a maximum count of 999:
defnomorethancount(arr,count):ifcount<1:return[]ifcount>len(arr):returnarrifcount>=1000:raiseValueError('count must be less than 1000')bigposnum=0bignegnum=0result=[]foriteminarr:ifitem<0:absitem=-1*itembignegnum=checkitem(absitem,item,bignegnum,count,result)else:bigposnum=checkitem(item,item,bigposnum,count,result)returnresultdefcheckitem(absitem,item,bignum,count,result):if1000**absitem>bignum:bignum+=1000**absitemresult.append(item)else:currentcount=(bignum//1000**absitem)%1000ifcurrentcount<count:result.append(item)bignum+=1000**absitemreturnbignum
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Trying to figure out a version that dosn't use a list or map to remember what's been, I've created this mess in python, that is limited to a maximum count of 999: