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

Added Codewars, TV and channels classes task and RPG Saga (feature complete) #24

Open
wants to merge 46 commits into
base: Chadov_Sergej_Vadimovich
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
89601e1
Codewars loaded
goutosama Sep 26, 2023
3274742
plus 1 codewars solved
goutosama Sep 26, 2023
24274f6
Added class files
goutosama Oct 10, 2023
33fa4a3
Adds
goutosama Oct 10, 2023
fd786e9
sync commit
goutosama Oct 16, 2023
7445d88
Problems with getting methods from child class
goutosama Oct 16, 2023
80a10f2
Battles in RPG Saga work
goutosama Oct 22, 2023
14f80bf
tournaments added, not ready
goutosama Oct 23, 2023
ed3b019
Tournaments added
goutosama Oct 23, 2023
3b21e83
Logger completed, needs redesign with action types
goutosama Nov 8, 2023
7ce9e7e
Tests for TV fixed, Action Types in Saga
goutosama Nov 16, 2023
b9b4b7c
tests for tv
goutosama Nov 20, 2023
0a183af
Little less chaos
iamsky3ll Nov 28, 2023
b34da5f
Automatic refactoring made
goutosama Dec 4, 2023
bfe250a
Main PC commit
goutosama Dec 4, 2023
e4829c8
Merge branch 'master' of github.com:fagirton/TProgramming_2023
goutosama Dec 4, 2023
4d4ee2b
Sync commit
goutosama Dec 4, 2023
8127c36
player generator and statuses implemented (never used there)
goutosama Dec 5, 2023
1cd0b7d
Oh no! Tests???
goutosama Dec 8, 2023
fc35672
player generator and statuses implemented (never used there)
goutosama Dec 5, 2023
3ae064d
Merge branch 'master' of github.com:fagirton/TProgramming_2023
goutosama Dec 9, 2023
5f72f92
playerGenerator working, test for it
goutosama Dec 9, 2023
e89d38e
Merge branch 'master' of github.com:fagirton/TProgramming_2023
goutosama Dec 9, 2023
743130a
Merge branch 'master' of github.com:fagirton/TProgramming_2023
goutosama Dec 12, 2023
ffc251a
Status update, affinities work, not tested
goutosama Dec 20, 2023
96d73d1
Merge branch 'master' of github.com:fagirton/TProgramming_2023
goutosama Dec 23, 2023
0cc465e
tests + balance change + minor refactor
goutosama Jan 2, 2024
0d1e116
Changer added + ability can return undefined
goutosama Jan 2, 2024
8dd82e8
Merge branch 'master' of github.com:fagirton/TProgramming_2023
goutosama Jan 2, 2024
8c512ad
player tests completed
goutosama Jan 4, 2024
52be946
Tests, tournaments fixed, logger redone (almost), small cleaning
goutosama Jan 4, 2024
2f54e84
I fully implemented changer, wrote one test and now my project doesn'…
goutosama Jan 4, 2024
bac7c0d
Tests work, if you dont try to fetch statuses from another file
goutosama Jan 4, 2024
754dc5e
Create jest.yml, trying auto testing
goutosama Jan 4, 2024
2181b04
Update jest.yml
goutosama Jan 4, 2024
85784f9
Update yml
goutosama Jan 4, 2024
166790a
Update jest.yml
goutosama Jan 4, 2024
ec3d627
Update jest.yml
goutosama Jan 4, 2024
8eb6090
Update jest.yml
goutosama Jan 4, 2024
4c995c1
Update jest.yml
goutosama Jan 4, 2024
b2bd8c9
Update jest.yml
goutosama Jan 4, 2024
cdb961b
I shouldnt have tried jest testing, I already have one
goutosama Jan 4, 2024
b950bea
Merge branch 'master' of github.com:fagirton/TProgramming_2023
goutosama Jan 4, 2024
cf05c5a
Returning to final state of the code, only some issues should be fixed
goutosama Jan 4, 2024
0f52c1a
Finally fixed, that "compiler error" was a mutation issue
goutosama Jan 4, 2024
b102958
Option to shuffle players in playerGenerator; logger now displays dam…
goutosama Jan 6, 2024
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
8 changes: 8 additions & 0 deletions codewars/.hintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"development"
],
"hints": {
"typescript-config/consistent-casing": "off"
}
}
30 changes: 30 additions & 0 deletions codewars/Adding Big Numbers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function add(a, b) {
if (a.length <= b.length) {
var small = a
var big = b
} else {
var big = a
var small = b
}
var tens = 0
var result = ""
for (let index = 0; index < big.length; index++) {
let num
if (/^[1-9]/.test(small[small.length - index - 1])) {
num = Number(big[big.length - index - 1]) + Number(small[small.length - index - 1]) + tens
} else{
num = Number(big[big.length - index - 1]) + tens
}
console.log(small[small.length - index - 1], big[big.length - index - 1], tens)
if (num > 9) {
tens = 1
} else{
tens = 0
}
result = (num % 10).toString() + result
}
if (tens > 0) {
result = tens.toString() + result
}
return result;
}
29 changes: 29 additions & 0 deletions codewars/Anagram difference/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function anagramDifference(firstWord, secondWord){
var sameLetters = 0;
var array = {};
if (firstWord.length >= secondWord.length){
var bigWord = firstWord
var smallWord = secondWord
} else{
var bigWord = secondWord
var smallWord = firstWord
}
var sameLetters = bigWord.length;

for (let index = 0; index < bigWord.length; index++) {
if (array[bigWord[index]] == null){
array[bigWord[index]] = 1
} else{
array[bigWord[index]] += 1}
}
for (let index = 0; index < smallWord.length; index++) {
if (array[smallWord[index]] != null && array[smallWord[index]] != 0){
array[smallWord[index]]--
}
}
for (let index = 0; index < bigWord.length; index++) {
sameLetters = sameLetters - array[bigWord[index]]
array[bigWord[index]] = 0
}
return bigWord.length + smallWord.length - (sameLetters * 2)
}
10 changes: 10 additions & 0 deletions codewars/Array Deep Count/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function deepCount(array, count = 0){
for (let index = 0; index < array.length; index++) {
const element = array[index];
count++
if (typeof element === "object") {
count = deepCount(element, count)
}
}
return count
}
22 changes: 22 additions & 0 deletions codewars/Build Tower/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function NumLength(num: number, res: number = 1): number {
if (num < 10) {
return res
} else {
num = Math.floor(num / 10)
return NumLength(num, res + 1)
}
}

export const digitalRoot = (num:number):number => {
var len = NumLength(num)
var res = 0
for (let index = 0; index < len; index++) {
const element = Math.floor((num % 10 ** (len - index)) / 10 ** (len - 1 - index));
res = res + element
}
if (NumLength(res) == 1) {
return res
} else {
return digitalRoot(res)
}
};
10 changes: 10 additions & 0 deletions codewars/Convert string to camel case/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function toCamelCase(str){
for (let index = 0; index < str.length; index++) {
//console.log(str[index])
if (str[index] == "-" || str[index] == "_") {
str = str.substring(0, index) + str[index + 1].toUpperCase() + str.substring(index + 2)
}
//console.log(str)
}
return str
}
22 changes: 22 additions & 0 deletions codewars/Duplicate Encoder/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function duplicateEncode(string){
string = string.toLowerCase();
var map = new Object;
for (let index = 0; index < string.length; index++) {
const element = string[index];
map[element] = 0
}
for (let index = 0; index < string.length; index++) {
const element = string[index];
map[element] = map[element] + 1
}
var result = ""
for (let index = 0; index < string.length; index++) {
const element = string[index];
if (map[element] > 1) {
result = result + ")"
} else {
result = result + "("
}
}
return result
}
14 changes: 14 additions & 0 deletions codewars/Find the missing letter/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export function findMissingLetter(array:string[]):string
{
var lastAscii = array[0].charCodeAt(0)

for (let index = 1; index < array.length; index++) {
const element = array[index];

if (element.charCodeAt(0) != lastAscii + 1) {
return String.fromCharCode(element.charCodeAt(0) - 1)
}
lastAscii = element.charCodeAt(0)
}
return "None"
}
20 changes: 20 additions & 0 deletions codewars/Fun with tree - max sum/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function maxSum(root) {
/* case if null */
if (root == null){
return 0
}

/* case if no children */
if(root.left == null && root.right == null){
return root.value
}

/* case if has only one children */
if(root.right == null)
return root.value + maxSum(root.left);
else if(root.left == null)
return root.value + maxSum(root.right);

/* case if both children exist */
return Math.max(root.value + maxSum(root.left), root.value + maxSum(root.right));
}
13 changes: 13 additions & 0 deletions codewars/Merge two arrays/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function mergeArrays(a, b) {
var result = []
var len = Math.max(a.length, b.length)
for (index = 0; index < len; index++){
if (a[index] != null){
result.push(a[index])
}
if (b[index] != null){
result.push(b[index])
}
}
return result
}
17 changes: 17 additions & 0 deletions codewars/Moving Zeros To The End/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function moveZeros(array) {
var zeroes = 0
var res = [];
for (let index = 0; index < array.length; index++) {
//console.log(array[index])
if (array[index] === 0) {
zeroes++
} else {
res.push(array[index])
}
//console.log(res)
}
for (let index = 0; index < zeroes; index++) {
res.push(0)
}
return res
}
9 changes: 9 additions & 0 deletions codewars/Simple Pig Latin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function pigIt(str){
var array = str.match(/\w+|\s+|[^\s\w]+/g)
for (index = 0; index < array.length; index++){
if (/^[a-zA-Z]/.test(array[index])) {
array[index] = array[index].substring(1) + array[index][0] + "ay"
}
}
return array.join("")
}
60 changes: 60 additions & 0 deletions codewars/Snail/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
snail = function(array) {
var steps = (array.length - 1) * 2 + 1
if (array[0].length == 0){
steps = 0
}
return SnailNewCycle(array, steps)
}

function SnailNewCycle(array, steps, cycle = 0, res = []) {
for (let index = 0; index < 4; index++) {
if (steps > 0) {
let sus = MoveHorisontally(array, cycle, array.length - cycle, cycle)
if (sus.length > 1 && steps > 1){
sus.pop()
}
res.push(sus)
steps--
array = Rotate2dArray(array)
}
}
if (steps > 0) {
return SnailNewCycle(array, steps, cycle + 1, res)
} else {
return flatten(res)
}
}

function flatten(ary) {
var ret = [];
for(var i = 0; i < ary.length; i++) {
if(Array.isArray(ary[i])) {
ret = ret.concat(flatten(ary[i]));
} else {
ret.push(ary[i]);
}
}
return ret;
}

function Rotate2dArray(array2d) {
result = []
for (let index = array2d[0].length - 1; index >= 0; index--) {
var verticalSlice = []
for (let index1 = 0; index1 < array2d.length; index1++) {
const element = array2d[index1][index];
verticalSlice.push(element)
}
result.push(verticalSlice)
}
return result
}

function MoveHorisontally(array, offsetStart, offsetEnd, i) {
var res = []
for (let index = offsetStart; index < offsetEnd; index++) {
const element = array[i][index];
res.push(element)
}
return res
}
22 changes: 22 additions & 0 deletions codewars/Sum of Digits - Digital Root/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function NumLength(num: number, res: number = 1): number {
if (num < 10) {
return res
} else {
num = Math.floor(num / 10)
return NumLength(num, res + 1)
}
}

export const digitalRoot = (num:number):number => {
var len = NumLength(num)
var res = 0
for (let index = 0; index < len; index++) {
const element = Math.floor((num % 10 ** (len - index)) / 10 ** (len - 1 - index));
res = res + element
}
if (NumLength(res) == 1) {
return res
} else {
return digitalRoot(res)
}
};
59 changes: 59 additions & 0 deletions codewars/Tic-Tac-Toe Checker/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
function getVertical(board, index) {
var a = 0
var result = []
while (a < 3) {
result.push(board[a][index])
a++
}
return result
}

function getDiagonal(board, isReversed) {
var a = 0
var result = []
while (a < 3) {
if (isReversed == true) {
b = 2 - a
} else {
b = a
}
result.push(board[a][b])
a++
}
return result
}

function isSolved(board) {
var a = 0
var hasEmptyspots = false;
while (a < 3) {
let vert = getVertical(board, a)
let hori = board[a]
if (Math.min.apply(null, vert) == 0 || Math.min.apply(null, hori) == 0) {
hasEmptyspots = true
}
let sumV = vert.reduce((partialSum, a) => partialSum + a, 0);
let sumH = hori.reduce((partialSum, a) => partialSum + a, 0);
if (sumV == 6 || sumH == 6) {
return 2
} else if ((sumV == 3 && Math.min.apply(null, vert) != 0) || (sumH == 3 && Math.min.apply(null, hori) != 0)) {
return 1
}
a++
}
let diag1 = getDiagonal(board, false)
let diag2 = getDiagonal(board, true)
let sum1 = diag1.reduce((partialSum, a) => partialSum + a, 0)
let sum2 = diag2.reduce((partialSum, a) => partialSum + a, 0)
console.log(diag1, diag2)
if (sum1 == 6 || sum2 == 6) {
return 2
} else if ((sum1 == 3 && Math.min.apply(null, diag1) != 0) || (sum2 == 3 && Math.min.apply(null, diag2) != 0)) {
return 1
}
if (hasEmptyspots) {
return -1
} else {
return 0
}
}
17 changes: 17 additions & 0 deletions codewars/Valid Parentheses/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function validParentheses(parens) {
let res = [];
res.push(parens[0])
for (let i = 1; i < parens.length; i++){
if (res[res.length - 1] == "(" && parens[i] == ")"){
res.splice(0,1)
} else {
res.push(parens[i])
}
}
console.log(res)
if (res.length == 0 || res[0] == undefined){
return true
} else{
return false;
}
}
Loading