شهادة القرآن الكريم

شهادة دار الإحسان

الحمد لله أن من علينا “قل بفضل الله وبرحمته فبذلك فليفرحوا هو خير مما يجمعون”

شهادة تقدير

الحمد لله الذى أعز حامل القرآن الكريم والصلاة والسلام على رسول الله القائل: “خيركم من تعلم القرآن وعلمه”

يسر الإدارة العامة لشئون القرآن منح هذه الشهادة للطالب/ عمر خميس مصطفى

وذلك لفوزه فى المسابقة القرآنية عام 1440 ه وذلك فى حفظ القرآن الكريم وكان تقديره/ امتياز (ب)

وقد تم اختياره من قبل لجنة متخصصة فى علوم القرآن الكريم والقراءا بإشراف الإدارة العامة لشئون القرآن الكريم بقطاع المعاهد الأزهرية

 

 

Mini-Max Sum

https://www.hackerrank.com/challenges/mini-max-sum/problem

   public static void miniMaxSum(List<Integer> arr) {
    // Write your code here
         Collections.sort(arr);
         BigInteger sum = BigInteger.ZERO;
         for (int i = 0; i < arr.size(); i++){
              sum =sum.add(BigInteger.valueOf(arr.get(i)));
         }
         System.out.print(sum.subtract(BigInteger.valueOf(arr.get(arr.size()-1).intValue()))+" ");
         System.out.print(sum.subtract(BigInteger.valueOf(arr.get(0).intValue())));
      
    }

Compare the Triplets

https://www.hackerrank.com/challenges/compare-the-triplets/problem

    public static List<Integer> compareTriplets(List<Integer> a, List<Integer> b) {
    // Write your code here
        List<Integer> out = new ArrayList<Integer>(2);
        out.add(0);
        out.add(0);
        for (int i = 0; i < a.size(); i++) {
            if (a.get(i) > b.get(i))
                out.set(0, out.get(0) + 1);
            else if (a.get(i) < b.get(i))
                out.set(1, out.get(1) + 1);
        }

        return out;
    }

Bitwise AND

Given an array of non-negative integers, count the number of unordered pairs of array
elements such that their bitwise AND is a power of 2.
For example, let’s say the array is arr = [10, 7, 2, 8, 3], and let ‘&’ denote the bitwise AND
operator. There are 6 unordered pairs of its elements that have a bitwise AND that is a
power of two:
For indices (0,1), 10 & 7 = 2, which is a power of 2.
For indices (0,2), 10 & 2 = 2, which is a power of 2.
For indices (0,3), 10 & 8 = 8, which is a power of 2.
For indices (0,4), 10 & 3 = 2, which is a power of 2.
For indices (1,2), 7 & 2 = 2, which is a power of 2.
For indices (2,4), 2 & 3 = 2, which is a power of 2.
Therefore, the answer is 6.

    public static long countPairs(List<Integer> arr) {
    // Write your code here
    int count = 0;
     for(int i = 0; i < arr.size(); i++){
         for(int j= i+1; j < arr.size(); j++){
             double a = Math.log(arr.get(i).intValue()&arr.get(j).intValue())/Math.log(2) ;
             if(a == (int) a)
             count++;
         }
     }
     return count;
    }

Counting Triangles

	class Sides {
		int a;
		int b;
		int c;

		Sides(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}

	}

	public int compare(Sides o1, Sides o2) {
		int[] o1Sides = new int[] { o1.a, o1.b, o1.c };
		Arrays.sort(o1Sides);
		int[] o2Sides = new int[] { o2.a, o2.b, o2.c };
		Arrays.sort(o2Sides);
		for (int i = 0; i < o1Sides.length; i++)
			if (o1Sides[i] != o2Sides[i])
				return -1;

		return 0;
	}

	public int countDistinctTriangles(ArrayList<Sides> arr) {
		if (arr.size() == 0)
			return 0;
		Collections.sort(arr, new Comparator<Sides>() {

			@Override
			public int compare(Sides o1, Sides o2) {
				int[] o1Sides = new int[] { o1.a, o1.b, o1.c };
				Arrays.sort(o1Sides);
				int[] o2Sides = new int[] { o2.a, o2.b, o2.c };
				Arrays.sort(o2Sides);
				for (int i = 0; i < o1Sides.length; i++)
					if (o1Sides[i] != o2Sides[i])
						return -1;

				return 0;
			}
		});
		int count = 1;
		for (int i = 1; i < arr.size(); i++) {
			if (compare(arr.get(i), arr.get(i - 1)) != 0)
				count++;
		}
		return count;
	}