Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Quran Symmetry Analyser  RSS feed

 
Intiyaz Mohammad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class QuranSymmetryAnalyser {

public static void main(String args[]) {

int[] chapterNos = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114 };

int[] verseNoDuplicates = {7,286,200,176,120,165,206,75,129,109,123,111,43,52,99,128,111,110,98,135,
112,78,118,64,77,227,93,88,69,60,34,30,73,54,45,83,182,88,75,85,54,53,89,59,37,35,38,29,18,
45,60,49,62,55,78,96,29,22,24,13,14,11,11,18,12,12,30,52,52,44,28,28,20,56,40,31,50,40,46,
42,29,19,36,25,22,17,19,26,30,20,15,21,11,8,8,19,5,8,8,11,11,8,3,9,5,4,7,3,6,3,5,4,5,6};

QuranSymmetryAnalyser quranAnalyser = new QuranSymmetryAnalyser();
int[] verseNos = quranAnalyser.removeDuplicates(verseNoDuplicates);

System.out.println(chapterNos.length + ": Chapter Sequence Numbers               = " + Arrays.toString(chapterNos));
System.out.println(verseNoDuplicates.length + ": Chapter Verse Numbers with Duplicates    = " + Arrays.toString(verseNoDuplicates));


int[] oddNos = quranAnalyser.findOdds(verseNoDuplicates);
int[] evenNos = quranAnalyser.findEvens(verseNoDuplicates);

System.out.println("************** Separate the Odd and Even numbers from above 114 verse numbers*************************");
System.out.println(evenNos.length + ": EVEN Verse Numbers                        = " + Arrays.toString(evenNos));
System.out.println(oddNos.length + ": ODD Verse Numbers                         = " + Arrays.toString(oddNos));
System.out.println("************** Here we got 54 odd, 60 even numbers from verses.***************************************");

int[] oddNoChapters = quranAnalyser.findOdds(chapterNos);
int[] evenNoChapters = quranAnalyser.findEvens(chapterNos);
int[] oddNoVerses = quranAnalyser.findOdds(verseNos);
int[] evenNoVerse = quranAnalyser.findEvens(verseNos);

int[] oddCommonNumbers = quranAnalyser.intersection(oddNoChapters, oddNoVerses);
int[] evenCommonNumbers = quranAnalyser.intersection(evenNoChapters, evenNoVerse);

int[] sequencePlusVerseNumbers = quranAnalyser.addElementsOfTwoArrays(chapterNos, verseNoDuplicates);


System.out.println(sequencePlusVerseNumbers.length + ": Sequence + Verse Numbers                 = " + Arrays.toString(sequencePlusVerseNumbers));


int[] sequencePlusVerseODDNumbers = quranAnalyser.findOdds(sequencePlusVerseNumbers);
int[] sequencePlusVerseEVENNumbers = quranAnalyser.findEvens(sequencePlusVerseNumbers);

System.out.println("************** Separate the Odd and Even numbers from the addition of sequence and verse numbers*************************");
System.out.println(sequencePlusVerseODDNumbers.length + ": ODD Numbers                               = " + Arrays.toString(sequencePlusVerseODDNumbers));
System.out.println(sequencePlusVerseEVENNumbers.length + ": EVEN Numbers                              = " + Arrays.toString(sequencePlusVerseEVENNumbers));
System.out.println("************** After adding sequence number to verse numbers we get equal 57 Odd, 57 Even numbers*********************");

System.out.println("Sum of sequence Numbers                       = " + quranAnalyser.addElementsOfOneArray(chapterNos));
System.out.println("Sum of verse Numbers                          = " + quranAnalyser.addElementsOfOneArray(verseNoDuplicates));
System.out.println("Sum of sequence Plus Verse Numbers (ODD)      = " + quranAnalyser.addElementsOfOneArray(sequencePlusVerseODDNumbers));
System.out.println("Sum of sequence Plus Verse Numbers (EVEN)     = " + quranAnalyser.addElementsOfOneArray(sequencePlusVerseEVENNumbers));
System.out.println("*************** Here see how their SUMs are matching******************************");

System.out.println("\n");
System.out.println(verseNos.length + ":  Chapter Verse Numbers with No Duplicates : " + Arrays.toString(verseNos));
System.out.println("**********************************************************************************************************************");
System.out.println(
"Question: How many of the ODD numbers that consist in the sequence numbers are also contained in the numbers of verses ?");
System.out.println(oddNoChapters.length + ": Odd Numbered Chapters" + Arrays.toString(oddNoChapters));
System.out.println(oddNoVerses.length + ": Odd Numbered Verses" + Arrays.toString(oddNoVerses));
System.out.println("The answer is = " + oddCommonNumbers.length);

System.out.println("**********************************************************************************************************************");
System.out.println(
"Question: How many of the EVEN numbers that consist in the sequence numbers are also contained in the numbers of verses?");
System.out.println(evenNoChapters.length + ": Even Numbered Chapters" + Arrays.toString(evenNoChapters));
System.out.println(evenNoVerse.length + ": Even Numbered Verses" + Arrays.toString(evenNoVerse));
System.out.println("The answer is = " + evenCommonNumbers.length);

int[] oddUniqueNumbers = quranAnalyser.findUniqueElements(oddNoChapters, oddNoVerses);
int[] evenUniqueNumbers = quranAnalyser.findUniqueElements(evenNoChapters, evenNoVerse);

System.out.println("**********************************************************************************************************************");
System.out.println(
"Question: How many of the ODD numbers found in the Question sequence numbers are have not been used in the numbers of verses?");
System.out.println(oddNoChapters.length + ": Odd Numbered Chapters" + Arrays.toString(oddNoChapters));
System.out.println(oddNoVerses.length + ": Odd Numbered Verses" + Arrays.toString(oddNoVerses));
System.out.println("The answer is = " + oddUniqueNumbers.length);

System.out.println("**********************************************************************************************************************");
System.out.println(
"Question: How many of the EVEN numbers found in the Question sequence numbers are have not been used in the numbers of verses?");
System.out.println(evenNoChapters.length + ": Even Numbered Chapters" + Arrays.toString(evenNoChapters));
System.out.println(evenNoVerse.length + ": Even Numbered Verses" + Arrays.toString(evenNoVerse));
System.out.println("The answer is = " + evenUniqueNumbers.length);
System.out.println("**********************************************************************************************************************");

}

}


Results:
114: Chapter Sequence Numbers               = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114]
114: Chapter Verse Numbers with Duplicates    = [7, 286, 200, 176, 120, 165, 206, 75, 129, 109, 123, 111, 43, 52, 99, 128, 111, 110, 98, 135, 112, 78, 118, 64, 77, 227, 93, 88, 69, 60, 34, 30, 73, 54, 45, 83, 182, 88, 75, 85, 54, 53, 89, 59, 37, 35, 38, 29, 18, 45, 60, 49, 62, 55, 78, 96, 29, 22, 24, 13, 14, 11, 11, 18, 12, 12, 30, 52, 52, 44, 28, 28, 20, 56, 40, 31, 50, 40, 46, 42, 29, 19, 36, 25, 22, 17, 19, 26, 30, 20, 15, 21, 11, 8, 8, 19, 5, 8, 8, 11, 11, 8, 3, 9, 5, 4, 7, 3, 6, 3, 5, 4, 5, 6]
************** Separate the Odd and Even numbers from above 114 verse numbers*************************
60: EVEN Verse Numbers                        = [286, 200, 176, 120, 206, 52, 128, 110, 98, 112, 78, 118, 64, 88, 60, 34, 30, 54, 182, 88, 54, 38, 18, 60, 62, 78, 96, 22, 24, 14, 18, 12, 12, 30, 52, 52, 44, 28, 28, 20, 56, 40, 50, 40, 46, 42, 36, 22, 26, 30, 20, 8, 8, 8, 8, 8, 4, 6, 4, 6]
54: ODD Verse Numbers                         = [7, 165, 75, 129, 109, 123, 111, 43, 99, 111, 135, 77, 227, 93, 69, 73, 45, 83, 75, 85, 53, 89, 59, 37, 35, 29, 45, 49, 55, 29, 13, 11, 11, 31, 29, 19, 25, 17, 19, 15, 21, 11, 19, 5, 11, 11, 3, 9, 5, 7, 3, 3, 5, 5]
************** Here we got 54 odd, 60 even numbers from verses.***************************************
114: Sequence + Verse Numbers                 = [8, 288, 203, 180, 125, 171, 213, 83, 138, 119, 134, 123, 56, 66, 114, 144, 128, 128, 117, 155, 133, 100, 141, 88, 102, 253, 120, 116, 98, 90, 65, 62, 106, 88, 80, 119, 219, 126, 114, 125, 95, 95, 132, 103, 82, 81, 85, 77, 67, 95, 111, 101, 115, 109, 133, 152, 86, 80, 83, 73, 75, 73, 74, 82, 77, 78, 97, 120, 121, 114, 99, 100, 93, 130, 115, 107, 127, 118, 125, 122, 110, 101, 119, 109, 107, 103, 106, 114, 119, 110, 106, 113, 104, 102, 103, 115, 102, 106, 107, 111, 112, 110, 106, 113, 110, 110, 114, 111, 115, 113, 116, 116, 118, 120]
************** Separate the Odd and Even numbers from the addition of sequence and verse numbers*************************
57: ODD Numbers                               = [203, 125, 171, 213, 83, 119, 123, 117, 155, 133, 141, 253, 65, 119, 219, 125, 95, 95, 103, 81, 85, 77, 67, 95, 111, 101, 115, 109, 133, 83, 73, 75, 73, 77, 97, 121, 99, 93, 115, 107, 127, 125, 101, 119, 109, 107, 103, 119, 113, 103, 115, 107, 111, 113, 111, 115, 113]
57: EVEN Numbers                              = [8, 288, 180, 138, 134, 56, 66, 114, 144, 128, 128, 100, 88, 102, 120, 116, 98, 90, 62, 106, 88, 80, 126, 114, 132, 82, 152, 86, 80, 74, 82, 78, 120, 114, 100, 130, 118, 122, 110, 106, 114, 110, 106, 104, 102, 102, 106, 112, 110, 106, 110, 110, 114, 116, 116, 118, 120]
************** After adding sequence number to verse numbers we get equal 57 Odd, 57 Even numbers*********************
Sum of sequence Numbers                       = 6555
Sum of verse Numbers                          = 6236
Sum of sequence Plus Verse Numbers (ODD)      = 6555
Sum of sequence Plus Verse Numbers (EVEN)     = 6236
*************** Here see how their SUMs are matching******************************


77:  Chapter Verse Numbers with No Duplicates : [3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 29, 30, 31, 34, 35, 36, 37, 38, 40, 42, 43, 44, 45, 46, 49, 50, 52, 53, 54, 55, 56, 59, 60, 62, 64, 69, 73, 75, 77, 78, 83, 85, 88, 89, 93, 96, 98, 99, 109, 110, 111, 112, 118, 120, 123, 128, 129, 135, 165, 176, 182, 200, 206, 227, 286]
**********************************************************************************************************************
Question: How many of the ODD numbers that consist in the sequence numbers are also contained in the numbers of verses ?
57: Odd Numbered Chapters[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113]
37: Odd Numbered Verses[3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 25, 29, 31, 35, 37, 43, 45, 49, 53, 55, 59, 69, 73, 75, 77, 83, 85, 89, 93, 99, 109, 111, 123, 129, 135, 165, 227]
The answer is = 32
**********************************************************************************************************************
Question: How many of the EVEN numbers that consist in the sequence numbers are also contained in the numbers of verses?
57: Even Numbered Chapters[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114]
40: Even Numbered Verses[4, 6, 8, 12, 14, 18, 20, 22, 24, 26, 28, 30, 34, 36, 38, 40, 42, 44, 46, 50, 52, 54, 56, 60, 62, 64, 78, 88, 96, 98, 110, 112, 118, 120, 128, 176, 182, 200, 206, 286]
The answer is = 32
**********************************************************************************************************************
Question: How many of the ODD numbers found in the Question sequence numbers are have not been used in the numbers of verses?
57: Odd Numbered Chapters[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113]
37: Odd Numbered Verses[3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 25, 29, 31, 35, 37, 43, 45, 49, 53, 55, 59, 69, 73, 75, 77, 83, 85, 89, 93, 99, 109, 111, 123, 129, 135, 165, 227]
The answer is = 25
**********************************************************************************************************************
Question: How many of the EVEN numbers found in the Question sequence numbers are have not been used in the numbers of verses?
57: Even Numbered Chapters[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114]
40: Even Numbered Verses[4, 6, 8, 12, 14, 18, 20, 22, 24, 26, 28, 30, 34, 36, 38, 40, 42, 44, 46, 50, 52, 54, 56, 60, 62, 64, 78, 88, 96, 98, 110, 112, 118, 120, 128, 176, 182, 200, 206, 286]
The answer is = 25
**********************************************************************************************************************
 
Tim Moores
Saloon Keeper
Posts: 3512
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a lot of code. Do you have a question about it?
 
Intiyaz Mohammad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops...I thought I have posted the question. Do we have any ready made functions for removing duplicates values from given array , find odd and even numbers from given array. Intersection of two arrays, add corresponding elements of 2 arrays. I have written but they are buggy and involves iteration loops. Please let me know if you know any java specific a pis for these functionalities.
 
somashaker goud
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you use collections like Arraylist and Set which will make your life easy.

We don't have method called remove in array . If you want to remove any element from array you need to recreate array by copying one required elements which will be cumbersome so use arraylist which will take care of all these things internally.
 
Intiyaz Mohammad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
somashaker goud wrote:Why don't you use collections like Arraylist and Set which will make your life easy.

We don't have method called remove in array . If you want to remove any element from array you need to recreate array by copying one required elements which will be cumbersome so use arraylist which will take care of all these things internally.
Let me check the collection framework. Thanks for your suggestion.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!