Skip to content

CodeWars_Fox class_RPGSAGA #7

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

Open
wants to merge 9 commits into
base: Tsyganov_Vladislav_Vasilevich
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion .github/workflows/rpgsaga.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
with:
node-version: 18.16.x
cache: yarn
cache-dependency-path: ./rpgsaga/saga/yarn.lock
cache-dependency-path: ./rpgsaga/foxfox/yarn.lock
- name: Lint Saga
run: |
cd ./rpgsaga/saga
Expand Down
58 changes: 58 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

162 changes: 162 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions codewars/Adding Big Numbers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function add(a, b) {
let result = ''
let carry = 0
let i = a.length - 1
let j = b.length - 1

while (i >= 0 || j >= 0 || carry > 0) {
const digit1 = i >= 0 ? parseInt(a[i]) : 0
const digit2 = j >= 0 ? parseInt(b[j]) : 0
const sum = digit1 + digit2 + carry

carry = Math.floor(sum / 10)
result = (sum % 10) + result

i--
j--
}

return result
}

add()
24 changes: 24 additions & 0 deletions codewars/Anagram difference/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function anagramDifference(w1,w2){
const charCount = {}
let deletedCount = 0

for (const char of w1) {
charCount[char] = (charCount[char] || 0) + 1
}

for (const char of w2) {
if (!charCount[char]) {
deletedCount++
} else {
charCount[char]--
}
}

for (const char in charCount) {
deletedCount += charCount[char]
}

return deletedCount
}

anagramDifference()
16 changes: 16 additions & 0 deletions codewars/Array Deep Count/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function deepCount(a){
let count = 0

a.forEach((el) => {
if (Array.isArray(el)) {
count += 1
count += deepCount(el)
}else {
count += 1
}
})

return count
}

deepCount()
18 changes: 18 additions & 0 deletions codewars/Build Tower/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function towerBuilder(nFloors) {
if (nFloors === 1) return ["*"]

let newList = "*".repeat(nFloors * 2 - 1).split("")
let resArr = []

for (i = 0; i < nFloors; i++) {
resArr.push(newList.join(''));

newList[i] = " "
newList[newList.length - 1 - i] = " "
}


return resArr.reverse();
}

towerBuilder()
11 changes: 11 additions & 0 deletions codewars/Convert string to camel case/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function toCamelCase(str){
const words = str.split(/[-_]/)

for (i = 1; i < words.length; i++) {
words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1)
}

return words.join('')
}

toCamelCase()
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(word){
const lowWord = word.toLowerCase()
const charCountMap = new Map()

let newStr = ""

for (const char of lowWord) {
charCountMap.set(char, (charCountMap.get(char) || 0) + 1);
}

for (const char of lowWord) {
if (charCountMap.get(char) === 1) {
newStr += '(';
} else {
newStr += ')';
}
}

return newStr;
}

duplicateEncode()
Loading