Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b11a73a

Browse filesBrowse files
authored
Add files via upload
1 parent 64196c9 commit b11a73a
Copy full SHA for b11a73a
Expand file treeCollapse file tree

9 files changed

+401
-0
lines changed

‎Medium/BinaryConverter.java

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
6+
public static int MathChallenge(String str) {
7+
// Abdullah Tas
8+
9+
int decimal = Integer.valueOf(str,2);
10+
11+
return decimal;
12+
}
13+
14+
public static void main (String[] args) {
15+
// keep this function call here
16+
Scanner s = new Scanner(System.in);
17+
System.out.print(MathChallenge(s.nextLine()));
18+
}
19+
20+
}

‎Medium/BracketMatcher.java

Copy file name to clipboard
+46Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
6+
public static String BracketMatcher(String str) {
7+
8+
if(!str.contains("(") && !str.contains(")"))
9+
return "1";
10+
11+
Stack<String> stack = new Stack<String>();
12+
String[] strArray = str.split("");
13+
14+
for(int i=0; i < strArray.length; i++){
15+
16+
String x = strArray[i];
17+
18+
if(x.equals("("))
19+
stack.push(x);
20+
21+
if(x.equals(")")){
22+
if(stack.isEmpty())
23+
return "0";
24+
25+
String y = stack.peek();
26+
if(x.equals(")") && y.equals("(")){
27+
stack.pop();
28+
}else{
29+
return "0";
30+
}
31+
}
32+
}
33+
34+
if(stack.isEmpty())
35+
return "1";
36+
else
37+
return "0";
38+
}
39+
40+
public static void main (String[] args) {
41+
// keep this function call here
42+
Scanner s = new Scanner(System.in);
43+
System.out.print(BracketMatcher(s.nextLine()));
44+
}
45+
46+
}

‎Medium/Division.java

Copy file name to clipboard
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
6+
public static int MathChallenge(int n1, int n2) {
7+
while(n1 != n2){
8+
if(n1>n2)
9+
n1 -= n2;
10+
else
11+
n2 -= n1;
12+
}
13+
14+
return n1;
15+
}
16+
17+
public static void main (String[] args) {
18+
// keep this function call here
19+
Scanner s = new Scanner(System.in);
20+
System.out.print(MathChallenge(s.nextLine()));
21+
}
22+
23+
}

‎Medium/FormattedNumber.java

Copy file name to clipboard
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
6+
public static String StringChallenge(String str) {
7+
8+
String newstr="";
9+
10+
for ( int i = 0 ; i < str.length() ; i++){
11+
12+
char letter = str.charAt(i);
13+
14+
if ( letter >= 'a' && letter <= 'z' || letter >= 'A' && letter <='Z'){
15+
16+
if ( isControl(newstr,letter)) newstr += letter;
17+
}
18+
}
19+
20+
return newstr.length() == 26 ? "true" : "false";
21+
22+
}
23+
24+
public static boolean isControl (String str, char x){
25+
26+
for (int i =0 ; i<str.length(); i++){
27+
if(x==str.charAt(i)) return false;
28+
}
29+
30+
return true;
31+
32+
}
33+
34+
public static void main (String[] args) {
35+
// keep this function call here
36+
Scanner s = new Scanner(System.in);
37+
System.out.print(StringChallenge(s.nextLine()));
38+
}
39+
40+
}

‎Medium/HTMLElements.java

Copy file name to clipboard
+71Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class mediumChallenge {
5+
public static String[][] taken = {{"b","/b"},{"i","/i"},{"em","/em"},{"div","/div"},{"p","/p"}};
6+
7+
8+
public static boolean isFirstTerm(String str){
9+
for(String[] array: taken){
10+
if(array[0].equals(str)){
11+
return true;
12+
}
13+
}
14+
return false;
15+
}
16+
17+
18+
public static boolean matches(String firstTerm, String lastTerm){
19+
for(String[] array: taken){
20+
if(array[0].equals(firstTerm)){
21+
return array[1].equals(lastTerm);
22+
}
23+
}
24+
return false;
25+
}
26+
27+
public static String StringChallenge(String str) {
28+
// code goes here
29+
30+
String[] strArr=str.split("[<>]");
31+
ArrayList<String> arrList= new ArrayList<String>();
32+
Stack<String> stack= new Stack<String>();
33+
for(String s: strArr){
34+
for(String[] array: taken){
35+
if(s.equals(array[0])||s.equals(array[1])){
36+
arrList.add(s);
37+
38+
}
39+
40+
}
41+
}
42+
43+
if(arrList.size()==1){
44+
return arrList.get(0);
45+
}
46+
47+
for(int i=0;i<arrList.size();i++){
48+
49+
if(isFirstTerm(arrList.get(i))) {
50+
stack.push(arrList.get(i));
51+
}
52+
53+
else {
54+
String result= stack.pop();
55+
stack.push(result);
56+
if (stack.isEmpty()||!matches(stack.pop(), arrList.get(i))) {
57+
return result;
58+
}
59+
}
60+
}
61+
62+
return "true";
63+
}
64+
65+
public static void main (String[] args) {
66+
// keep this function call here
67+
Scanner s = new Scanner(System.in);
68+
System.out.print(StringChallenge(s.nextLine()));
69+
}
70+
71+
}

‎Medium/MathChallenge.java

Copy file name to clipboard
+81Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
6+
public static List<List<Integer>> permute(int[] nums){
7+
List<List<Integer>> result = new ArrayList<>();
8+
Permutation(0,nums,result);
9+
return result;
10+
}
11+
12+
13+
public static void Permutation(int i,int[]nums,List<List<Integer>> result){
14+
if(i == nums.length-1){
15+
List<Integer> list = new ArrayList<>();
16+
for(int n: nums) list.add(n);
17+
result.add(list);
18+
}else{
19+
for(int j = i,l= nums.length;j<l;j++){
20+
int temp = nums[j];
21+
nums[j] = nums[i];
22+
nums[i] = temp;
23+
Permutation(i+1,nums,result);
24+
temp = nums[j];
25+
nums[j]= nums[i];
26+
nums[i] = temp;
27+
}
28+
}
29+
}
30+
31+
32+
public static boolean checkForPrime(int inputNumber){
33+
boolean isItPrime = true;
34+
if(inputNumber<=1){
35+
isItPrime=false;
36+
return isItPrime;
37+
}else{
38+
for(int i=2;i<= inputNumber/2;i++){
39+
if((inputNumber%i)== 0){
40+
isItPrime = false;
41+
break;
42+
}
43+
}
44+
return isItPrime;
45+
}
46+
}
47+
48+
49+
public static int concatenateArr(List<Integer> arr){
50+
int ans = arr.get(0);
51+
for(int i = 1; i<arr.size();i++){
52+
int l = (int)Math.floor(Math.log10(arr.get(i))+1);
53+
ans = ans * (int)Math.pow(10,1);
54+
ans += arr.get(i);
55+
}
56+
return ans;
57+
}
58+
59+
public static int MathChallenge(int num) {
60+
String temp = Integer.toString(num);
61+
int[] myArray = new int[temp.length()];
62+
for(int i = 0;i< temp.length();i++){
63+
myArray[i]= temp.charAt(i)-'0';
64+
}
65+
List<List<Integer>> array = permute(myArray);
66+
//System.out.print(concatenateArr(array.get(4)));
67+
//System.out.print(array);
68+
for(int i=0;i<array.size();i++){
69+
if(checkForPrime(concatenateArr(array.get(i)))==true){
70+
return 1;
71+
}
72+
}
73+
return 0;
74+
}
75+
76+
public static void main (String[] args) {
77+
// keep this function call here
78+
Scanner s = new Scanner(System.in);
79+
System.out.print(MathChallenge(s.nextLine()));
80+
}
81+
}

‎Medium/NumberSearch.java

Copy file name to clipboard
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
6+
public static int NumberSearch(String str) {
7+
// code goes here
8+
double countLetter=0;
9+
double sumTotal=0;
10+
int result=0;
11+
for(int i=0;i<str.length();i++) {
12+
if(Character.isLetter(str.charAt(i))){
13+
countLetter++;
14+
}
15+
if(Character.isDigit(str.charAt(i))==true){
16+
sumTotal += Character.getNumericValue(str.charAt(i));
17+
18+
}
19+
}
20+
result =(int) Math.round(sumTotal/countLetter);
21+
22+
return result;
23+
}
24+
25+
public static void main (String[] args) {
26+
// keep this function call here
27+
Scanner s = new Scanner(System.in);
28+
System.out.print(NumberSearch(s.nextLine()));
29+
}
30+
31+
}

‎Medium/StarRating.java

Copy file name to clipboard
+47Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
6+
public static String StringChallenge(String str) {
7+
// code goes here
8+
float value = Float.parseFloat(str);
9+
int starCount = 0;
10+
String sonuc="";
11+
12+
while(starCount < 5){
13+
if(value >= 1){
14+
sonuc+="full ";
15+
16+
value-=1;
17+
}
18+
else if(value > 0){
19+
if(value+.25 >= 1){
20+
sonuc+="full ";
21+
}
22+
else if(value+.25 >= .5){
23+
sonuc+="half ";
24+
}
25+
else{
26+
sonuc+="empty ";
27+
}
28+
value-=value;
29+
}
30+
else{
31+
sonuc+="empty ";
32+
}
33+
starCount++;
34+
}
35+
36+
return sonuc;
37+
}
38+
39+
public static void main (String[] args) {
40+
// keep this function call here
41+
Scanner s = new Scanner(System.in);
42+
String str;
43+
str = s.nextLine();
44+
System.out.print(StringChallenge(str));
45+
}
46+
47+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.