Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "windows-gcc-x86",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "C:/MinGW/bin/gcc.exe",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x86",
"compilerArgs": [
""
]
}
],
"version": 4
}
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": ".",
"program": "build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
59 changes: 59 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}
Empty file.
26 changes: 26 additions & 0 deletions codewars/Adding Big Numbers/Adding_Big_Numbers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;

string add(const string& a, const string& b) {
string ans;
char n = '0', c;
short int t;
const int A_size = a.size(), B_size = b.size();
if (A_size == 0) {
if (B_size == 0) return "0";
return b;
}
if (B_size == 0) return a;

for (int i = 1; i <= max(A_size, B_size); i++) {
t = n + (A_size >= i) * (a[A_size - i] - '0')
+ (B_size >= i) * (b[B_size - i] - '0') - '0';
c = 48 + t % 10;
n = 48 + t / 10;
ans = c + ans;
}
if (n != '0') ans = n + ans;
return ans;
}
Empty file.
18 changes: 18 additions & 0 deletions codewars/Anagram difference/Anagram_difference.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdlib.h>

unsigned anagram_difference(const char *word1, const char *word2) {
int A[26] = {}, B[26] = {};
int i = 0;
while (word1[i] != '\0') {
A[word1[i] - 'a']++;
i++;
}
i = 0;
while (word2[i] != '\0') {
B[word2[i] - 'a']++;
i++;
}
unsigned a = 0;
for (int i = 0; i < 26; i++) a += abs(A[i] - B[i]);
return a;
}
Empty file removed codewars/Array Deep Count/.gitkeep
Empty file.
10 changes: 10 additions & 0 deletions codewars/Array Deep Count/Array_Deep_Count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def R(a):
b = 0
for i in a:
if type(i) == list:
b += R(i)
b += 1
return b

def deep_count(a):
return R(a)
Empty file removed codewars/Build Tower/.gitkeep
Empty file.
14 changes: 14 additions & 0 deletions codewars/Build Tower/Build_Tower.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <bits/stdc++.h>

using namespace std;

void towerBuilder(unsigned nFloors) {
vector <string> V(nFloors, "*");
for (int i = 0; i < nFloors; i++) {
string a, b;
for (int j = i; j < nFloors - 1; j++) a += "-";
for (int k = 0; k < i; k++) b += "*";
V[i] = a + b + V[i] + b + a;
cout << V[i] << endl;
}
}
Empty file.
18 changes: 18 additions & 0 deletions codewars/Convert string to camel case/Convert_to_Camel_Case.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <bits/stdc++.h>

using namespace std;

string to_camel_case(string text) {
string ans;
for (int i = 0; i < text.size(); i++) {
if ((text[i] == '-' || text[i] == '_')
&& i < text.size() - 1) {
if (text[i + 1] >= 97 && text[i + 1] <= 122) {
ans += text[i + 1] - 32;
} else ans += text[i + 1];
i++;
}
else ans += text[i];
}
return ans;
}
Empty file.
18 changes: 18 additions & 0 deletions codewars/Duplicate Encoder/Duplicate_Encoder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <bits/stdc++.h>

using namespace std;

string duplicate_encoder(const string& word) {
string s = word;
int M[256] = {};
for (int i = 0; i < s.size(); i++) {
if (s[i] >= 97 && s[i] <= 122) M[s[i] - 32]++;
if (s[i] >= 65 && s[i] <= 90) M[s[i] + 32]++;
M[s[i]]++;
}
for (int i = 0; i < s.size(); i++) {
if (M[s[i]] == 1) s[i] = '(';
else s[i] = ')';
}
return s;
}
Empty file.
10 changes: 10 additions & 0 deletions codewars/Find the missing letter/Find_the_Missing_Letter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <bits/stdc++.h>

using namespace std;

char findMissingLetter(const vector<char>& chars) {
for (int i = 1; i < chars.size(); i++) {
if (chars[i] - chars[i - 1] > 1) return chars[i] - 1;
}
return chars[0] - 1;
}
Empty file.
40 changes: 40 additions & 0 deletions codewars/Flatten a Nested Map/Flatten_a_Nested_Map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function flattenMap(map) {
let m = [map]
let a = []
const ans = {}
let node = null
let parent = null
let pkey = null

while (Object.keys(map).length) {

if (m.length) {
node = m.pop()
} else {
node = map
}

const keys = Object.keys(node)
const value = node[keys[0]]
a.push(keys[0])

if (value && value.toString() === "[object Object]") {
parent = node
pkey = keys[0]
m.push(value)
} else {
ans[a.join("/")] = value
a = []
delete node[keys[0]]

if (!Object.keys(node).length) {
if (parent) {
delete parent[pkey]
}
}
m = []
m.push(map)
}
}
return ans
}
1 change: 0 additions & 1 deletion codewars/Fun with tree - max sum/.gitkeep

This file was deleted.

13 changes: 13 additions & 0 deletions codewars/Fun with tree - max sum/Fun_with_Trees_Max_Sum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <bits/stdc++.h>

using namespace std;

class Solution {
public:
static int maxSum(TreeNode* root) {
if (!root) return root -> value;
if (!root -> left) return root -> value + maxSum(root -> right);
if (!root -> right) return root -> value + maxSum(root -> left);
return root -> value + max(maxSum(root -> left), maxSum(root -> right));
}
};
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def sorted_insert(head, data):
V = [data]
temp = head
while temp:
V.append(temp.data)
temp = temp.next
head = v = None
for i in sorted(V):
if head is None:
head = Node(i)
v = head
else:
v.next = Node(i)
v = v.next
return head
Empty file removed codewars/Merge two arrays/.gitkeep
Empty file.
21 changes: 21 additions & 0 deletions codewars/Merge two arrays/Merge_Two_Arrays.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>

void merge_arrays (
size_t len_a, const int a[len_a],
size_t len_b, const int b[len_b],
int merged[len_a + len_b]
) {
int i = 0, j = 0;
while (i + j < len_a + len_b) {
if (i < len_a) {
merged[i + j] = a[i];
i++;
}
if (j < len_b) {
merged[i + j] = b[j];
j++;
}
}
}
Empty file.
14 changes: 14 additions & 0 deletions codewars/Moving Zeros To The End/Moving_Zeroes_To_The_End.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <bits/stdc++.h>

using namespace std;

vector <int> move_zeroes(const vector <int>& input) {
vector <int> V;
int a = 0;
for (int i = 0; i < input.size(); i++) {
if (input[i] == 0) a++;
else V.push_back(input[i]);
}
while (a--) V.push_back(0);
return V;
}
Empty file removed codewars/Permutations/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions codewars/Permutations/So_Many_Permutations.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

vector<string> permutations(string s) {
vector <string> v;
sort(s.begin(), s.end());
do {v.push_back(s);}
while (next_permutation(s.begin(), s.end()));

return v;
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
class ProdFib
{
public:
static vector<ull> productFib(ull prod) {
ull a = 0, b = 1;
while (a * b < prod) {
swap(a, b);
b += a;
}
return {a, b, (a * b == prod ? true : false)};
}
};
Empty file removed codewars/Simple Pig Latin/.gitkeep
Empty file.
Loading
Loading