dasari4kntr Posted February 25 Author Report Posted February 25 2 minutes ago, nag said: bro.. don't know how time sensitive is your request.. basically I would start it a smaller code and enhance it in iterations.. naa coding style kooda adhey.. as i said I'm done coding for the code.. been a long day if you have time..i can give it you later lite bro… just discussing approaches ..అంతే… take it lite… Quote
ARYA Posted February 25 Report Posted February 25 9 minutes ago, dasari4kntr said: nice…can you ask how to convert to indian number system…? i am expecting minimal changes… def number_to_words_indian(n): if n == 0: return "zero" ones = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] teens = ["", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"] tens = ["", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"] # Modified for Indian Number System indian_place_values = ["", "thousand", "lakh", "crore", "arab", "kharab"] # Step 1: Extract digits and push them into a stack stack = [] temp = n while temp > 0: stack.append(temp % 10) temp //= 10 # Step 2: Process digits from stack num_words = [] position = len(stack) # Determines the place value (hundreds, thousands, etc.) # Indian system follows 3,2,2,2 grouping (not 3,3,3) groupings = [3, 2, 2, 2, 2] # First 3 digits as a group, then 2s grouping_index = 0 while stack: chunk_size = groupings[grouping_index] if grouping_index < len(groupings) else 2 chunk = [] for _ in range(chunk_size): if stack: chunk.append(stack.pop()) num_chunk = int("".join(map(str, chunk[::-1]))) # Convert list of digits to number words = [] # Process chunk if num_chunk >= 100: words.append(ones[num_chunk // 100] + " hundred") num_chunk %= 100 if 10 < num_chunk < 20: words.append(teens[num_chunk - 10]) else: if num_chunk >= 20: words.append(tens[num_chunk // 10]) num_chunk %= 10 if num_chunk > 0: words.append(ones[num_chunk]) # Append place value (e.g., lakh, crore) if words and grouping_index > 0: words.append(indian_place_values[grouping_index]) num_words.extend(words) grouping_index += 1 return " ".join(num_words) # Test cases print(number_to_words_indian(375)) # Output: three hundred seventy five print(number_to_words_indian(760000)) # Output: seven lakh sixty thousand print(number_to_words_indian(123456789)) # Output: twelve crore thirty four lakh fifty six thousand seven hundred eighty nine print(number_to_words_indian(10000000)) # Output: one crore print(number_to_words_indian(5000000000)) # Output: five arab Quote
dasari4kntr Posted February 25 Author Report Posted February 25 2 minutes ago, ARYA said: groupings = [3, 2, 2, 2, 2] # First 3 digits as a group, then 2s thats the key… Quote
nag Posted February 25 Report Posted February 25 5 minutes ago, dasari4kntr said: lite bro… just discussing approaches ..అంతే… take it lite… ok 1 Quote
ARYA Posted February 25 Report Posted February 25 1 minute ago, dasari4kntr said: thats the key… Yes thata Quote
TeluguTexas Posted February 25 Report Posted February 25 56 minutes ago, dasari4kntr said: no…next four years…survive అయ్యి…india కి పోయి రిటైర్మెంట్ తీసుకుంటా… my target is survive for next four years in usa…honestly saying.. 40 key retire???not even work until 45 or 50? India lo properties or full rich?? India lo ela survive avvali bro Quote
Aquaman Posted February 25 Report Posted February 25 59 minutes ago, dasari4kntr said: no…next four years…survive అయ్యి…india కి పోయి రిటైర్మెంట్ తీసుకుంటా… my target is survive for next four years in usa…honestly saying.. india poyedhi unte..y bought home Quote
dasari4kntr Posted February 25 Author Report Posted February 25 11 hours ago, TeluguTexas said: 40 key retire???not even work until 45 or 50? India lo properties or full rich?? India lo ela survive avvali bro already 40+… 11 hours ago, Aquaman said: india poyedhi unte..y bought home సొంతూరు తప్ప…ఏ ఆస్తి స్తిరాస్ధి కాదు…ఎప్పుడైనా అమ్ముకోవచ్చు… 1 Quote
Aquaman Posted February 25 Report Posted February 25 10 minutes ago, dasari4kntr said: already 40+… సొంతూరు తప్ప…ఏ ఆస్తి స్తిరాస్ధి కాదు…ఎప్పుడైనా అమ్ముకోవచ్చు… 40 is new 30 ani @csrcsr tolded no Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.