Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rohith-bare-on - COMPLETED #79

Open
wants to merge 63 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
28660cf
initial_commit
rohithmsr Dec 2, 2020
06ccffa
day_1_implementation
rohithmsr Dec 2, 2020
36f35cf
day1_implementaion
rohithmsr Dec 2, 2020
534da7e
day2_backtracking
rohithmsr Dec 3, 2020
ab32027
Merge remote-tracking branch 'upstream/main' into main
rohithmsr Dec 4, 2020
3912d40
day3_vectors
rohithmsr Dec 4, 2020
e5ab51f
day4_implementation
rohithmsr Dec 5, 2020
cbd8015
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
rohithmsr Dec 6, 2020
37965b4
day5_bfs_testcase
rohithmsr Dec 6, 2020
7f586ec
day5_bfs
rohithmsr Dec 6, 2020
0d852a1
Files renamed
rohithmsr Dec 6, 2020
4fc8fd9
day1_issue_implementation
rohithmsr Dec 6, 2020
ef857c1
day6_dfs_toposort
rohithmsr Dec 7, 2020
c3c8bb2
day6_toposort(dfs)
rohithmsr Dec 7, 2020
5bebb2c
day8_nqueens_testcase
rohithmsr Dec 8, 2020
f705c78
day8_backtracking_but_minflow
rohithmsr Dec 8, 2020
e1187d3
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
rohithmsr Dec 9, 2020
f94f630
day8_backtracking_not_maxflow
rohithmsr Dec 9, 2020
58af741
day9_incidentList_or_adjacencyMatrix
rohithmsr Dec 9, 2020
5463bd3
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
rohithmsr Dec 12, 2020
e005944
day10_backtracking_ipaddress
rohithmsr Dec 12, 2020
8ba261c
Delete Picture
rohithmsr Dec 12, 2020
a080d11
day10_BackTracking_IPAddress
rohithmsr Dec 12, 2020
2880add
day10_BactTrack_IPAddressRestore
rohithmsr Dec 12, 2020
3704384
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
rohithmsr Dec 19, 2020
c85e8d2
day2_backtracking_1
rohithmsr Dec 19, 2020
3860c5c
day3_vectors_in_cpp
rohithmsr Dec 19, 2020
a293a8f
day5_BFS_minknightmoves
rohithmsr Dec 19, 2020
a50c197
day7_queue
rohithmsr Dec 19, 2020
5713692
day16_cipherLHR
rohithmsr Dec 19, 2020
e39aaa4
day11_jsql_ipynb
rohithmsr Dec 19, 2020
1ddb591
day11_jsql_ipynb_edited
rohithmsr Dec 19, 2020
e80d188
day18_regex-JS-ES6
rohithmsr Dec 19, 2020
8962972
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
rohithmsr Dec 23, 2020
8b70238
day13_editDistance
rohithmsr Dec 23, 2020
ab7d5c1
day12_SGD_logisticregression
rohithmsr Dec 23, 2020
11b6828
day20_dynamicprogramming
rohithmsr Dec 23, 2020
626470b
day14_backtracking_ratmaze
rohithmsr Dec 24, 2020
c369492
ownership
rohithmsr Dec 25, 2020
3c2ad23
day15_hashing_hashmap_prefixsum
rohithmsr Dec 25, 2020
0528121
day17_greedyalgo
rohithmsr Dec 25, 2020
d66d006
day24_DP_minimumsumofdiffsubsets
rohithmsr Dec 25, 2020
eb85c93
day21_linesweepalgorithm
rohithmsr Dec 26, 2020
eed69d6
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
rohithmsr Dec 26, 2020
9690561
day26_manacher'salgorithm
rohithmsr Dec 26, 2020
50f1421
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
rohithmsr Dec 27, 2020
b97076c
day27_x&yextrapolate_circle
rohithmsr Dec 27, 2020
1142f9d
day19_generictrees
rohithmsr Dec 27, 2020
0e8f71c
day4_O(n)_vectors
rohithmsr Dec 27, 2020
44b936c
day28_findpath-alldirections
rohithmsr Dec 28, 2020
bc7372e
day22_kcenters_greedyapproximation
rohithmsr Dec 28, 2020
0b47ca8
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
rohithmsr Dec 28, 2020
38eba79
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
rohithmsr Dec 29, 2020
4a0808f
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
rohithmsr Dec 30, 2020
573b45e
day29_2-persons-path_dynamicprog
rohithmsr Dec 30, 2020
812fa92
day30_linear-line-sweep
rohithmsr Dec 30, 2020
9f32bd9
day31_simpleeuclideandistance
rohithmsr Dec 31, 2020
62f83d2
Merge branch 'main' of https://github.com/SVCE-ACM/A-December-of-Algo…
rohithmsr Dec 31, 2020
b784e9c
day25_trappingrainwater_twopointers
rohithmsr Dec 31, 2020
c2ffe22
day23_dungeon_dynamicprogramming
rohithmsr Dec 31, 2020
f4c707b
Add Certificate In Readme
rohithmsr Feb 11, 2021
e1be4b3
Add Certificate
rohithmsr Feb 11, 2021
aadc6fc
Created using Colaboratory
rohithmsr Apr 27, 2022
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
51 changes: 51 additions & 0 deletions December-01/cpp_rohithmsr_sherlocksquest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int statusCheck(int room_no)
{
int sqr, len, k, ans, first_part, second_part;

if (room_no % 3 == 0)
{
sqr = room_no * room_no;
k = (int)(to_string(room_no).size()); // no of digits of room_no
len = (int)(to_string(sqr).size()); // no of digits of (room_no)^2

//before converting to int, add 0.5 for precision
//since it stores pow(5,2) as 24.99999,
//so add 0.5 and convert to int to get 25
second_part = (sqr % (int)(pow(10, k) + 0.5));
first_part = (sqr - second_part) / (int)(pow(10, k) + 0.5);

ans = first_part + second_part;

if (ans == room_no)
{
return 1;
}
}
return 0;
}

int main()
{
int room_no;

cout << "Room: ";
cin >> room_no;
cout << "Status: ";

if (statusCheck(room_no))
{
cout << "Safe" << endl;
}
else
{
cout << "Not Safe" << endl;
}

return 0;
}
60 changes: 60 additions & 0 deletions December-02/cpp_rohithmsr_convo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

void getCombo(string str, int number, vector<string> *ans, vector<string> *dial)
{
int size = to_string(number).size();

if (number == 0) // this condition is achieved when size of the one of the element is equal to number of digits of number given as input by the user
{
ans->push_back(str);
}
else
{
int first_digit = (int)(number / ((int)(pow(10, size - 1) + 0.5)));
//find the first digit of the number

for (int i = 0; i < dial->at(first_digit).size(); i++)
{
int no = (int)(number % ((int)(pow(10, size - 1) + 0.5)));
//finds the remaining digits

string strr = str + dial->at(first_digit).substr(i, 1);
getCombo(strr, no, ans, dial);
}
}
}

// Returns the combinations using getCombo function
vector<string> getList(int digits)
{

vector<string> dial{"_", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
vector<string> ans; // contains the combinations

getCombo("", digits, &ans, &dial); // empty string should be given as the first argument

return ans;
}

void print(vector<string> v)
{
cout << '[';
for (int i = 0; i < v.size(); i++)
{
cout << '"' << v.at(i) << '"' << ",";
}
cout << '\b' << ']';
}

// Driver Code
int main()
{
int digits;
cin >> digits;
print(getList(digits));
}
87 changes: 87 additions & 0 deletions December-03/cpp_rohithmsr_meetandgreet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#include <iostream>
#include <string>
#include <vector>

using namespace std;

// Convert Input string to Vector
vector<string> createList(string str)
{
int quote = 0;
string timestr = "";
// add start time to vector
vector<string> v = {"0900"};

for (int i = 0; i < str.size(); i++)
{
if (str.at(i) == '\"')
{
if (quote % 2 == 1)
{
v.push_back(timestr);
timestr = "";
}
quote++;
}
else if (quote % 2 == 1)
{
timestr = timestr + str.at(i);
}
else
{
continue;
}
}
// add ending time to vector
v.push_back("1700");

// for (auto i = v.begin(); i != v.end(); ++i)
// cout << '|' << *i << '|' << " ";
//fr debugging..lol

return v;
}

void getIntervals(string str)
{
int start, end, flag = 0;

// ["0930","1100"],["1200","1330"],["1530","1630"]
vector<string> v = createList(str);

for (int i = 0; i < v.size(); i = i + 2)
{
start = stoi(v.at(i));
end = stoi(v.at(i + 1));

if (end - start >= 100)
{
if (flag == 1)
{
cout << ',';
}
cout << "[\"" << v[i] << "\",\"" << v[i + 1] << "\"]";
flag = 1;
}
}
if (flag == 0)
{
cout << "Can't have meeting today" << endl;
}
else
{
printf("\n");
}
return;
}

// Driver Code
int main()
{
string str; // ["0930", "1100"],["1200","1330"],["1530","1630"]
cin >> str;

getIntervals(str);

return 0;
}
47 changes: 47 additions & 0 deletions December-04/cpp_rohithmsr_spoiledornot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void spoiled(vector<long long> &dates, long long today)
{
int count = 0;
for (int i = 0; i < dates.size(); i++)
{
if (dates[i] < today)
{
count++;
}
}
printf("\n%d\n", count);
}

int main()
{
int n;
cin >> n;

long long a, b, c, d;

vector<long long> dates;
for (int i = 0; i < n; i++)
{
cin >> a >> b >> c >> d;
a = a + (b * 30) + (c * 12 * 30) + d;
dates.push_back(a);
}

cin >> a >> b >> c;
long long today = a + (b * 12) + (c * 12 * 30);
spoiled(dates, today);
return 0;
}

/*
3
10 1 2020 20
13 1 2020 13
20 12 2019 20
28 1 2020
*/
118 changes: 118 additions & 0 deletions December-05/cpp_rohithmsr_grandmaster.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#include <iostream>
#include <list>

using namespace std;

// checks if the point is inside the borad
bool isInside(int c, int d, int a, int b)
{
if (c >= 1 & c <= a & d >= 1 & d <= b)
{
return true;
}
return false;
}

//calculates the minimum steps
int minsteps(int c, int d, int e, int f, int a, int b)
{
// next steps moved by knight
int steps_x[8] = {1, 1, 2, 2, -1, -1, -2, -2};
int steps_y[8] = {2, -2, 1, -1, 2, -2, 1, -1};

//respective grid number(each grid starts with 1 till a*b)
// grid number of (1,1) is 1,(1,2) is 2 for a = 1 and b = 2
int grid_number = (d - 1) * b + c;
int target = (f - 1) * b + e;

if (!isInside(c, d, a, b) | !isInside(e, f, a, b))
{
return -1;
}

int grid_c, grid_d, layer = 0, aa, bb, cc;

list<int> queue;

//boolean array storing whether the point has been visited or not
bool *visited;
visited = (bool *)malloc(((a * b) + 1) * sizeof(int));
for (int i = 0; i <= a * b; i++)
{
visited[i] = false;
}

//set visit of first position as true and add to the queue
visited[grid_number] = true;
queue.push_back(c);
queue.push_back(d);
queue.push_back(layer); // layer of the bfs

while (!queue.empty())
{
aa = queue.front();
queue.pop_front();
bb = queue.front();
queue.pop_front();
cc = queue.front();
queue.pop_front();

if (visited[target] == true)
{
return layer;
}
for (int i = 0; i < 8; i++)
{
grid_c = aa + steps_x[i];
grid_d = bb + steps_y[i];
layer = cc + 1;

if (visited[target] == true)
{
return layer;
}

if (isInside(grid_c, grid_d, a, b))
{
grid_number = (grid_d - 1) * b + grid_c;

if (!visited[grid_number])
{
visited[grid_number] = true;
queue.push_back(grid_c);
queue.push_back(grid_d);
queue.push_back(layer);
}
}
}
}
return -2;
}

// Driver Code
int main()
{
int a, b, c, d, e, f, steps;
cout << "Dimension of Board : ";
cin >> a >> b;
cout << "Position of Knight : ";
cin >> c >> d;
cout << "Target Position : ";
cin >> e >> f;

steps = minsteps(c, d, e, f, a, b);

if (steps == -1)
{
cout << "Minimum Steps : Target or Position Out of the bounds" << endl;
}
else if (steps == -2)
{
cout << "Minimum Steps : Impossible" << endl;
}
else
{
cout << "Minimum Steps : " << steps << endl;
}
return 0;
}
Binary file added December-05/output_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading