This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// prac.cpp : This file contains the 'main' function. Program execution begins and ends there. | |
// | |
#include <iostream> | |
#include <boost/asio.hpp> | |
#include <thread> | |
#include <chrono> | |
std::chrono::seconds getsecondsPt() { | |
auto st = std::chrono::high_resolution_clock::now().time_since_epoch(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import sys | |
import codecs | |
sys.stdout = codecs.getwriter('utf8')(sys.stdout) | |
def save(dat): | |
with open('dump', 'a') as file: | |
file.write(dat) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sdlCircle.cpp : This file contains the 'main' function. Program execution begins and ends there. | |
// | |
#include <iostream> | |
#include <SDL2/SDL.h> | |
#include "tinysplinecxx.h" | |
struct Point { | |
double x; | |
double y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void printArray(int p[], int n) | |
{ | |
for (int i = 0; i < n; i++) | |
cout << p[i] << " "; | |
cout << endl; | |
} | |
void printAllUniqueParts(int n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int Ipan(int num, int k){ | |
int table[num][k]; | |
for(int j = 1; j <= k; j++){ | |
table[0][j] = 1; | |
table[1][j] = 1; | |
} | |
for(int i = 2; i <= num; i++){ | |
table[i][1] = 1; | |
for(int j = 2; j <= i; j++){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int longestPalindrome(string s) { | |
map<char, int> count; | |
for (char c: s){ | |
count[c]++; | |
} | |
int ans = 0; | |
for (auto v: count) { | |
ans += v.second / 2 * 2; | |
if (ans % 2 == 0 && v.second % 2 == 1) | |
ans++; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int utopianTree(int n) { | |
int res = 0; | |
int rem = 0; | |
for(int i = 0; i <= n; i++){ | |
if(rem == 0 && i > 0){ | |
res = res * 2; | |
}else{ | |
res = res + 1; | |
} | |
int mod = i % 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int camelcase(string s) { | |
int counter = 0; | |
for(int i = 0; i < s.size(); i++){ | |
if(isupper(s[i])){ | |
counter++; | |
} | |
} | |
return counter + 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string superReducedString(string s) { | |
string temp; | |
int index = 0; | |
for(int i = 0; index < s.size(); i++){ | |
if(s[index] == s[index+1]){ | |
index = index + 2; | |
} | |
else { | |
if(!temp.empty()){ | |
if(*(temp.end() -1) != s[index]){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int height(Node* root) { | |
if (root == NULL) | |
return -1; | |
else | |
{ | |
/* compute the depth of each subtree */ | |
int lefth = height(root->left); | |
int righth = height(root->right); | |
/* use the larger one */ |