[Solved] consider a string which has question marks, numbers , letters [closed]

I leave the refactoring of regex on you, but this is something you can do using String.prototype.match. function checkStr(str) { let match = str.match(/(\d)\?{3}(\d)/); return match && +match[1] + +match[2] === 10; } let out = checkStr(‘bdhfr6???3hfyrt5???eee5’); console.log(out) out = checkStr(‘bdhfr6???4hfyrt5???eee5’); console.log(out) solved consider a string which has question marks, numbers , letters [closed]

[Solved] Array Default Constructor [closed]

You can do this: public class IntArrayDemo { private static final int DEFAULT_SIZE = 10; private int [] values; public IntArrayDemo() { this(DEFAULT_SIZE); } public IntArrayDemo(int size) { if (size < 0) throw new IllegalArgumentException(“size cannot be negative”); this.values = new int[size]; } } solved Array Default Constructor [closed]

[Solved] Group array by inner value in PHP

Try this $result = []; foreach ($array as $vlaue) { $uniqueKey = $vlaue[‘lat’] .’_’. $vlaue[‘long’]; $result[$uniqueKey][] = $value; } $result = array_values($result); 2 solved Group array by inner value in PHP

[Solved] How to get minimum & maximum value in a NSString/String array?

@user3815344’s answer works, however you can simplify it by using minElement and maxElement to retrieve the minimum and maximum values. For example: let arr = [“55a”, “95a”, “66”, “25”, “88b”, “#”] let numbers: [Int] = arr.reduce([]) { if let num = “”.join($1.componentsSeparatedByCharactersInSet(NSCharacterSet.decimalDigitCharacterSet().invertedSet)).toInt() { return $0 + [num] } return $0 } minElement(numbers) // 25 maxElement(numbers) … Read more

[Solved] How to create a method that allows arrays to act like single values?

Do not use this answer, just use Select() method much simpler. class Program { static void Main(string[] args) { string[] s = new string[] { “hi”, “hello”, “what’s up” }; string[] newS = s.ArrayTo<string>(x => x.Remove(0, 1) ); foreach (string str in newS) Console.WriteLine(str); } } static class Ext { public static T[] ArrayTo<T>(this T[] … Read more

[Solved] How to find the depth of an unlimited depthed array [duplicate]

Try this man function array_depth($array, $n = 0) { $max_depth = 1; foreach ($array as $value) { if (isset($value[‘subcategories’][0])) { $depth = $this -> array_depth($value[‘subcategories’]) + 1; if ($depth > $max_depth) { $max_depth = $depth; } } } return $max_depth; } 1 solved How to find the depth of an unlimited depthed array [duplicate]

[Solved] R create a matrix of occurence [closed]

Ok, still not perfectly clear, but I THINK that presence is now an adjacency matrix, where the columns represent users and the rows represent events, so presence[i,j] indicates that user i attended event j. If I’m interpreting it correctly then counts seems to be the co-occurrence matrix, correct? count[i,j] should record the number of events … Read more

[Solved] Find smallest even from array. and also average of even and odd numbers?

Try this. package lesson5; import java.util.Scanner; public class task3 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int [] masarray = new int [10]; int a,b,c,d,f,g,j,m,n,l; int flag_even =0; int min_even = 0; float sum_even=0; float sum_odd=0; int total_even=0; int total_odd=0; System.out.println(“input first number of array”); a=sc.nextInt(); masarray [0]= a; System.out.println(“input … Read more