[Solved] How to convert a number into two numbers in the scientific notation?

[ad_1] use this Method to determine your string public static string ConvertExp(int Value) { int exp = Math.Abs(Value).ToString().Length -1; return string.Format(“{0} * 10^{1}”,( Value / Math.Pow(10 , exp)), exp); } and to get 2 values public static double[] ConvertExp(int Value) { int exp = Math.Abs(Value).ToString().Length -1; return new double[] { Value / Math.Pow(10, exp), Math.Pow(10, … Read more

[Solved] Codechef : Correct approach or not?

[ad_1] My friend your approach is absolutely right , Only check your datatype to print answer . Your answer may come >10000000000 for any test case . check it, Its open forum , So I won’t mention by pointing. 3 [ad_2] solved Codechef : Correct approach or not?

[Solved] combinations program help in python [closed]

[ad_1] Alright I’ve done the hard part hoping you can finish it up: tmp = [] def recal(_list): n = [] if ‘-‘ in _list: for i in 0,1: t = _list[:] t[t.index(‘-‘)] = i n.append(recall(t)) else: tmp.append(l) return l recall([‘-‘,’-‘,’0′,’1’]) for l in tmp: print int(”.join(l),2) 0 [ad_2] solved combinations program help in python … Read more

[Solved] Power of two failed to pass the test

[ad_1] Are you sure that you are checking power of 2? Rather, being checked divisible with 2. If you are serious, use the piece of cake snippet return n > 0 && ((n & -n) == n); The second way, private static boolean powerOf2(int num) { if(num <= 0){ return false; } while(num > 1) … Read more

[Solved] searching sub string in string and check another string before that [closed]

[ad_1] Here ya go, use std::string::find: // Notice the double quotes std::string::size_type position = my_string.find(“34”); bool found = ((position != std::string::npos) && (position > 0) && (my_string[position – 1] == ‘6’)); The find method returns the position of substring, or std::string::npos if it is not found. The position must be greater than 0, because of … Read more

[Solved] Finding consecutive letters in a list [closed]

[ad_1] def consecutiveLetters(word): currentMaxCount = 1 maxChar=”” tempCount = 1 for i in range(0, len(word) – 2): if(word[i] == word[i+1]): tempCount += 1 if tempCount > currentMaxCount: currentMaxCount = tempCount maxChar = word[i] else: currentMaxCount = 1 return [maxChar,tempCount] result = consecutiveLetters(“TATAAAAAAATGACA”) print(“The max consecutive letter is “, result[0] , ” that appears “, result[1], … Read more

[Solved] which code is better? [closed]

[ad_1] “Better” is a subjective term. Some points to consider: Yes, if you had a Map or an object keyed by id for patients, beds, and departments, in general looking up patients, beds, and departments by id would be faster using that Map/object instead of a linear searches of those arrays. But, presuming that you … Read more