Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

smallest string with a given numeric value

def solve(n, k):
   string = ""
   while n > 0:
      letter = min(26, k-n+1)
      string += chr(letter + ord('a') - 1)
      k -= letter
      n -= 1
   return string[::-1]

n = 4
k = 16
print(solve(n, k))
Comment

PREVIOUS NEXT
Code Example
Python :: How to run python in command promt 
Python :: trigger to print on python 
Python :: how to connect smartphone camera to opencv python 
Python :: python ListObjectsV2 over 1000 
Python :: place parameters tkinter 
Python :: matplotlib add abline 
Python :: heapq basic push and pop - default minHeap 
Python :: pandas count vvariables of each dtype 
Python :: Display complete information about the DataFrame 
Python :: get predict proba category order 
Python :: python too many values to unpack 
Python :: how to combine sets using update() Function 
Python :: for loop for multiple things 
Python :: how list ul info with python 
Python :: print hi in python 
Python :: loop through KeyedVectors 
Python :: python backtest 
Python :: pyhton transpose without changing column and row names 
Python :: Lightbank b2c 
Python :: os cd python 
Python :: how to append the items in list 
Python :: python two list into dictinaray list comprehension 
Python :: tkinter window not responding during progress bar 
Python :: read://https_www.tumblr.com/?url=https://www.tumblr.com/login?redirect_to=%2Fneue_web%2Fiframe%2Freblog%2F629907744681590784%2FjQw7OUs8&3739a18c-0c68-43cc-a4cb-b8b99e9bfd72=a52e06db-92b6-4b86-b3c5-fa2ab267405c 
Python :: repeat printing rows excel using python whenever i run the script 
Python :: pie chart add outline python 
Python :: nltk document 
Python :: 1 min candle resampling pandas 
Python :: python site-packages pyspark 
Python :: Access the Response Methods and Attributes in python Show redirections 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =