Skip to content

Instantly share code, notes, and snippets.

View nimbus98's full-sized avatar

Akash Nair nimbus98

View GitHub Profile
@nimbus98
nimbus98 / ctoclstm.py
Created August 22, 2019 21:38
LSTM C-to-C Model for IEEE Blog reference
# Getting Started, first we load our text file and encode the text with integers.
with open('./The Outcasts.txt', 'r') as f:
text = f.read()
characters = tuple(set(text))
int2char = dict(enumerate(characters)) # enumerate gives the characters their integer values
char2int = {char: index for index, char in int2char.items()} # create the dictionary from characters to assigned integers
encoded = np.array([char2int[char] for char in text]) # encode text using character to integer dictionary
@nimbus98
nimbus98 / rain_water.cpp
Created October 17, 2018 12:02
IEEE CodeBuddy | Week 5 | Aditya A & Akash Nair
int Solution::trap(const vector<int> &A) {
int ans = 0;
int n = A.size();
int i = 0, j = n - 1;
int lm = -1, rm = -1;
while(i < j){
if(A[i] < A[j]){
if(A[i] > lm) lm = A[i];
else ans += (lm - A[i]);
i++;
@nimbus98
nimbus98 / rodcutting.cpp
Created October 14, 2018 22:52
IEEE CodeBuddy | Week 4 | Vilas M & Akash Nair
typedef long long ll;
vector<int>ans;
vector<int>ar;
ll dp[1000][1000];
ll bestcut[1000][1000];
ll sol(int l,int r)
{
ll good_cut;
if(l + 1 >= r) return 0;
if(dp[l][r] != -1)
@nimbus98
nimbus98 / 3sum.cpp
Last active October 14, 2018 22:45
IEEE CodeBuddy | Week 3 | Ashwin Joisa & Akash Nair
int Solution::threeSumClosest(vector<int> &A, int B) {
int ans = INT_MIN/2;
int n = A.size();
sort(A.begin(),A.end());
int i, j, k;
for(int i = 0; i < n; i++){
j = i + 1;
k = n - 1;
while(j < k){
if(abs(B - (A[i]+A[j]+A[k])) < abs(B - ans))
@nimbus98
nimbus98 / sortedpermutationrank.cpp
Last active October 14, 2018 22:44
IEEE CodeBuddy | Week 2 | Aravind Sai K & Akash Nair
int fact(int n)
{
int i = 0,ans = 1;
for(i=1;i<=n;i++)
{
ans = ans*i;
ans = ans%1000003;
}
return ans;
}
@nimbus98
nimbus98 / maxunsortedarray.cpp
Last active October 14, 2018 22:43
IEEE CodeBuddy | Week 1 | Moksh Jain & Akash Nair
vector<int> Solution::subUnsort(vector<int> &A) {
int n = A.size();
if(A[0] > A[n-1]) {
vector<int> ret;
ret.push_back(0);
ret.push_back(n-1);
return ret;
}
vector<int> ret;