[Solved] How to find if a string contains uppercase letters and digits [closed]

[ad_1] This should help: import re # Check if the string has 3 digits or more def haveDigits(text): if len(filter(str.isdigit, text))>=3: return True else: return False # Check if the string has 2 uppercase letters or more def haveUppercase(text): if len([char for char in text if char.isupper()])>=2: return True else: return False # First condition … Read more

[Solved] remove elemets from array where value of daughter array is equal [closed]

[ad_1] The easiest way to get the result you expect is in my opinion this way: $data = array( array( ‘domain’ => ‘messages’, ‘key’ => ‘test.testik’, ‘message’ => array() ), array( ‘domain’ => ‘messages’, ‘key’ => ‘test2313.tes31231tik’, ‘message’ => array() ), array( ‘domain’ => ‘validators’, ‘key’ => ‘valid.validik’, ‘message’ => array() ), array( ‘domain’ => … Read more

[Solved] Need to implement an algorithm to obtain the average value of the fields of the graph structure( graph tree)

[ad_1] You could create recursive function with for…in loop and first calculate total sum and total number of nodes and then use those 2 values to calculate average. var graph_structure = {“val”:74,”child”:[{“val”:17,”child”:[{“val”:34,”child”:[{“val”:34,”child”:[{“val”:65,”child”:[{“val”:28,”child”:[{“val”:85},{“val”:30,”child”:[{“val”:68},{“val”:10,”child”:[{“val”:100,”child”:[{“val”:21,”child”:[{“val”:21},{“val”:64}]},{“val”:86}]}]}]}]}]},{“val”:22,”child”:[{“val”:17,”child”:[{“val”:65}]}]}]},{“val”:53,”child”:[{“val”:3,”child”:[{“val”:98,”child”:[{“val”:90,”child”:[{“val”:76,”child”:[{“val”:87,”child”:[{“val”:52,”child”:[{“val”:56}]}]},{“val”:47},{“val”:40,”child”:[{“val”:80,”child”:[{“val”:34}]},{“val”:23,”child”:[{“val”:47},{“val”:92}]},{“val”:98,”child”:[{“val”:89},{“val”:16},{“val”:10}]}]}]}]},{“val”:35,”child”:[{“val”:89,”child”:[{“val”:76,”child”:[{“val”:50,”child”:[{“val”:51},{“val”:90}]},{“val”:69,”child”:[{“val”:93},{“val”:98},{“val”:62}]}]}]}]}]}]}]}]}]},{“val”:98,”child”:[{“val”:85},{“val”:85,”child”:[{“val”:58,”child”:[{“val”:81,”child”:[{“val”:36,”child”:[{“val”:45,”child”:[{“val”:96,”child”:[{“val”:15,”child”:[{“val”:11,”child”:[{“val”:96}]}]},{“val”:48,”child”:[{“val”:4,”child”:[{“val”:74},{“val”:1}]},{“val”:7}]}]},{“val”:84,”child”:[{“val”:9},{“val”:81,”child”:[{“val”:10,”child”:[{“val”:67}]}]}]}]},{“val”:85,”child”:[{“val”:53},{“val”:7,”child”:[{“val”:47,”child”:[{“val”:74,”child”:[{“val”:30},{“val”:7},{“val”:12}]},{“val”:22}]},{“val”:56,”child”:[{“val”:51,”child”:[{“val”:45}]},{“val”:54,”child”:[{“val”:20},{“val”:62}]}]}]}]}]}]}]},{“val”:62,”child”:[{“val”:36,”child”:[{“val”:39,”child”:[{“val”:20}]},{“val”:10,”child”:[{“val”:91,”child”:[{“val”:81,”child”:[{“val”:59,”child”:[{“val”:19,”child”:[{“val”:59},{“val”:16}]},{“val”:35,”child”:[{“val”:30}]},{“val”:6,”child”:[{“val”:27}]}]},{“val”:89,”child”:[{“val”:60,”child”:[{“val”:59}]}]}]}]}]}]}]}]}]},{“val”:8,”child”:[{“val”:56,”child”:[{“val”:55,”child”:[{“val”:41,”child”:[{“val”:17,”child”:[{“val”:15,”child”:[{“val”:40,”child”:[{“val”:55,”child”:[{“val”:50},{“val”:99,”child”:[{“val”:86},{“val”:90}]}]}]},{“val”:85,”child”:[{“val”:36,”child”:[{“val”:39,”child”:[{“val”:45}]}]}]},{“val”:78,”child”:[{“val”:24,”child”:[{“val”:93,”child”:[{“val”:8}]},{“val”:26,”child”:[{“val”:5}]}]},{“val”:36}]}]},{“val”:13}]}]},{“val”:10,”child”:[{“val”:0,”child”:[{“val”:77,”child”:[{“val”:46,”child”:[{“val”:72,”child”:[{“val”:17,”child”:[{“val”:10},{“val”:67}]},{“val”:48},{“val”:60}]},{“val”:98,”child”:[{“val”:12,”child”:[{“val”:61},{“val”:27}]}]}]}]}]}]}]}]}]}]} function calc(data) { return (function repeat(data, res) { for(let i in data) { if(data.val) { res.nodes++; res.total += data.val if(!res.min) res.min = data … Read more

[Solved] Is there a Vanilla JS alternative for the jQuery UI Dialog widget [closed]

[ad_1] Only to a certain extend. You might use alert, prompt or confirm dialogs (implemented as functions on the window object), but they can’t be styled and look different between various browsers. Creating a special modal/dialog with vanilla JS is of course possible. How hard it is depends on the features you want/need it to … Read more

[Solved] Haskell join function inputs in list in specific order

[ad_1] Well since you got it working without the starting/ending point. An easy way to complete would be use your function but add the starting/ending point in the list in an inner function. So your interface is still same. Another way using recursion, pattern matching and guards is: — assuming the inputs to be int … Read more

[Solved] more than one type in Arraylist

[ad_1] This is not the proper way, but you can do something like this, ArrayList<Object> objects = new ArrayList<>(); objects.add(1); objects.add(“asd”); The better way is to create a different class with the attributes with Strings and int values you want. Then create an array with the type of that class and add those objects to … Read more

[Solved] can someone please elaborate the following code?

[ad_1] The line: ch[i] = (char)(ch[i] – ‘a’ + ‘A’); Sets ch[i] to its associated uppercase due to a constant difference between an uppercase letter and its lowercase form. For means of communication, the line can be re-written as: ch[i] = (char)(ch[i] + (‘A’ – ‘a’)); By adding this constant difference the line yields the … Read more

[Solved] Are Express Validator and Express Mutually Exclusive or Dependent Packages [closed]

[ad_1] Since v4.16.0 you no longer need to use body-parser, instead you can use express.json(). Once you have the request body you can use express-validator to validate the input. Code examples available here Edit To access the request body you have two options: app.use(bodyParser.json()) // Option A: middleware bodyParser app.use(express.json()) // Option B: in-built method … Read more

[Solved] how to fetch data from a database?

[ad_1] Try with below code, it should work. $output = array(); $output2 = ”; foreach($this->CoachPlayers as $key => $value){ $coachName = $value[‘coachName’]; $coachImage = $value[‘icon’]; if (!array_key_exists($coachName, $output)) { $output[$coachName] = array(); } $player = array(); $player[‘name’] = $value[‘name’]; $player[‘age’] = $value[‘age’]; $output[$coachName][] = $player; $output[$coachName][‘image’] = $value[‘icon’]; } foreach($output as $data => $values) { … Read more