Skip to content

Commit b6a7e09

Browse files
committed
initial commit
0 parents  commit b6a7e09

File tree

73 files changed

+1350
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1350
-0
lines changed

Diff for: 0-helloworld/main.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"bufio"
6+
"os"
7+
)
8+
9+
func main(){
10+
reader := bufio.NewReader(os.Stdin)
11+
var message string
12+
message, _ = reader.ReadString('\n')
13+
14+
fmt.Printf("Hello, World.\n%s", message)
15+
}

Diff for: 1-datatypes/main.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
"fmt"
6+
"os"
7+
)
8+
9+
func main() {
10+
var i uint64 = 4
11+
var d float64 = 4.0
12+
var s string = "HackerRank "
13+
14+
scanner := bufio.NewScanner(os.Stdin)
15+
16+
var i2 uint64
17+
var d2 float64
18+
var s2 string
19+
20+
fmt.Scan(&i2)
21+
fmt.Scan(&d2)
22+
scanner.Scan()
23+
s2 = scanner.Text()
24+
25+
fmt.Println(i + i2)
26+
fmt.Printf("%.1f\n", d+d2)
27+
fmt.Printf("%s%s", s, s2)
28+
}

Diff for: 10-binarynumbers/main.go

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
func main() {
8+
var n, reminder, count, max int
9+
10+
fmt.Scan(&n)
11+
12+
for n > 0 {
13+
reminder = n % 2
14+
if reminder == 1 {
15+
count++
16+
} else {
17+
count = 0
18+
}
19+
if count > max {
20+
max = count
21+
}
22+
n /= 2
23+
}
24+
fmt.Println(max)
25+
26+
}

Diff for: 11-2darrays/main.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
var a [6][6]int
7+
var max int
8+
for i := range a {
9+
for j := range a[i] {
10+
fmt.Scan(&a[i][j])
11+
}
12+
}
13+
14+
for i := 0; i < 4; i++ {
15+
for j := 0; j < 4; j++ {
16+
sumHourGlass := a[i][j] + a[i][j+1] + a[i][j+2] + a[i+1][j+1] + a[i+2][j] + a[i+2][j+1] + a[i+2][j+2]
17+
if (i == 0 && j == 0) || sumHourGlass > max {
18+
max = sumHourGlass
19+
}
20+
}
21+
}
22+
fmt.Println(max)
23+
}

Diff for: 12-inheritence/.classpath

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9">
4+
<attributes>
5+
<attribute name="module" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="src" path="src"/>
9+
<classpathentry kind="output" path="bin"/>
10+
</classpath>

Diff for: 12-inheritence/.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>12-Inheritance</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

Diff for: 12-inheritence/.settings/org.eclipse.jdt.core.prefs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=9
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=9
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=9

Diff for: 12-inheritence/bin/Person.class

970 Bytes
Binary file not shown.

Diff for: 12-inheritence/bin/Student.class

795 Bytes
Binary file not shown.

Diff for: 12-inheritence/src/Person.java

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.util.*;
2+
3+
class Person {
4+
protected String firstName;
5+
protected String lastName;
6+
protected int idNumber;
7+
8+
// Constructor
9+
Person(String firstName, String lastName, int identification){
10+
this.firstName = firstName;
11+
this.lastName = lastName;
12+
this.idNumber = identification;
13+
}
14+
15+
// Print person data
16+
public void printPerson(){
17+
System.out.println(
18+
"Name: " + lastName + ", " + firstName
19+
+ "\nID: " + idNumber);
20+
}
21+
22+
}

Diff for: 12-inheritence/src/Student.java

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
class Student extends Person{
2+
private int[] testScores;
3+
4+
5+
/*
6+
* Class Constructor
7+
*
8+
* @param firstName - A string denoting the Person's first name.
9+
* @param lastName - A string denoting the Person's last name.
10+
* @param id - An integer denoting the Person's ID number.
11+
* @param scores - An array of integers denoting the Person's test scores.
12+
*/
13+
// Write your constructor here
14+
Student(String firstName, String lastName, int id, int[] scores){
15+
super(firstName,lastName,id);
16+
testScores = scores;
17+
}
18+
/*
19+
* Method Name: calculate
20+
* @return A character denoting the grade.
21+
*/
22+
// Write your method here
23+
char calculate() {
24+
int sum = 0;
25+
int average;
26+
for(int i = 0; i < testScores.length;i++) {
27+
sum += testScores[i];
28+
}
29+
average = sum / testScores.length;
30+
if(average >= 90)
31+
return 'O';
32+
else if(average >= 80)
33+
return 'E';
34+
else if(average >= 70)
35+
return 'A';
36+
else if(average >= 55)
37+
return 'P';
38+
else if(average >= 40)
39+
return 'D';
40+
41+
return 'T';
42+
}
43+
}

Diff for: 13-abstractclasses/.classpath

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9">
4+
<attributes>
5+
<attribute name="module" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="src" path="src"/>
9+
<classpathentry kind="output" path="bin"/>
10+
</classpath>

Diff for: 13-abstractclasses/.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>13-Abstract Classes</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=9
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=9
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=9

Diff for: 13-abstractclasses/bin/Book.class

413 Bytes
Binary file not shown.

Diff for: 13-abstractclasses/bin/MyBook.class

965 Bytes
Binary file not shown.

Diff for: 13-abstractclasses/src/Book.java

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import java.util.*;
2+
3+
abstract class Book {
4+
String title;
5+
String author;
6+
7+
Book(String title, String author) {
8+
this.title = title;
9+
this.author = author;
10+
}
11+
12+
abstract void display();
13+
}

Diff for: 13-abstractclasses/src/MyBook.java

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
public class MyBook extends Book {
3+
private int price;
4+
MyBook(String title, String author, int price){
5+
super(title,author);
6+
this.price = price;
7+
}
8+
9+
void display() {
10+
System.out.println("Title: " + this.title);
11+
System.out.println("Author: " + this.author);
12+
System.out.println("Price: " + this.price);
13+
}
14+
}

Diff for: 14-scope/.classpath

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9">
4+
<attributes>
5+
<attribute name="module" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="src" path="src"/>
9+
<classpathentry kind="output" path="bin"/>
10+
</classpath>

Diff for: 14-scope/.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>14-Scope</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

Diff for: 14-scope/.settings/org.eclipse.jdt.core.prefs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=9
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=9
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=9

Diff for: 14-scope/bin/Difference.class

709 Bytes
Binary file not shown.

Diff for: 14-scope/src/Difference.java

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.io.*;
2+
import java.util.*;
3+
import java.text.*;
4+
import java.math.*;
5+
import java.util.regex.*;
6+
7+
8+
class Difference {
9+
private int[] elements;
10+
public int maximumDifference;
11+
12+
Difference(int []arr){
13+
this.elements = arr;
14+
}
15+
16+
void computeDifference() {
17+
int max = 0;
18+
for(int i = 0; i < elements.length; i++) {
19+
for(int j = 0; j < elements.length; j++) {
20+
if(i != j) {
21+
int absDifference = Math.abs(elements[i] - elements[j]);
22+
if(absDifference > max)
23+
max = absDifference;
24+
}
25+
}
26+
}
27+
maximumDifference = max;
28+
}
29+
}

Diff for: 15-linkedlist/a.out

14.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)