├── CPP_LANGUAGE_SECTION_HACKERRANK ├── CLASSES │ ├── Classes.cpp │ ├── ClassesAndObjects.cpp │ ├── Structs.cpp │ └── a.out ├── INHERITANCE │ ├── AccessingInheritedFunctions.cpp │ ├── InheritanceIntroduction.cpp │ ├── MultilevelInheritance.cpp │ └── RectangleArea.cpp ├── INTRODUCTION │ ├── ArraysIntroduction │ │ ├── ArrayIntroduction.cpp │ │ └── a.out │ ├── BasicDataTypes │ │ ├── BasicDataTypes.cpp │ │ └── a.out │ ├── ConditionalStatements │ │ └── ConditionalStatements.cpp │ ├── ForLoop │ │ ├── ForLoop.cpp │ │ └── a.out │ ├── Functions │ │ └── Function.cpp │ ├── InputAndOutput │ │ ├── InputAndOutput.cpp │ │ └── a.out │ ├── Pointers │ │ └── Pointers.cpp │ ├── RectangleArea │ │ └── RectangleArea.cpp │ ├── SayHelloWorldWithC++ │ │ ├── SayHelloWorldWithC++.cpp │ │ └── a.out │ └── VariableSizedArray │ │ ├── VariableSizedArray.cpp │ │ └── a.out ├── OTHERCONCEPTS │ ├── InheritanceIntoduction.cpp │ ├── OperatorOverloading.cpp │ ├── OverloadOperators.cpp │ └── OverloadingOstreamOperator.cpp └── STRINGS │ ├── StringStream.cpp │ ├── Strings.cpp │ └── strings.cpp ├── C_LANGUAGE_SECTION_HACKERRANK ├── bitwise-operators-in-c │ └── bitwise-operators-in-c.c ├── conditional-statements-in-c │ └── conditional-statements-in-c.c ├── for-loop-in-c │ └── for-loop-in-c.c ├── functions-in-c │ └── functions-in-c.c ├── hello-world-c │ └── hello-world-c.c ├── playing-with-characters │ └── playing-with-characters.c ├── pointer-in-c │ └── pointer-in-c.c ├── sum-numbers-c │ └── sum-numbers-c.c └── sum-of-digits-of-a-five-digit-number │ └── sum-of-digits-of-a-five-digit-number.c ├── DONTREADME.md ├── JAVA_LANGUAGE_SECTION_HACKERRANK ├── Java_stdin_and_stdout_1 │ └── Java_stdin_and_stdout_1.java ├── Welcome_to_java │ └── welcome_to_java.java ├── java_if_else │ └── java_if_else.java ├── java_loops_1 │ └── java_loops_1.java ├── java_loops_2 │ └── java_loops_2.java ├── java_output_formatting │ └── java_output_formatting.java └── java_stdin_and_stdout_2 │ └── java_stdin_and_stdout_2.java ├── MATHEMATICS ├── army-game │ └── army-game.c ├── find-the-point │ └── find-the-point.c ├── halloween-party │ └── halloween-party.c ├── handshake │ └── handshake.c ├── maximum-draws │ └── maximum-draws.c └── minimum-height-triangle │ └── minimum-height-triangle.c ├── Mathematics ├── army-game │ └── army-game.c ├── find-the-point │ └── find-the-point.c ├── halloween-party │ └── halloween-party.c ├── handshake │ └── handshake.c ├── maximum-draws │ └── maximum-draws.c └── minimum-height-triangle │ └── minimum-height-triangle.c ├── README.md └── images └── HackerRankLogo.svg /CPP_LANGUAGE_SECTION_HACKERRANK/CLASSES/Classes.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Classes.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/08 15:02:33 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/08 15:02:36 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | using namespace std; 17 | 18 | class Student 19 | { 20 | private : 21 | int age; 22 | int standard; 23 | string first_name, last_name; 24 | public : 25 | void set_age(int age); 26 | int get_age(); 27 | void set_standard(int standard); 28 | int get_standard(); 29 | void set_first_name(string first_name); 30 | string get_first_name(); 31 | void set_last_name(string last_name); 32 | string get_last_name(); 33 | string to_string(); 34 | }; 35 | 36 | void Student::set_age(int age) 37 | { 38 | this->age = age; 39 | } 40 | 41 | int Student::get_age() 42 | { 43 | return (this->age); 44 | } 45 | 46 | void Student::set_standard(int standard) 47 | { 48 | this->standard = standard; 49 | } 50 | 51 | int Student::get_standard() 52 | { 53 | return (this->standard); 54 | } 55 | 56 | void Student::set_first_name(string first_name) 57 | { 58 | this->first_name = first_name; 59 | } 60 | 61 | string Student::get_first_name() 62 | { 63 | return (this->first_name); 64 | } 65 | 66 | void Student::set_last_name(string last_name) 67 | { 68 | this->last_name = last_name; 69 | } 70 | 71 | string Student::get_last_name() 72 | { 73 | return (this->last_name); 74 | } 75 | 76 | string Student::to_string() 77 | { 78 | stringstream age, standard; 79 | string buffer; 80 | age << this->age; 81 | standard << this->standard; 82 | buffer = age.str() + "," + this->first_name + "," + \ 83 | this->last_name + "," + standard.str(); 84 | return (buffer); 85 | } 86 | 87 | int main() 88 | { 89 | int age, standard; 90 | string first_name, last_name; 91 | 92 | cin >> age >> first_name >> last_name >> standard; 93 | Student st; 94 | st.set_age(age); 95 | st.set_standard(standard); 96 | st.set_first_name(first_name); 97 | st.set_last_name(last_name); 98 | cout << st.get_age() << "\n"; 99 | cout << st.get_last_name() << ", " << st.get_first_name() << "\n"; 100 | cout << st.get_standard() << "\n"; 101 | cout << "\n"; 102 | cout << st.to_string(); 103 | return 0; 104 | } 105 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/CLASSES/ClassesAndObjects.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ClassesAndObjects.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/09 21:50:01 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/09 21:50:30 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | using namespace std; 18 | 19 | class Student 20 | { 21 | private: 22 | int scores; 23 | public : 24 | void input(); 25 | int calculateTotalScore(); 26 | }; 27 | 28 | void Student::input() 29 | { 30 | int i1, i2, i3, i4, i5; 31 | cin >> i1 >> i2 >> i3 >> i4 >> i5; 32 | this->scores = i1 + i2 + i3 + i4 + i5; 33 | } 34 | 35 | int Student::calculateTotalScore() 36 | { 37 | int count = 0; 38 | count += this->scores; 39 | return (count); 40 | } 41 | 42 | int main() { 43 | int n; // number of students 44 | cin >> n; 45 | Student *s = new Student[n]; // an array of n students 46 | 47 | for(int i = 0; i < n; i++){ 48 | s[i].input(); 49 | } 50 | 51 | // calculate kristen's score 52 | int kristen_score = s[0].calculateTotalScore(); 53 | 54 | // determine how many students scored higher than kristen 55 | int count = 0; 56 | for(int i = 1; i < n; i++){ 57 | int total = s[i].calculateTotalScore(); 58 | if(total > kristen_score){ 59 | count++; 60 | } 61 | } 62 | 63 | // print result 64 | cout << count; 65 | 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/CLASSES/Structs.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Structs.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/08 15:02:44 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/08 15:03:12 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | struct Student 16 | { 17 | int age; 18 | std::string first_name; 19 | std::string last_name; 20 | int standard; 21 | }; 22 | 23 | int main() 24 | { 25 | Student st; 26 | std::cin >> st.age >> st.first_name >> st.last_name >> st.standard; 27 | std::cout << st.age << " " << st.first_name << " " << st.last_name \ 28 | << " " << st.standard; 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/CLASSES/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ablaamim/Problem_Solving/8d12437a54ca0c666a671e9690bacc615689684a/CPP_LANGUAGE_SECTION_HACKERRANK/CLASSES/a.out -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INHERITANCE/AccessingInheritedFunctions.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* AccessingInheritedFunctions.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/15 16:15:32 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/15 16:15:44 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | class A 18 | { 19 | public: 20 | A(){ 21 | callA = 0; 22 | } 23 | private: 24 | int callA; 25 | void inc(){ 26 | callA++; 27 | } 28 | 29 | protected: 30 | void func(int & a) 31 | { 32 | a = a * 2; 33 | inc(); 34 | } 35 | public: 36 | int getA(){ 37 | return callA; 38 | } 39 | }; 40 | 41 | class B 42 | { 43 | public: 44 | B(){ 45 | callB = 0; 46 | } 47 | private: 48 | int callB; 49 | void inc(){ 50 | callB++; 51 | } 52 | protected: 53 | void func(int & a) 54 | { 55 | a = a * 3; 56 | inc(); 57 | } 58 | public: 59 | int getB(){ 60 | return callB; 61 | } 62 | }; 63 | 64 | class C 65 | { 66 | public: 67 | C(){ 68 | callC = 0; 69 | } 70 | private: 71 | int callC; 72 | void inc(){ 73 | callC++; 74 | } 75 | protected: 76 | void func(int & a) 77 | { 78 | a = a * 5; 79 | inc(); 80 | } 81 | public: 82 | int getC(){ 83 | return callC; 84 | } 85 | }; 86 | 87 | class D : public A, public B, public C 88 | { 89 | private : 90 | int val; 91 | public: 92 | //Initially val is 1 93 | D() 94 | { 95 | val = 1; 96 | } 97 | //Implement this function 98 | void update_val(int new_val) 99 | { 100 | while (new_val % 2 == 0) 101 | { 102 | new_val /= 2; 103 | A::func(val); 104 | } 105 | while (new_val % 3 == 0) 106 | { 107 | new_val /= 3; 108 | B::func(val); 109 | } 110 | while (new_val % 5 == 0) 111 | { 112 | new_val /= 5; 113 | C::func(val); 114 | } 115 | } 116 | //For Checking Purpose 117 | void check(int); //Do not delete this line. 118 | }; 119 | 120 | 121 | 122 | void D::check(int new_val) 123 | { 124 | update_val(new_val); 125 | cout << "Value = " << val << endl << "A's func called " << getA() << " times " << endl << "B's func called " << getB() << " times" << endl << "C's func called " << getC() << " times" << endl; 126 | } 127 | 128 | 129 | int main() 130 | { 131 | D d; 132 | int new_val; 133 | cin >> new_val; 134 | d.check(new_val); 135 | 136 | } 137 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INHERITANCE/InheritanceIntroduction.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* InheritanceIntroduction.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/13 19:20:08 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/13 19:20:40 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | 16 | using namespace std; 17 | 18 | 19 | class Triangle{ 20 | public: 21 | void triangle(){ 22 | cout<<"I am a triangle\n"; 23 | } 24 | }; 25 | 26 | class Isosceles : public Triangle{ 27 | public: 28 | void isosceles() 29 | { 30 | cout<<"I am an isosceles triangle\n"; 31 | } 32 | void description() 33 | { 34 | cout << "In an isosceles triangle two sides are equal" << endl; 35 | } 36 | }; 37 | 38 | int main(){ 39 | Isosceles isc; 40 | isc.isosceles(); 41 | isc.description(); 42 | isc.triangle(); 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INHERITANCE/MultilevelInheritance.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* MultilevelInheritance.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/15 15:51:06 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/15 15:53:55 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | class Triangle 18 | { 19 | public: 20 | void triangle() 21 | { 22 | cout<<"I am a triangle\n"; 23 | } 24 | }; 25 | 26 | class Isosceles : public Triangle 27 | { 28 | public: 29 | void isosceles() 30 | { 31 | cout<<"I am an isosceles triangle\n"; 32 | } 33 | }; 34 | 35 | class Equilateral : public Isosceles 36 | { 37 | public : 38 | void equilateral() 39 | { 40 | cout << "I am an equilateral triangle" << endl; 41 | } 42 | }; 43 | 44 | int main() 45 | { 46 | 47 | Equilateral eqr; 48 | 49 | eqr.equilateral(); 50 | eqr.isosceles(); 51 | eqr.triangle(); 52 | return (0); 53 | } 54 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INHERITANCE/RectangleArea.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* RectangleArea.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/14 23:03:51 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/14 23:06:43 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | class Rectangle 18 | { 19 | private : 20 | int width; 21 | int height; 22 | public : 23 | int get_height() 24 | { 25 | return (height); 26 | } 27 | int get_width() 28 | { 29 | return (width); 30 | } 31 | void set_height() 32 | { 33 | cin >> height; 34 | } 35 | void set_width() 36 | { 37 | cin >> width; 38 | } 39 | void display() 40 | { 41 | cout << height << " " << width << endl; 42 | } 43 | }; 44 | 45 | class RectangleArea : public Rectangle 46 | { 47 | public : 48 | void read_input() 49 | { 50 | set_height(); 51 | set_width(); 52 | } 53 | void display() 54 | { 55 | cout << get_height() * get_width(); 56 | } 57 | }; 58 | 59 | int main() 60 | { 61 | /* 62 | * Declare a RectangleArea object 63 | */ 64 | RectangleArea r_area; 65 | 66 | /* 67 | * Read the width and height 68 | */ 69 | r_area.read_input(); 70 | 71 | /* 72 | * Print the width and height 73 | */ 74 | r_area.Rectangle::display(); 75 | 76 | /* 77 | * Print the area 78 | */ 79 | r_area.display(); 80 | 81 | return 0; 82 | } 83 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/ArraysIntroduction/ArrayIntroduction.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ArrayIntroduction.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/02 21:34:30 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/02 21:35:02 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | 18 | int main() 19 | { 20 | int size; 21 | int i = 0; 22 | int arr[size]; 23 | 24 | cin >> size; 25 | while (size--) 26 | { 27 | cin >> arr[i]; 28 | i++; 29 | } 30 | int j = i - 1; 31 | while (j >= 0) 32 | { 33 | cout << arr[j] << " "; 34 | j--; 35 | } 36 | return (0); 37 | } 38 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/ArraysIntroduction/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ablaamim/Problem_Solving/8d12437a54ca0c666a671e9690bacc615689684a/CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/ArraysIntroduction/a.out -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/BasicDataTypes/BasicDataTypes.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* BasicDataTypes.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/02 18:04:30 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/02 18:12:10 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace std; 17 | 18 | int main() 19 | { 20 | int i; 21 | long l; 22 | char c; 23 | float f; 24 | double d; 25 | 26 | cin >> i >> l >> c >> f >> d; 27 | cout << i << endl; 28 | cout << l << endl; 29 | cout << c << endl; 30 | cout << fixed << setprecision(3) << f << endl; 31 | cout << fixed << setprecision(9) << d << endl; 32 | return (0); 33 | } 34 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/BasicDataTypes/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ablaamim/Problem_Solving/8d12437a54ca0c666a671e9690bacc615689684a/CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/BasicDataTypes/a.out -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/ConditionalStatements/ConditionalStatements.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ConditionalStatements.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/02 18:21:56 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/02 18:22:36 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | int main(void) 18 | { 19 | int n; 20 | 21 | cin >> n; 22 | if (n == 1) 23 | cout << "one" << endl; 24 | else if (n == 2) 25 | cout << "two" << endl; 26 | else if (n == 3) 27 | cout << "three" << endl; 28 | else if (n == 4) 29 | cout << "four" << endl; 30 | else if (n == 5) 31 | cout << "five" << endl; 32 | else if (n == 6) 33 | cout << "six" << endl; 34 | else if (n == 7) 35 | cout << "seven" << endl; 36 | else if (n == 8) 37 | cout << "eight" << endl; 38 | else if (n == 9) 39 | cout << "nine" << endl; 40 | else 41 | cout << "Greater than 9" << endl; 42 | return (0); 43 | } 44 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/ForLoop/ForLoop.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* ForLoop.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/02 18:30:35 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/02 18:30:37 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | int a,b; 20 | 21 | cin >> a >> b; 22 | while (a <= b) 23 | { 24 | if (a <= 9) 25 | { 26 | if (a == 1) 27 | cout << "one" << endl; 28 | else if (a == 2) 29 | cout << "two" << endl; 30 | else if (a == 3) 31 | cout << "three" << endl; 32 | else if (a == 4) 33 | cout << "four" << endl; 34 | else if (a == 5) 35 | cout << "five" << endl; 36 | else if (a == 6) 37 | cout << "six" << endl; 38 | else if (a == 7) 39 | cout << "seven" << endl; 40 | else if (a == 8) 41 | cout << "eight" << endl; 42 | else if (a == 9) 43 | cout << "nine" << endl; 44 | } 45 | else if (a > 9) 46 | { 47 | if (a % 2 == 0) 48 | cout << "even" << endl; 49 | else 50 | cout << "odd" << endl; 51 | } 52 | a++; 53 | } 54 | return (0); 55 | } 56 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/ForLoop/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ablaamim/Problem_Solving/8d12437a54ca0c666a671e9690bacc615689684a/CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/ForLoop/a.out -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/Functions/Function.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Function.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/02 21:10:50 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/02 21:16:30 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | int a,b,c,d; 20 | int max = 0; 21 | cin >> a >> b >> c >> d; 22 | if (max < a) 23 | max = a; 24 | if (max < b) 25 | max = b; 26 | if (max < c) 27 | max = c; 28 | if (max < d) 29 | max = d; 30 | cout << max; 31 | return (0); 32 | } 33 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/InputAndOutput/InputAndOutput.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* InputAndOutput.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/02 17:24:36 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/02 17:25:54 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | int i,j,k; 20 | 21 | cin >> i >> j >> k; 22 | cout << i + j + k << endl; 23 | return (0); 24 | } 25 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/InputAndOutput/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ablaamim/Problem_Solving/8d12437a54ca0c666a671e9690bacc615689684a/CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/InputAndOutput/a.out -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/Pointers/Pointers.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Pointers.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/02 21:24:37 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/02 21:25:23 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | 16 | void update(int *a,int *b) 17 | { 18 | int alter; 19 | alter = *a; 20 | *a = abs(*a + *b); 21 | *b = abs(alter - *b); 22 | } 23 | 24 | using namespace std; 25 | 26 | int main() 27 | { 28 | int a, b; 29 | int *pa = &a, *pb = &b; 30 | 31 | cin >> a >> b; 32 | update(pa, pb); 33 | cout << a << endl; 34 | cout << b << endl; 35 | return (0); 36 | } 37 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/RectangleArea/RectangleArea.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* RectangleArea.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/05 21:24:13 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/05 21:24:35 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | class Rectangle 18 | { 19 | public : 20 | int height; 21 | int width; 22 | void display(); 23 | }; 24 | 25 | class RectangleArea : public Rectangle 26 | { 27 | public : 28 | void read_input(); 29 | void display(); 30 | }; 31 | 32 | void RectangleArea::read_input() 33 | { 34 | cin >> this->height; 35 | cin >> this->width; 36 | } 37 | 38 | void RectangleArea::display() 39 | { 40 | cout << this->height * this->width << endl; 41 | } 42 | 43 | void Rectangle::display() 44 | { 45 | cout << this->height << " " << this->width << endl; 46 | } 47 | 48 | 49 | int main() 50 | { 51 | /* 52 | * Declare a RectangleArea object 53 | */ 54 | RectangleArea r_area; 55 | 56 | /* 57 | * Read the width and height 58 | */ 59 | r_area.read_input(); 60 | 61 | /* 62 | * Print the width and height 63 | */ 64 | r_area.Rectangle::display(); 65 | 66 | /* 67 | * Print the area 68 | */ 69 | r_area.display(); 70 | 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/SayHelloWorldWithC++/SayHelloWorldWithC++.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* SayHelloWorldWithC++.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/02 17:21:52 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/02 17:22:58 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | cout << "Hello, World!" << endl; 20 | return (0); 21 | } 22 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/SayHelloWorldWithC++/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ablaamim/Problem_Solving/8d12437a54ca0c666a671e9690bacc615689684a/CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/SayHelloWorldWithC++/a.out -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/INTRODUCTION/VariableSizedArray/VariableSizedArray.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* VariableSizedArray.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/02 21:53:49 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/02 21:54:23 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | using namespace std; 15 | 16 | int main() 17 | { 18 | int n, q; 19 | cin >> n; 20 | cin >> q; 21 | 22 | int** a = new int* [n]; 23 | int* arrlen = new int[n]; 24 | for (int i=0; i> arrlen[i]; 27 | a[i] = new int[arrlen[i]]; 28 | for (int j=0; j> a[i][j]; 30 | } 31 | for (int k=0; k> i >> j; 35 | cout << a[i][j] < +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/11 19:24:41 by root #+# #+# */ 9 | /* Updated: 2023/01/11 19:24:45 by root ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | using namespace std; 19 | 20 | 21 | class Triangle{ 22 | public: 23 | void triangle(){ 24 | cout<<"I am a triangle\n"; 25 | } 26 | }; 27 | 28 | class Isosceles : public Triangle{ 29 | public: 30 | void isosceles(){ 31 | cout<<"I am an isosceles triangle\n"; 32 | } 33 | void description() 34 | { 35 | cout << "In an isosceles triangle two sides are equal" << endl; 36 | } 37 | }; 38 | 39 | int main(){ 40 | Isosceles isc; 41 | isc.isosceles(); 42 | isc.description(); 43 | isc.triangle(); 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/OTHERCONCEPTS/OperatorOverloading.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ablaamim/Problem_Solving/8d12437a54ca0c666a671e9690bacc615689684a/CPP_LANGUAGE_SECTION_HACKERRANK/OTHERCONCEPTS/OperatorOverloading.cpp -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/OTHERCONCEPTS/OverloadOperators.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* OverloadOperators.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/10 17:56:08 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/10 17:56:13 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | class Complex 18 | { 19 | public: 20 | int a,b; 21 | void input(string s) 22 | { 23 | int v1=0; 24 | int i=0; 25 | while(s[i]!='+') 26 | { 27 | v1=v1*10+s[i]-'0'; 28 | i++; 29 | } 30 | while(s[i]==' ' || s[i]=='+'||s[i]=='i') 31 | { 32 | i++; 33 | } 34 | int v2=0; 35 | while(i>s1; 63 | cin>>s2; 64 | x.input(s1); 65 | y.input(s2); 66 | Complex z=x+y; 67 | cout< 2 | 3 | using namespace std; 4 | 5 | class Person { 6 | public: 7 | Person(const string& first_name, const string& last_name) : first_name_(first_name), last_name_(last_name) {} 8 | const string& get_first_name() const { 9 | return first_name_; 10 | } 11 | const string& get_last_name() const { 12 | return last_name_; 13 | } 14 | private: 15 | string first_name_; 16 | string last_name_; 17 | }; 18 | 19 | ostream &operator<<(ostream &COUT, Person const ©) 20 | { 21 | COUT << "first_name=" << copy.get_first_name() <<"," << "last_name=" <> first_name >> last_name >> event; 29 | auto p = Person(first_name, last_name); 30 | cout << p << " " << event << endl; 31 | return 0; 32 | } -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/STRINGS/StringStream.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* StringStream.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/07 13:04:43 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/07 13:04:55 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | using namespace std; 17 | 18 | vector parseInts(string str) 19 | { 20 | vector v; 21 | stringstream s(str); 22 | int i; 23 | char c; 24 | while (s >> i) 25 | { 26 | v.push_back(i); 27 | s >> c; 28 | } 29 | return (v); 30 | } 31 | 32 | int main() 33 | { 34 | string str; 35 | cin >> str; 36 | vector integers = parseInts(str); 37 | for(int i = 0; i < integers.size(); i++) 38 | cout << integers[i] << "\n"; 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/STRINGS/Strings.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Strings.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/06 16:07:46 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/06 16:09:08 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | std::string a,b; 20 | 21 | getline(cin, a); 22 | getline(cin, b); 23 | cout << a.length() << " " << b.length() << endl; 24 | cout << a + b << endl; 25 | char swap = a[0]; 26 | a[0] = b[0]; 27 | b[0] = swap; 28 | cout << a << " " << b; 29 | return (0); 30 | } 31 | -------------------------------------------------------------------------------- /CPP_LANGUAGE_SECTION_HACKERRANK/STRINGS/strings.cpp: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* strings.cpp :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2023/01/07 13:04:14 by ablaamim #+# #+# */ 9 | /* Updated: 2023/01/07 13:04:26 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | std::string a,b; 20 | 21 | getline(cin, a); 22 | getline(cin, b); 23 | cout << a.length() << " " << b.length() << endl; 24 | cout << a + b << endl; 25 | char swap = a[0]; 26 | a[0] = b[0]; 27 | b[0] = swap; 28 | cout << a << " " << b; 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /C_LANGUAGE_SECTION_HACKERRANK/bitwise-operators-in-c/bitwise-operators-in-c.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* bitwise-operators-in-c.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/15 21:17:08 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 21:17:10 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void calculate_the_maximum(int n, int k) 18 | { 19 | int i; 20 | int j; 21 | int max_and; 22 | int max_or; 23 | int max_xor; 24 | 25 | max_and = 0; 26 | max_or = 0; 27 | max_xor = 0; 28 | i = 1; 29 | while (i <= n) 30 | { 31 | j = i + 1; 32 | while (j <= n) 33 | { 34 | int x = i & j; 35 | int y = i | j; 36 | int z = i ^ j; 37 | if(x < k & x > max_and) 38 | max_and = x; 39 | if(y < k & y > max_or) 40 | max_or = y; 41 | if(z < k & z > max_xor) 42 | max_xor = z; 43 | j++; 44 | 45 | } 46 | i++; 47 | } 48 | printf("%d\n%d\n%d", max_and, max_or, max_xor); 49 | } 50 | 51 | int main(int argc, char **argv) 52 | { 53 | (void) argc; 54 | (void) argv; 55 | int n; 56 | int k; 57 | 58 | scanf("%d %d", &n, &k); 59 | calculate_the_maximum(n, k); 60 | return (EXIT_SUCCESS); 61 | } 62 | -------------------------------------------------------------------------------- /C_LANGUAGE_SECTION_HACKERRANK/conditional-statements-in-c/conditional-statements-in-c.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* conditional-statements-in-c.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/15 03:17:49 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 03:26:35 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | #include 14 | #include 15 | 16 | void ft_putstr(char *str) 17 | { 18 | while (*str) 19 | write(1, str++, 1); 20 | } 21 | 22 | int main(int argc, char **argv) 23 | { 24 | (void) argc; 25 | (void) argv; 26 | int n; 27 | 28 | scanf("%d", &n); 29 | if (n == 1) 30 | ft_putstr("one"); 31 | else if (n == 2) 32 | ft_putstr("two"); 33 | else if (n == 3) 34 | ft_putstr("three"); 35 | else if (n == 4) 36 | ft_putstr("four"); 37 | else if (n == 5) 38 | ft_putstr("five"); 39 | else if (n == 6) 40 | ft_putstr("six"); 41 | else if (n == 7) 42 | ft_putstr("seven"); 43 | else if (n == 8) 44 | ft_putstr("eight"); 45 | else if (n == 9) 46 | ft_putstr("nine"); 47 | else 48 | ft_putstr("Greater than 9"); 49 | return (EXIT_SUCCESS); 50 | } -------------------------------------------------------------------------------- /C_LANGUAGE_SECTION_HACKERRANK/for-loop-in-c/for-loop-in-c.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* for-loop-c.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/15 07:07:27 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 07:26:17 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putchar(char *str) 18 | { 19 | while (*str) 20 | write(1, str++, 1); 21 | } 22 | 23 | int main(int argc, char **argv) 24 | { 25 | (void) argc; 26 | (void) argv; 27 | int a; 28 | int b; 29 | int x; 30 | 31 | scanf("%d\n%d", &a, &b); 32 | x = a; 33 | while (x <= b) 34 | { 35 | if (x <= 9) 36 | { 37 | if (x == 1) 38 | ft_putchar("one\n"); 39 | else if (x == 2) 40 | ft_putchar("two\n"); 41 | else if (x == 3) 42 | ft_putchar("three\n"); 43 | else if (x == 4) 44 | ft_putchar("four\n"); 45 | else if (x == 5) 46 | ft_putchar("five\n"); 47 | else if (x == 6) 48 | ft_putchar("six\n"); 49 | else if (x == 7) 50 | ft_putchar("seven\n"); 51 | else if (x == 8) 52 | ft_putchar("eight\n"); 53 | else if (x == 9) 54 | ft_putchar("nine\n"); 55 | } 56 | else if (x > 9) 57 | { 58 | if (x % 2 == 0) 59 | ft_putchar("even\n"); 60 | else 61 | ft_putchar("odd\n"); 62 | } 63 | x++; 64 | } 65 | return (EXIT_SUCCESS); 66 | } 67 | 68 | -------------------------------------------------------------------------------- /C_LANGUAGE_SECTION_HACKERRANK/functions-in-c/functions-in-c.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* functions-in-c.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/14 23:45:51 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 00:19:12 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putnbr(int n) 18 | { 19 | long nbr; 20 | 21 | nbr = (long) n; 22 | if (nbr < 0) 23 | { 24 | nbr = -nbr; 25 | write(1, "-", 1); 26 | } 27 | if (nbr > 9) 28 | ft_putnbr(nbr / 10); 29 | write(1, &"0123456789"[nbr % 10], 1); 30 | } 31 | 32 | int ft_max_of_four(int a, int b, int c, int d) 33 | { 34 | int max; 35 | 36 | max = a; 37 | if (b > max) 38 | max = b; 39 | if (c > max) 40 | max = c; 41 | if (d > max) 42 | max = d; 43 | return (max); 44 | } 45 | 46 | int main(int argc, char **argv) 47 | { 48 | (void) argc; 49 | (void) argv; 50 | 51 | int a; 52 | int b; 53 | int c; 54 | int d; 55 | 56 | scanf("%d %d %d %d", &a, &b, &c, &d); 57 | int answer = ft_max_of_four(a, b, c, d); 58 | ft_putnbr(answer); 59 | return (EXIT_SUCCESS); 60 | } 61 | -------------------------------------------------------------------------------- /C_LANGUAGE_SECTION_HACKERRANK/hello-world-c/hello-world-c.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* hello_c.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/14 20:50:42 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/14 21:16:10 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | #define MAX 100 17 | 18 | void ft_putstr(char *str) 19 | { 20 | while (*str) 21 | write(1, str++, 1); 22 | } 23 | 24 | int main(int argc, char **argv) 25 | { 26 | (void) argc; 27 | (void) argv; 28 | char str[MAX]; 29 | 30 | fgets(str, MAX, stdin); 31 | ft_putstr("Hello, World!\n"); 32 | ft_putstr(str); 33 | return (EXIT_SUCCESS); 34 | } 35 | -------------------------------------------------------------------------------- /C_LANGUAGE_SECTION_HACKERRANK/playing-with-characters/playing-with-characters.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* Playing_With_Characters.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/14 21:17:42 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/14 21:48:41 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | #define MAX 100 17 | 18 | void ft_putchar(char c) 19 | { 20 | write(1, &c, 1); 21 | } 22 | 23 | void ft_putstr(char *str) 24 | { 25 | while (*str) 26 | write(1, str++, 1); 27 | } 28 | 29 | int main(int argc, char **argv) 30 | { 31 | (void) argc; 32 | (void) argv; 33 | char ch; 34 | char str[100]; 35 | char sen[100]; 36 | 37 | scanf("%c", &ch); 38 | ft_putchar(ch); 39 | ft_putchar('\n'); 40 | scanf("%s", str); 41 | ft_putstr(str); 42 | ft_putchar('\n'); 43 | scanf("\n"); 44 | fgets(sen, MAX, stdin); 45 | ft_putstr(sen); 46 | return (EXIT_SUCCESS); 47 | } 48 | -------------------------------------------------------------------------------- /C_LANGUAGE_SECTION_HACKERRANK/pointer-in-c/pointer-in-c.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* pointer-in-c.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/15 01:08:54 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 01:20:39 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putnbr(int n) 18 | { 19 | long nbr; 20 | 21 | nbr = (long) n; 22 | if (nbr < 0) 23 | { 24 | nbr = -nbr; 25 | write(1, "-", 1); 26 | } 27 | if (nbr > 9) 28 | ft_putnbr(nbr / 10); 29 | write(1, &"0123456789"[nbr % 10], 1); 30 | } 31 | 32 | void ft_update(int *a, int *b) 33 | { 34 | int add; 35 | int diff; 36 | 37 | add = *a + *b; 38 | if (*a < *b) 39 | { 40 | diff = *a - *b; 41 | *b = -diff; 42 | } 43 | else 44 | { 45 | diff = *a - *b; 46 | *b = diff; 47 | } 48 | *a = add; 49 | } 50 | 51 | int main(int argc, char **argv) 52 | { 53 | (void) argc; 54 | (void) argv; 55 | int a; 56 | int b; 57 | int *pa; 58 | int *pb; 59 | 60 | pa = &a; 61 | pb = &b; 62 | scanf("%d %d", &a, &b); 63 | ft_update(pa, pb); 64 | ft_putnbr(a); 65 | write(1, "\n", 1); 66 | ft_putnbr(b); 67 | return (EXIT_SUCCESS); 68 | } 69 | -------------------------------------------------------------------------------- /C_LANGUAGE_SECTION_HACKERRANK/sum-numbers-c/sum-numbers-c.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* sum-numbers.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/14 22:19:16 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/14 23:13:09 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putnbr(int n) 18 | { 19 | long nbr; 20 | 21 | nbr = (long) n; 22 | if (nbr < 0) 23 | { 24 | nbr = -nbr; 25 | write(1, "-", 1); 26 | } 27 | if (nbr > 9) 28 | ft_putnbr(nbr / 10); 29 | write(1, &"0123456789"[nbr % 10], 1); 30 | } 31 | 32 | int main(int argc, char **argv) 33 | { 34 | (void) argc; 35 | (void) argv; 36 | int i1; 37 | int i2; 38 | float f1; 39 | float f2; 40 | 41 | scanf("%d", &i1); 42 | scanf("%d", &i2); 43 | ft_putnbr(i1 + i2); 44 | write(1, " ", 1); 45 | ft_putnbr(i1 - i2); 46 | scanf("%f", &f1); 47 | scanf("%f", &f2); 48 | printf("%.1f ", f1 + f2); 49 | printf("%.1f", f1 - f2); 50 | return (EXIT_SUCCESS); 51 | } 52 | -------------------------------------------------------------------------------- /C_LANGUAGE_SECTION_HACKERRANK/sum-of-digits-of-a-five-digit-number/sum-of-digits-of-a-five-digit-number.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* sum-of-digits-of-a-five-digit-number.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/15 17:52:15 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 18:21:10 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putnbr(int n) 18 | { 19 | long nbr; 20 | 21 | nbr = (long) n; 22 | if (nbr < 0) 23 | { 24 | nbr = -nbr; 25 | write(1, "-", 1); 26 | } 27 | if (nbr > 9) 28 | ft_putnbr(nbr / 10); 29 | write(1,&"0123456789"[nbr % 10], 1); 30 | } 31 | 32 | int main(int argc, char **argv) 33 | { 34 | (void) argc; 35 | (void) argv; 36 | int j; 37 | int sum; 38 | int i; 39 | 40 | sum = 0; 41 | j = 0; 42 | scanf("%d", &i); 43 | while (j < 5) 44 | { 45 | sum += i % 10; 46 | i = i / 10; 47 | ft_putnbr(sum); 48 | write(1, "\n", 1); 49 | j++; 50 | } 51 | return (EXIT_SUCCESS); 52 | } 53 | -------------------------------------------------------------------------------- /DONTREADME.md: -------------------------------------------------------------------------------- 1 | # 🤔 2 | ![pp](https://cdn.lowgif.com/small/451497b85de2a33e-pin-by-lennie-andersson-on-reaktionsgiffar-pinterest-gifs-meme.gif) -------------------------------------------------------------------------------- /JAVA_LANGUAGE_SECTION_HACKERRANK/Java_stdin_and_stdout_1/Java_stdin_and_stdout_1.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Solution 4 | { 5 | public static void main(String[] args) 6 | { 7 | Scanner scan = new Scanner(System.in); 8 | int a = scan.nextInt(); 9 | int b = scan.nextInt(); 10 | int c = scan.nextInt(); 11 | 12 | System.out.println(a); 13 | System.out.println(b); 14 | System.out.println(c); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JAVA_LANGUAGE_SECTION_HACKERRANK/Welcome_to_java/welcome_to_java.java: -------------------------------------------------------------------------------- 1 | public class Solution 2 | { 3 | public static void main(String[] args) 4 | { 5 | System.out.println("Hello, World."); 6 | System.out.println("Hello, Java."); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /JAVA_LANGUAGE_SECTION_HACKERRANK/java_if_else/java_if_else.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.math.*; 3 | import java.security.*; 4 | import java.text.*; 5 | import java.util.*; 6 | import java.util.concurrent.*; 7 | import java.util.regex.*; 8 | 9 | public class Solution 10 | { 11 | private static final Scanner scanner = new Scanner(System.in); 12 | 13 | public static void main(String[] args) 14 | { 15 | int N = scanner.nextInt(); 16 | scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); 17 | 18 | if (N % 2 == 1) 19 | System.out.println("Weird"); 20 | else if ((N % 2 == 0) && (N >= 2 && N <= 5)) 21 | System.out.println("Not Weird"); 22 | else if ((N % 2 == 0) && (N >= 6 && N <= 20)) 23 | System.out.println("Weird"); 24 | else 25 | System.out.println("Not Weird"); 26 | scanner.close(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /JAVA_LANGUAGE_SECTION_HACKERRANK/java_loops_1/java_loops_1.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.math.*; 3 | import java.security.*; 4 | import java.text.*; 5 | import java.util.*; 6 | import java.util.concurrent.*; 7 | import java.util.regex.*; 8 | 9 | 10 | 11 | public class Solution 12 | { 13 | public static void main(String[] args) throws IOException 14 | { 15 | int i; 16 | 17 | i = 1; 18 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); 19 | 20 | int N = Integer.parseInt(bufferedReader.readLine().trim()); 21 | 22 | bufferedReader.close(); 23 | while (i <= 10) 24 | { 25 | System.out.print(N); 26 | System.out.print(" x "); 27 | System.out.print(i); 28 | System.out.print(" = "); 29 | System.out.print(N * i); 30 | System.out.println(); 31 | i++; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /JAVA_LANGUAGE_SECTION_HACKERRANK/java_loops_2/java_loops_2.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | 4 | class Solution 5 | { 6 | public static void main(String []argh) 7 | { 8 | int i; 9 | 10 | i = 0; 11 | Scanner in = new Scanner(System.in); 12 | int t = in.nextInt(); 13 | while (i < t) 14 | { 15 | int a = in.nextInt(); 16 | int b = in.nextInt(); 17 | int n = in.nextInt(); 18 | int j = 0; 19 | int res = a; 20 | while (j < n) 21 | { 22 | res += Math.pow(2, j) *b; 23 | System.out.print(res); 24 | System.out.print(" "); 25 | j++; 26 | } 27 | System.out.println(); 28 | i++; 29 | } 30 | in.close(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /JAVA_LANGUAGE_SECTION_HACKERRANK/java_output_formatting/java_output_formatting.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Solution 4 | { 5 | public static void main(String[] args) 6 | { 7 | int i; 8 | 9 | i = 0; 10 | Scanner sc = new Scanner(System.in); 11 | System.out.println("================================"); 12 | while(i < 3) 13 | { 14 | String s1 = sc.next(); 15 | int x = sc.nextInt(); 16 | System.out.printf("%-15s%03d%n", s1, x); 17 | i++; 18 | } 19 | System.out.println("================================"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /JAVA_LANGUAGE_SECTION_HACKERRANK/java_stdin_and_stdout_2/java_stdin_and_stdout_2.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Solution 4 | { 5 | public static void main(Strings[] args) 6 | { 7 | Scanner scan = new Scanner(System.in); 8 | int i = scan.nextInt(); 9 | double d = scan.nextDouble(); 10 | scan.nextLine(); 11 | String s = scan.nextLine(); 12 | scan.close(); 13 | System.out.println("String: " + s); 14 | System.out.println("Double: " + d); 15 | System.out.prinln("Int: " + i); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MATHEMATICS/army-game/army-game.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* army-game.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/16 00:32:18 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/16 00:34:53 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putnbr(int nb) 18 | { 19 | if (nb > 9) 20 | ft_putnbr(nb / 10); 21 | write(1, &"0123456789"[nb % 10], 1); 22 | } 23 | 24 | int main(int argc, char **argv) 25 | { 26 | (void) argc; 27 | (void) argv; 28 | int n; 29 | int m; 30 | 31 | scanf("%d %d", &m, &n); 32 | if (n <= 2 && m <= 2) 33 | ft_putnbr(1); 34 | else 35 | ft_putnbr(((n % 2) + n) * ((m % 2) + m) /4); 36 | return (EXIT_SUCCESS); 37 | } 38 | -------------------------------------------------------------------------------- /MATHEMATICS/find-the-point/find-the-point.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* find-the-point.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/15 02:00:45 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 03:03:41 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | int main(int argc, char **argv) 18 | { 19 | (void) argc; 20 | (void) argv; 21 | int n; 22 | int px; 23 | int py; 24 | int qx; 25 | int qy; 26 | int rx; 27 | int ry; 28 | 29 | scanf("%d", &n); 30 | while (n--) 31 | { 32 | scanf("%d %d %d %d", &px, &py, &qx, &qy); 33 | rx = 2 * px - qx; 34 | ry = 2 * py - qy; 35 | printf("%d %d", rx, ry); 36 | } 37 | return (EXIT_SUCCESS); 38 | } 39 | -------------------------------------------------------------------------------- /MATHEMATICS/halloween-party/halloween-party.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* halloween.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/02/17 18:16:17 by ablaamim #+# #+# */ 9 | /* Updated: 2022/02/17 18:26:36 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | #include 14 | #include 15 | 16 | void putnbr(long nb) 17 | { 18 | if (nb > 9) 19 | putnbr(nb / 10); 20 | write(1, &"0123456789"[nb % 10], 1); 21 | } 22 | 23 | int main(int argc, char **argv) 24 | { 25 | (void) argc; 26 | (void) argv; 27 | long k; 28 | long i; 29 | 30 | scanf("%ld", &k); 31 | while (k--) 32 | { 33 | scanf("%ld\n", &i); 34 | putnbr(((i / 2) * ((i + 1) / 2))); 35 | write(1, "\n", 1); 36 | } 37 | return (EXIT_SUCCESS); 38 | } 39 | -------------------------------------------------------------------------------- /MATHEMATICS/handshake/handshake.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* handshake.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/15 21:57:18 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 22:46:30 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putnbr(int nb) 18 | { 19 | if (nb > 9) 20 | ft_putnbr(nb / 10); 21 | write(1, &"0123456789"[nb % 10], 1); 22 | } 23 | 24 | int main(int argc, char **argv) 25 | { 26 | (void) argc; 27 | (void) argv; 28 | int t; 29 | int n; 30 | 31 | scanf("%d", &t); 32 | while (t--) 33 | { 34 | scanf("%d", &n); 35 | if (n == 1) 36 | { 37 | ft_putnbr(0); 38 | write(1, "\n", 1); 39 | } 40 | else 41 | { 42 | n = n * (n - 1) / 2; 43 | ft_putnbr(n); 44 | write(1, "\n", 1); 45 | } 46 | } 47 | return (EXIT_SUCCESS); 48 | } 49 | -------------------------------------------------------------------------------- /MATHEMATICS/maximum-draws/maximum-draws.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* maximum-draws.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/15 03:36:44 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 03:48:33 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putnbr(int n) 18 | { 19 | long nbr; 20 | 21 | nbr = (long) n; 22 | if (nbr < 0) 23 | { 24 | nbr = -nbr; 25 | write(1, "-", 1); 26 | } 27 | if (nbr > 9) 28 | ft_putnbr(nbr / 10); 29 | write(1, &"0123456789"[nbr % 10], 1); 30 | } 31 | 32 | int main(int argc, char **argv) 33 | { 34 | (void) argc; 35 | (void) argv; 36 | int t; 37 | int n; 38 | 39 | scanf("%d", &t); 40 | while (t--) 41 | { 42 | scanf("%d", &n); 43 | ft_putnbr(n + 1); 44 | write(1, "\n", 1); 45 | } 46 | return (EXIT_SUCCESS); 47 | } 48 | -------------------------------------------------------------------------------- /MATHEMATICS/minimum-height-triangle/minimum-height-triangle.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* minimum-height-triangle.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/02/17 18:09:36 by ablaamim #+# #+# */ 9 | /* Updated: 2022/02/17 18:14:35 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void putnbr(int n) 18 | { 19 | if (n > 9) 20 | putnbr(n / 10); 21 | write(1, &"0123456789"[n % 10], 1); 22 | } 23 | 24 | int main(int argc, char **argv) 25 | { 26 | (void) argc; 27 | (void) argv; 28 | int a; 29 | int b; 30 | int h; 31 | 32 | scanf("%d %d", &b, &a); 33 | h = (((a * 2) + (b - 1)) / b); 34 | putnbr(h); 35 | return (EXIT_SUCCESS); 36 | } 37 | -------------------------------------------------------------------------------- /Mathematics/army-game/army-game.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* army-game.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/16 00:32:18 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/16 00:34:53 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putnbr(int nb) 18 | { 19 | if (nb > 9) 20 | ft_putnbr(nb / 10); 21 | write(1, &"0123456789"[nb % 10], 1); 22 | } 23 | 24 | int main(int argc, char **argv) 25 | { 26 | (void) argc; 27 | (void) argv; 28 | int n; 29 | int m; 30 | 31 | scanf("%d %d", &m, &n); 32 | if (n <= 2 && m <= 2) 33 | ft_putnbr(1); 34 | else 35 | ft_putnbr(((n % 2) + n) * ((m % 2) + m) /4); 36 | return (EXIT_SUCCESS); 37 | } 38 | -------------------------------------------------------------------------------- /Mathematics/find-the-point/find-the-point.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* find-the-point.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/15 02:00:45 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 03:03:41 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | int main(int argc, char **argv) 18 | { 19 | (void) argc; 20 | (void) argv; 21 | int n; 22 | int px; 23 | int py; 24 | int qx; 25 | int qy; 26 | int rx; 27 | int ry; 28 | 29 | scanf("%d", &n); 30 | while (n--) 31 | { 32 | scanf("%d %d %d %d", &px, &py, &qx, &qy); 33 | rx = 2 * px - qx; 34 | ry = 2 * py - qy; 35 | printf("%d %d", rx, ry); 36 | } 37 | return (EXIT_SUCCESS); 38 | } 39 | -------------------------------------------------------------------------------- /Mathematics/halloween-party/halloween-party.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* halloween.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/02/17 18:16:17 by ablaamim #+# #+# */ 9 | /* Updated: 2022/02/17 18:26:36 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | #include 13 | #include 14 | #include 15 | 16 | void putnbr(long nb) 17 | { 18 | if (nb > 9) 19 | putnbr(nb / 10); 20 | write(1, &"0123456789"[nb % 10], 1); 21 | } 22 | 23 | int main(int argc, char **argv) 24 | { 25 | (void) argc; 26 | (void) argv; 27 | long k; 28 | long i; 29 | 30 | scanf("%ld", &k); 31 | while (k--) 32 | { 33 | scanf("%ld\n", &i); 34 | putnbr(((i / 2) * ((i + 1) / 2))); 35 | write(1, "\n", 1); 36 | } 37 | return (EXIT_SUCCESS); 38 | } 39 | -------------------------------------------------------------------------------- /Mathematics/handshake/handshake.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* handshake.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/15 21:57:18 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 22:46:30 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putnbr(int nb) 18 | { 19 | if (nb > 9) 20 | ft_putnbr(nb / 10); 21 | write(1, &"0123456789"[nb % 10], 1); 22 | } 23 | 24 | int main(int argc, char **argv) 25 | { 26 | (void) argc; 27 | (void) argv; 28 | int t; 29 | int n; 30 | 31 | scanf("%d", &t); 32 | while (t--) 33 | { 34 | scanf("%d", &n); 35 | if (n == 1) 36 | { 37 | ft_putnbr(0); 38 | write(1, "\n", 1); 39 | } 40 | else 41 | { 42 | n = n * (n - 1) / 2; 43 | ft_putnbr(n); 44 | write(1, "\n", 1); 45 | } 46 | } 47 | return (EXIT_SUCCESS); 48 | } 49 | -------------------------------------------------------------------------------- /Mathematics/maximum-draws/maximum-draws.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* maximum-draws.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/01/15 03:36:44 by ablaamim #+# #+# */ 9 | /* Updated: 2022/01/15 03:48:33 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void ft_putnbr(int n) 18 | { 19 | long nbr; 20 | 21 | nbr = (long) n; 22 | if (nbr < 0) 23 | { 24 | nbr = -nbr; 25 | write(1, "-", 1); 26 | } 27 | if (nbr > 9) 28 | ft_putnbr(nbr / 10); 29 | write(1, &"0123456789"[nbr % 10], 1); 30 | } 31 | 32 | int main(int argc, char **argv) 33 | { 34 | (void) argc; 35 | (void) argv; 36 | int t; 37 | int n; 38 | 39 | scanf("%d", &t); 40 | while (t--) 41 | { 42 | scanf("%d", &n); 43 | ft_putnbr(n + 1); 44 | write(1, "\n", 1); 45 | } 46 | return (EXIT_SUCCESS); 47 | } 48 | -------------------------------------------------------------------------------- /Mathematics/minimum-height-triangle/minimum-height-triangle.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************** */ 2 | /* */ 3 | /* ::: :::::::: */ 4 | /* minimum-height-triangle.c :+: :+: :+: */ 5 | /* +:+ +:+ +:+ */ 6 | /* By: ablaamim +#+ +:+ +#+ */ 7 | /* +#+#+#+#+#+ +#+ */ 8 | /* Created: 2022/02/17 18:09:36 by ablaamim #+# #+# */ 9 | /* Updated: 2022/02/17 18:14:35 by ablaamim ### ########.fr */ 10 | /* */ 11 | /* ************************************************************************** */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | void putnbr(int n) 18 | { 19 | if (n > 9) 20 | putnbr(n / 10); 21 | write(1, &"0123456789"[n % 10], 1); 22 | } 23 | 24 | int main(int argc, char **argv) 25 | { 26 | (void) argc; 27 | (void) argv; 28 | int a; 29 | int b; 30 | int h; 31 | 32 | scanf("%d %d", &b, &a); 33 | h = (((a * 2) + (b - 1)) / b); 34 | putnbr(h); 35 | return (EXIT_SUCCESS); 36 | } 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HackerRank 2 | [![My hackerrank profile](images/HackerRankLogo.svg)](https://www.hackerrank.com/ablaamim) 3 | Solutions to some problems on Hackerrank. 4 | 5 | * [LANGUAGE PROFICIENCY](#language-proficiency) 6 | * [C](#c) 7 | * [JAVA](#java) 8 | * [Mathematics](#Mathematics) 9 | 10 | --- 11 | 12 | # Mathematics 13 | 14 | | Subdomain | Difficulty | Challenge | Solution | 15 | |--- |--- |--- |--- | 16 | | Fundamentals | Easy | [find the point](https://www.hackerrank.com/challenges/find-point/problem?isFullScreen=true) | [find-the-point.c](Mathematics/find-the-point/find-the-point.c) | 17 | | Fundamentals | Easy | [maximum draws](https://www.hackerrank.com/challenges/maximum-draws/problem?isFullScreen=true) | [maximum-draws.c](Mathematics/maximum-draws/maximum-draws.c) | 18 | | Fundamentals | Easy | [handshake](https://www.hackerrank.com/challenges/handshake/problem?isFullScreen=true) | [handshake.c](Mathematics/handshake/handshake.c) | 19 | | Fundamentals | Easy | [army-game](https://www.hackerrank.com/challenges/game-with-cells/problem?isFullScreen=true) | [army-game.c](Mathematics/army-game/army-game.c) | 20 | | Fundamentals | Easy | [minimum-height-triangle](https://www.hackerrank.com/challenges/lowest-triangle/problem?isFullScreen=true) | [minimum-height-triangle.c](Mathematics/minimum-height-triangle/minimum-height-triangle.c) | 21 | | Fundamentals | Easy | [halloween-party](https://www.hackerrank.com/challenges/halloween-party/problem?isFullScreen=true) | [halloween-party.c](Mathematics/halloween-party/halloween-party.c) | 22 | 23 | --- 24 | 25 | # c 26 | 27 | | Subdomain | Difficulty | Challenge | Solution | 28 | |--- |--- |--- |--- | 29 | | Introduction | Easy | ["Hello World!" in C](https://www.hackerrank.com/challenges/hello-world-c/problem) | [hello-world-c.c](C_LANGUAGE_SECTION_HACKERRANK/hello-world-c/hello-world-c.c) | 30 | | Introduction | Easy | [Playing With Characters](https://www.hackerrank.com/challenges/playing-with-characters/problem) | [playing-with-characters.c](C_LANGUAGE_SECTION_HACKERRANK/playing-with-characters/playing-with-characters.c)| 31 | | Introduction | Easy | [Sum and Difference of Two Numbers](https://www.hackerrank.com/challenges/sum-numbers-c/problem) | [sum-numbers-c.c](C_LANGUAGE_SECTION_HACKERRANK/sum-numbers-c/sum-numbers-c.c)| 32 | | Introduction | Easy | [Functions in C](https://www.hackerrank.com/challenges/functions-in-c/problem) | [functions-in-c.c](C_LANGUAGE_SECTION_HACKERRANK/functions-in-c/functions-in-c.c)| 33 | | Introduction | Easy | [Pointers in C](https://www.hackerrank.com/challenges/pointer-in-c/problem) | [pointer-in-c.c](C_LANGUAGE_SECTION_HACKERRANK/pointer-in-c/pointer-in-c.c)| 34 | | Conditionals and Loops | Easy | [Conditional Statements in C](https://www.hackerrank.com/challenges/conditional-statements-in-c/problem) | [conditional-statements-in-c.c](C_LANGUAGE_SECTION_HACKERRANK/conditional-statements-in-c/conditional-statements-in-c.c)| 35 | | Conditionals and Loops | Easy | [For Loop in C](https://www.hackerrank.com/challenges/for-loop-in-c/problem) | [for-loop-in-c.c](C_LANGUAGE_SECTION_HACKERRANK/for-loop-in-c/for-loop-in-c.c)| 36 | | Conditionals and Loops | Easy | [Sum of Digits of a Five Digit Number](https://www.hackerrank.com/challenges/sum-of-digits-of-a-five-digit-number/problem)|[sum-of-digits-of-a-five-digit-number.c](C_LANGUAGE_SECTION_HACKERRANK/sum-of-digits-of-a-five-digit-number/sum-of-digits-of-a-five-digit-number.c)| 37 | | Conditionals and Loops | Easy | [Bitwise Operators](https://www.hackerrank.com/challenges/bitwise-operators-in-c/problem) | [bitwise-operators-in-c.c](C_LANGUAGE_SECTION_HACKERRANK/bitwise-operators-in-c/bitwise-operators-in-c.c)| 38 | | Conditionals and Loops | Medium | [Printing Pattern using Loops](https://www.hackerrank.com/challenges/printing-pattern-2/problem) | [printing-pattern-2.c](C_LANGUAGE_SECTION_HACKERRANK/printing-pattern-2/printing-pattern-2.c)| 39 | | Arrays and Strings | Medium | [1D Arrays in C](https://www.hackerrank.com/challenges/1d-arrays-in-c/problem) | [1d-arrays-in-c.c](C_LANGUAGE_SECTION_HACKERRANK/1d-arrays-in-c/1d-arrays-in-c.c)| 40 | | Arrays and Strings | Medium | [Array Reversal](https://www.hackerrank.com/challenges/reverse-array-c/problem) | [reverse-array-c.c](C_LANGUAGE_SECTION_HACKERRANK/reverse-array-c/reverse-array-c.c)| 41 | | Arrays and Strings | Medium| [Printing Tokens](https://www.hackerrank.com/challenges/printing-tokens-/problem) | [printing-tokens.c](C_LANGUAGE_SECTION_HACKERRANK/printing-tokens/printing-tokens.c)| 42 | | Arrays and Strings| Medium | [Digit Frequency](https://www.hackerrank.com/challenges/frequency-of-digits-1/problem) | [frequency-of-digits-1.c](C_LANGUAGE_SECTION_HACKERRANK/frequency-of-digits-1/frequency-of-digits-1.c)| 43 | | Arrays and Strings | Medium | [Dynamic Array in C](https://www.hackerrank.com/challenges/dynamic-array-in-c/problem) | [dynamic-array-in-c.c](C_LANGUAGE_SECTION_HACKERRANK/dynamic-array-in-c/dynamic-array-in-c.c)| 44 | | Functions | Easy| [Calculate the Nth term](https://www.hackerrank.com/challenges/recursion-in-c/problem) | [recursion-in-c.c](C_LANGUAGE_SECTION_HACKERRANK/recursion-in-c/recursion-in-c.c)| 45 | | Functions | Easy| [Students Marks Sum](https://www.hackerrank.com/challenges/students-marks-sum/problem) | [students-marks-sum.c](C_LANGUAGE_SECTION_HACKERRANK/students-marks-sum/students-marks-sum.c)| 46 | | Functions | Medium | [Permutations of Strings](https://www.hackerrank.com/challenges/permutations-of-strings/problem) | [permutations-of-strings.c](C_LANGUAGE_SECTION_HACKERRANK/permutations-of-strings/permutations-of-strings.c)| 47 | | Functions | Medium | [Variadic functions in C](https://www.hackerrank.com/challenges/variadic-functions-in-c/problem) | [variadic-functions-in-c.c](C_LANGUAGE_SECTION_HACKERRANK/variadic-functions-in-c/variadic-functions-in-c.c)| 48 | | Functions | Hard |[Sorting Array of Strings](https://www.hackerrank.com/challenges/sorting-array-of-strings/problem) | [sorting-array-of-strings.c](C_LANGUAGE_SECTION_HACKERRANK/sorting-array-of-strings/sorting-array-of-strings.c)| 49 | | Structs and Enums | Easy| [Boxes through a Tunnel](https://www.hackerrank.com/challenges/too-high-boxes/problem) | [too-high-boxes.c](C_LANGUAGE_SECTION_HACKERRANK/too-high-boxes/too-high-boxes.c)| 50 | | Structs and Enums | Medium |[Small Triangles, Large Triangles](https://www.hackerrank.com/challenges/small-triangles-large-triangles/problem) | [small-triangles-large-triangles.c](C_LANGUAGE_SECTION_HACKERRANK/small-triangles-large-triangles/small-triangles-large-triangles.c)| 51 | | Structs and Enums | Hard |[Post Transition](https://www.hackerrank.com/challenges/post-transition/problem) | [post-transition.c](C_LANGUAGE_SECTION_HACKERRANK/post-transition/post-transition.c) | 52 | 53 | --- 54 | 55 | # java 56 | 57 | | Subdomain | Difficulty | Challenge | Solution | 58 | |--- |--- |--- |--- | 59 | | Introduction | Easy | [Welcome to Java!](https://www.hackerrank.com/challenges/welcome-to-java/problem?isFullScreen=true) | [Welcome to Java!](https://github.com/ablaamim/Problem_Solving/blob/master/JAVA_LANGUAGE_SECTION_HACKERRANK/Welcome_to_java/welcome_to_java.java) | 60 | | Introduction | Easy | [Java Stdin and Stdout I](https://www.hackerrank.com/challenges/java-stdin-and-stdout-1/problem?isFullScreen=true) | [Java Stding and Stdout I](https://github.com/ablaamim/Problem_Solving/blob/master/JAVA_LANGUAGE_SECTION_HACKERRANK/Java_stdin_and_stdout_1/Java_stdin_and_stdout_1.java) | 61 | | Introduction | Easy | [Java if-Else](https://www.hackerrank.com/challenges/java-if-else/problem?isFullScreen=true) | [Java if-Else](https://github.com/ablaamim/Problem_Solving/blob/master/JAVA_LANGUAGE_SECTION_HACKERRANK/java_if_else/java_if_else.java) | 62 | | Introduction | Easy | [Java Stdin and Stdout II](https://www.hackerrank.com/challenges/java-stdin-stdout/problem?isFullScreen=true) | [Java Stdin and Stdout II](https://github.com/ablaamim/Problem_Solving/blob/master/JAVA_LANGUAGE_SECTION_HACKERRANK/java_stdin_and_stdout_2/java_stdin_and_stdout_2.java) | 63 | | Introduction | Easy | [Java output formatting](https://www.hackerrank.com/challenges/java-output-formatting/problem?isFullScreen=true) | [Java output formatting](https://github.com/ablaamim/Problem_Solving/tree/master/JAVA_LANGUAGE_SECTION_HACKERRANK/java_output_formatting/java_output_formatting.java) | 64 | 65 | --- 66 | -------------------------------------------------------------------------------- /images/HackerRankLogo.svg: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------