Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5d6da2f
Add files via upload
PriyaShrinithi Nov 30, 2020
79b3067
Rename Quest.java to java_PriyaShrinithi_Sherlock'sQuest.java
PriyaShrinithi Nov 30, 2020
c386b13
Update and rename java_PriyaShrinithi_Sherlock'sQuest.java to java_Pr…
PriyaShrinithi Dec 1, 2020
59c2359
Add files via upload
PriyaShrinithi Dec 1, 2020
21ce793
Rename Convo.java to java_PriyaShrinithi_Convo.java
PriyaShrinithi Dec 1, 2020
5ff7ce7
Create java_PriyaShrinithi_MeetAndGreet.java
PriyaShrinithi Dec 3, 2020
b5bdc53
Update java_PriyaShrinithi_SherlocksQuest.java
PriyaShrinithi Dec 3, 2020
9e4c4d2
Add files via upload
PriyaShrinithi Dec 4, 2020
8351e66
Rename Spoiled.java to java_PriyaShriniithi_SpoiledOrNot.java
PriyaShrinithi Dec 4, 2020
2036191
Merge pull request #1 from SVCE-ACM/main
PriyaShrinithi Dec 6, 2020
9db4691
Merge pull request #2 from SVCE-ACM/main
PriyaShrinithi Dec 10, 2020
c32e4b7
First commit
PriyaShrinithi Dec 12, 2020
0326a85
Merge pull request #3 from SVCE-ACM/main
PriyaShrinithi Dec 12, 2020
bd3e0bb
Merge branch 'main' of https://github.com/PriyaShrinithi/A-December-o…
PriyaShrinithi Dec 12, 2020
70443b7
new file: December-12/java_PriyaShrinithi_RecruitmentDrive.java
PriyaShrinithi Dec 12, 2020
ad942ac
Merge pull request #4 from SVCE-ACM/main
PriyaShrinithi Dec 13, 2020
1b85597
Merge pull request #5 from SVCE-ACM/main
PriyaShrinithi Dec 14, 2020
d341737
Merge pull request #6 from SVCE-ACM/main
PriyaShrinithi Dec 15, 2020
13a2e31
Your branch is up to date with 'origin/main'.
PriyaShrinithi Dec 15, 2020
64dfde8
new file: December-15/java_PriyaShrinithi_HelpMaxShop.java
PriyaShrinithi Dec 15, 2020
b96a584
Merge remote-tracking branch 'upstream/main' into main
PriyaShrinithi Dec 16, 2020
efcbd06
new file: December-16/java_PriyaShrinithi_Max'sParty.java
PriyaShrinithi Dec 16, 2020
b6287b8
Merge remote-tracking branch 'upstream/main' into main
PriyaShrinithi Dec 17, 2020
3b87903
new file: December-17/java_PriyaShrinithi_Pokemon.java
PriyaShrinithi Dec 17, 2020
dd4eb31
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
PriyaShrinithi Dec 18, 2020
783c7f1
new file: December-18/java_PriyaShrinithi_IsThisANewUser.java
PriyaShrinithi Dec 18, 2020
cd20d34
modified: December-18/java_PriyaShrinithi_IsThisANewUser.java
PriyaShrinithi Dec 18, 2020
29d98d3
Merge remote-tracking branch 'upstream/main' into main
PriyaShrinithi Dec 21, 2020
f662322
Merge remote-tracking branch 'upstream/main' into main
PriyaShrinithi Dec 22, 2020
2795aad
new file: December-20/java_PriyaShrinithi_ShowUpPeople.java
PriyaShrinithi Dec 22, 2020
057045a
new file: December-22/java_PriyaShrinithi_ClosestServers.java
PriyaShrinithi Dec 22, 2020
d48bc27
Merge remote-tracking branch 'upstream/main' into main
PriyaShrinithi Dec 23, 2020
47438d3
Merge remote-tracking branch 'upstream/main' into main
PriyaShrinithi Dec 24, 2020
2a62d26
new file: December-23/java_PriyaShrinithi_TheRiseOfTheKnight.java
PriyaShrinithi Dec 24, 2020
16c7bc9
new file: December-24/java_PriyaShrinithi_MinifyDamage.java
PriyaShrinithi Dec 24, 2020
1f893aa
Merge remote-tracking branch 'upstream/main' into main
PriyaShrinithi Dec 25, 2020
f8c61c4
Merge remote-tracking branch 'upstream/main' into main
PriyaShrinithi Dec 26, 2020
7f8330b
new file: December-25/java_PrIyaShrinithi_TrappingRainWater.java
PriyaShrinithi Dec 26, 2020
f83f869
Merge remote-tracking branch 'upstream/main' into main
PriyaShrinithi Jan 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions December-01/java_PriyaShrinithi_SherlocksQuest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.company;
import java.lang.*;
public class Quest
{
public boolean isRoomSafe(int door_number)
{
int door_squared = 0;
int left = 0;
int right = 0;

if(door_number%3!=0)
return false;
door_squared = (int) Math.pow(door_number, 2);
int count = Integer.toString(door_squared).length();

left = (int) (door_squared / Math.pow(10, count / 2));
right = (int) (door_squared - left*Math.pow(10, count/2));

if(left+right!=door_number)
return false;
return true;
}
}
41 changes: 41 additions & 0 deletions December-02/java_PriyaShrinithi_Convo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.company;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Convo
{
int j = 0;
HashMap map = new HashMap<String, String>()
{{
put("2", "abc");
put("3", "def");
put("4", "ghi");
put("5", "jkl");
put("6", "mno");
put("7", "pqrs");
put("8", "tuv");
put("9", "wxyz");
}};

List combinations = new ArrayList<String>();
List <String> makeCombination(String number)
{
if(number.length()<=2)
backtrack("", number);
return combinations;
}

private void backtrack(String letter, String digit) {
if (digit.length()==0)
combinations.add(letter);
else {
String combinat = (String) map.get(digit.substring(0, 1));
for (int i = 0; i < combinat.length(); i++)
{
backtrack(letter+combinat.substring(i, i + 1), digit.substring(1, digit.length()));
}
}
}
}
53 changes: 53 additions & 0 deletions December-03/java_PriyaShrinithi_MeetAndGreet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.company;

import java.util.LinkedList;
import java.util.List;

public class MeetAndGreet
{
List<List<String>> allotTime(List <List<String>> schedule)
{
List<List<String>> intervals = new LinkedList<>();
List <String> interval;
int start_meet = 0;
int end_meet = 0;

int start = 900;
int end = 1700;

if(schedule==null)
{
interval = new LinkedList<>();
interval.add(Integer.toString(start));
interval.add(Integer.toString(end));
intervals.add(interval);
}
else
{
for(List<String> s: schedule)
{
System.out.println(s);
start_meet = Integer.parseInt(s.get(0));
end_meet = Integer.parseInt(s.get(1));

if(start_meet - start >= 100)
{
interval = new LinkedList<>();
interval.add(Integer.toString(start));
interval.add(Integer.toString(start_meet));
intervals.add(interval);
}
start = end_meet;
}
if(end - end_meet >=100)
{
interval = new LinkedList<>();
interval.add(Integer.toString(end_meet));
interval.add(Integer.toString(end));
intervals.add(interval);

}
}
return intervals;
}
}
32 changes: 32 additions & 0 deletions December-04/java_PriyaShrinithi_SpoiledOrNot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.company;

public class Spoiled
{
int spoiledOrNot(int icecreamNumbers, int[][] manufacturingDates, int [] bestBeforeDays, int [] Date)
{
if(manufacturingDates.length!=bestBeforeDays.length)
System.exit(-1);

int spoiledIcecreamNumbers = 0;

int [][] spoiled = new int[manufacturingDates.length][manufacturingDates[0].length];
int i = 0;
for(int[] date: manufacturingDates)
{
date[0] = date[0]+bestBeforeDays[i];
if(date[0]>30){
date[0] -=30;
date[1]++;
}
if(date[1]>12){
date[1]-=12;
date[2]++;
}
i++;
if(date[2]<=Date[2]&&date[1]<=Date[1]&&date[0]<Date[0])
spoiledIcecreamNumbers++;
}

return spoiledIcecreamNumbers;
}
}
37 changes: 37 additions & 0 deletions December-05/java_PriyaShrinithi_GrandMaster.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.company;

import java.util.LinkedList;
import java.util.List;
/*
* It was a dark and stormy night where an Oldman and his grandson were playing chess.
* The Oldman gave his grandson a problem, to check his knowledge and skills in chess.
* He stated that, It was a square chessboard of A x B size, the position of Knight (C, D) and position of a target (E, F) is given.
* Now the Grandson needs to find out the minimum steps a Knight will take to reach the target position.
* Sample Input/Output
* Dimension of Board : 6 6
* Position of Knight : 1 1
* Target Position : 4 5

* Minimum Steps : 3
* Explanation
* From the starting position of the Knight (1,1). The Knight can move to either (3,2) or (2,3). We choose (3,2).
* From (3,2) the Knight can move to (5,1), (1,3), (2,4), (4,4), (5,3), (1,1). We choose (5,3).
* From (5,3) the Knight moves to (4,5).
* The Minimum steps required is 3.
*/
public class KnightMinimumMoves
{
int step = 0;
int minMoves(int edge, int sx, int sy, int tx, int ty)
{
if(sx<edge && sy<edge)
{
System.out.println(sx+" "+sy);
if (sx == tx && sy == ty)
step++;
step = 1 + Math.min(minMoves(edge, sx + 2, sy + 1, tx, ty), minMoves(edge, sx + 1, sy + 2, tx, ty));
}

return step;
}
}
35 changes: 35 additions & 0 deletions December-07/java_PriyaShrinithi_TemperatureScreening.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.company;

import java.util.LinkedList;
import java.util.Queue;

public class TemperatureScreen
{
private Queue <String> checkUpOrder = new LinkedList<>();

Queue<String> screen(Queue<String> A, Queue<String> B)
{

//A takes 2 minutes for 1 move
//B takes 1 minute for 1 move
if(A.isEmpty()&&B.isEmpty())
return checkUpOrder;
if(A.isEmpty())
{
checkUpOrder.add(B.poll());
checkUpOrder.add(B.poll());
}
if(B.isEmpty())
checkUpOrder.add(A.poll());
else
{
checkUpOrder.add(B.poll());
checkUpOrder.add(B.poll());
checkUpOrder.add(A.poll());
}
return screen(A, B);
}


}

45 changes: 45 additions & 0 deletions December-10/java_PriyaShrinithi_RestoreIPAddress.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.company;

import java.util.ArrayList;
import java.util.List;

public class RestoreIPAddress
{
int r = 0;
List <String> uncorrupted_log = new ArrayList<>();
int corrupted_length = 0;
List<String> restore(String corrupted_log)
{
if(corrupted_log.length()<4||corrupted_log.length()>12)
return uncorrupted_log;
corrupted_length = corrupted_log.length();
backtrack("", corrupted_log, 0);
return uncorrupted_log;
}

void backtrack(String partOfLog, String restOf_corrupted_log, int end)
{
r++;
if(end==4||restOf_corrupted_log.length()==0) {
String log = partOfLog.substring(0, partOfLog.length() - 1);
if(validity(log))
uncorrupted_log.add(log);
System.out.println(r);
return;
}
else
{
for(int i = 1;i<=(restOf_corrupted_log.charAt(0)=='0'?1:3) && i<=restOf_corrupted_log.length();i++)
{
String path = restOf_corrupted_log.substring(0, i);
if(Integer.parseInt(path)> -1 && Integer.parseInt(path)<256)
backtrack(partOfLog+path+".", restOf_corrupted_log.substring(i), end + 1);
}
}
}

boolean validity(String log)
{
return log.split("[.]").length == 4 && corrupted_length+3==log.length();
}
}
37 changes: 37 additions & 0 deletions December-11/java_PriyaShrinithi_JSQL.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.company;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class JSQL
{
String convertToSQL(JSONObject json) throws JSONException {


String sql = "create table "+json.get("table name")+" (";
JSONObject header = (JSONObject) json.get("headers");
for(Iterator i = header.keys();i.hasNext();)
{
JSONObject key = (JSONObject) header.get((String) i.next());
String dt = (String) key.get("data type");;
String cn = (String) key.get("column name");
sql+=dt+" "+cn+", ";
}
sql = sql.substring(0, sql.length()-2)+")";
JSONObject record = (JSONObject) json.get("records");
int i = 0;
for(Iterator keys = record.keys();keys.hasNext();)
{

String value = String.valueOf(record.get((String) keys.next()));
sql+="\ninsert into " + json.get("table name")+" values "+"("+value.substring(1, value.length()-1)+")";
i++;
}
return sql;
}
}
62 changes: 62 additions & 0 deletions December-12/java_PriyaShrinithi_RecruitmentDrive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.company;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class RecruitmentDrive
{
private List<String[]> columns = new ArrayList<>();
private double b0 = 0;
private double b1 = 0;
private double b2 = 0;
private double threshold = 0.5;
String readCSV(String csv_link, double gpa, double xp) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(csv_link));
String line ="";
while((line = reader.readLine())!=null) {
columns.add(line.split(","));
}
reader.close();
predict(columns);
if(predict(gpa, xp))
return "Selected";
return "Unselected";
}

void predict (List <String[]> columns)
{
for(String [] row: columns)
{
try{
double x1 = Double.parseDouble(row[0]);
double x2 = Double.parseDouble(row[1]);
double y = Integer.parseInt(row[2]);
double prediction = prediction(b0, b0, b1, x1, x2);
b0 = stochasticGradient(b0, 1,prediction, y);
b1 += stochasticGradient(b1, x1, prediction, y);
b2 += stochasticGradient(b2, x2, prediction, y);
}catch(Exception e){}

}
}

double stochasticGradient(double b, double x, double prediction, double y)
{
return b+0.3*(y - prediction)*prediction*(1-prediction)*x;
}

double prediction(double b0, double b1, double b2, double x1, double x2)
{
return 1/(1 + (Math.exp( - (b0+(b1*x1)+(b2*x2)))));
}

boolean predict(double gpa, double xp)
{
if(prediction(b0, b1, b2, gpa, xp)>threshold)
return true;
return false;
}
}
Loading