[Solved] Convert a swift function in objective-c

I think you want to find if given string contains at least one of the strings contained in the array to ban abusive words – (BOOL) checkIfOfStringOfArray: (NSArray *) array inString: (NSString *) string { for (NSString * element in array) { if ([string containsString: element]) return YES; } return NO; } Call like: BOOL … Read more

[Solved] NullPointerException error in Insertion sort [closed]

You are not passing the array object to sort method. Try the following code: public class SortTest { public void sort(String[] array) { String insert; for (int next = 1; next < array.length; next++) { insert = array[next]; int moveItem = next; while (moveItem > 0 && array[moveItem – 1].compareTo(insert) > 0) { array[moveItem] = … Read more

[Solved] how to convert a string of number with trailing x’s into a list of unsigned numbers

Create two variables: std::string maxVal = fn; std::replace(maxVal, ‘X’, ‘9’); std::string minVal = fn; std::replace(minVal, ‘X’, ‘0’); Now you can loop with for (auto i = std::stoi(minVal), j = std::stoi(maxVal); i <= j; ++i) { codes.push_back(i); } The whole Code #include <algorithm> #include <iostream> #include <list> std::list<unsigned> stringToCode(std::string fn) { std::string maxVal = fn; std::replace(std::begin(maxVal), … Read more

[Solved] Java Array Search, on a value which i’snt inside the array Exception Error

Yes. For example, if you were trying to ‘catch’ an InvalidYearException, you would do something like this: try { // Your code (the code that will possibly cause an exception to be thrown) } catch(InvalidYearException exception) { // Your code (the code that will be executed when you ‘catch’ an InvalidYearException) // for example: System.out.println(“Error!” … Read more

[Solved] How to get unique value of json and sum another value in array?

You need to check existence of value in array using .indexOf(). If value doesn’t exist in array, insert it using .push(). About WinProbability, if exist, increase value of it. var json = [ {“ID”:1,”Nominee”:”12 Years a Slave”,”WinProbability”:0.00,”WinType”:”Win”}, {“ID”:2,”Nominee”:”12 Years a Slave”,”WinProbability”:2.81,”WinType”:”Win”}, {“ID”:3,”Nominee”:”12 Years a Slave”,”WinProbability”:0.66,”WinType”:”Nominated”}, {“ID”:1,”Nominee”:”American Hustle”,”WinProbability”:1.62,”WinType”:”Nominated”}, {“ID”:2,”Nominee”:”American Hustle”,”WinProbability”:0.85,”WinType”:”Win”}, {“ID”:3,”Nominee”:”American Hustle”,”WinProbability”:0.07,”WinType”:”Win”}, {“ID”:1,”Nominee”:”Captain Phillips”,”WinProbability”:2.70,”WinType”:”Nominated”}, {“ID”:2,”Nominee”:”Captain Phillips”,”WinProbability”:0.00,”WinType”:”Win”}, … Read more

[Solved] Merging objects by property, accumulating another property in node

var sales = [ { order_id: 138, price: 25, }, { order_id: 138, price: 30, }, { order_id: 139, price: 15, }, { order_id: 131, price: 25, }, ]; var buf = {} sales.map(obj => { if(buf[obj.order_id]) { buf[obj.order_id].price += obj.price } else { buf[obj.order_id] = obj } }) var result = Object.values(buf) console.log(result) 1 … Read more

[Solved] cant access json array using php [closed]

Look at documentation: json_decode( string $json, ?bool $associative = null, int $depth = 512, int $flags = 0 ): mixed and you are passing second argument as true, so it returns array and not object. And you missing intermediate keys. So final solution would be: $update = file_get_contents(‘php://input’); $update = json_decode($update, true); $callbak = $update[‘result’][0][‘callback_query’][‘data’]; … Read more

[Solved] Android App Crushing Unexpectedly [closed]

Since you are using Arrays.asList to create your list, this list is unmodifiable, you cannot add or delete any element. Arrays.asList: Returns a fixed-size list backed by the specified array. So when you get to the line facts.remove(randomNumber); you get an Exception like the following (just guessing because you have not shared any stacktrace or … Read more

[Solved] Find missing int values from over two or more different dynamic arrays [closed]

You can use standard algorithms i.e. : #include <iostream> #include <algorithm> int main() { int array_1[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int array_2[9] = {0, 3, 4, 6, 7, 2, 9, 8, 5}; int* missingValPtr = std::find_if(std::begin(array_1), std::end(array_1), [&](int arr1Val){ return std::none_of(std::begin(array_2), std::end(array_2), [&](int arr2Val) { return arr1Val == … Read more

[Solved] How can I get time for each name

The variable dateBirth is static. This means that whenever it is changed on one person, it is changed on all of the other people as well. The last person has a date of birth of May 23, 1968, so, since it is the last time the variable is changed, that is what all of the … Read more