-
Notifications
You must be signed in to change notification settings - Fork 82
Polymorphism #84
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
Krovaldo
wants to merge
6
commits into
ISUCT:Ivanov_Aleksej_Alekseevich
Choose a base branch
from
Krovaldo:Polymorphism
base: Ivanov_Aleksej_Alekseevich
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Polymorphism #84
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
969aabc
codewars+mathFunc+Classes
Krovaldo b41f0ba
lintFixes
Krovaldo 59a3248
lintFixes2
Krovaldo 97d5494
calcFunc tests fix
Krovaldo dae0426
Made abstract class Animal
Krovaldo e848b9a
fixed polymorphism, functionCalculate and codewars
Krovaldo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| function deepCount(a){ | ||
| let count = 0; | ||
| for (let elem of a){ | ||
| if(Array.isArray(elem)){ | ||
| count += 1 | ||
| count +=deepCount(elem); | ||
| } else { | ||
| count++; | ||
| } | ||
|
|
||
| } | ||
| return count; | ||
| } | ||
|
|
||
| console.log(deepCount([[], 1, 2, 3])) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module buildTower | ||
|
|
||
| go 1.22.6 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package main | ||
|
|
||
| import "fmt" | ||
|
|
||
| func BuildTower(floors int) []string { | ||
| tower := make([]string, floors) | ||
|
|
||
| for i := 0; i < floors; i++ { | ||
|
|
||
| stars := 2*i + 1 | ||
| spaces := floors - i - 1 | ||
|
|
||
| line := "" | ||
|
|
||
| for j := 0; j < spaces; j++ { | ||
| line += " " | ||
| } | ||
|
|
||
| for j := 0; j < stars; j++ { | ||
| line += "*" | ||
| } | ||
|
|
||
| for j := 0; j < spaces; j++ { | ||
| line += " " | ||
| } | ||
| tower[i] = line | ||
| } | ||
| return tower | ||
| } | ||
|
|
||
| func main() { | ||
| new := BuildTower(10) | ||
|
|
||
| for _, row := range new { | ||
| fmt.Println(row) | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module camelcase | ||
|
|
||
| go 1.22.6 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
| ) | ||
|
|
||
| func ToCamelCase(s string) string { | ||
| if len(s) == 0 { | ||
| return "" | ||
| } | ||
| result := strings.Builder{} | ||
| var nextUpper bool | ||
| result.WriteByte(s[0]) | ||
| newS := s[1:] | ||
| for _, v := range []byte(strings.TrimSpace(newS)) { | ||
| if v == ' ' || v == '-' || v == '_' { | ||
| nextUpper = true | ||
| continue | ||
| } | ||
| if nextUpper { | ||
| v = ToUpper(v) | ||
| nextUpper = false | ||
| } | ||
| result.WriteByte(v) | ||
| } | ||
| return result.String() | ||
| } | ||
|
|
||
| func ToUpper(b byte) byte { | ||
| if b >= 'a' && b <= 'z' { | ||
| return b - 'a' + 'A' | ||
| } | ||
| return b | ||
| } | ||
|
|
||
| func main() { | ||
| var str string | ||
| fmt.Scan(&str) | ||
| res := ToCamelCase(str) | ||
| fmt.Println(res) | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module dublEnc | ||
|
|
||
| go 1.22.6 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
| ) | ||
|
|
||
| func DuplicateEncode(word string) string { | ||
| freqMap := make(map[rune]int) | ||
| for _, char := range strings.ToLower(word) { | ||
| freqMap[char]++ | ||
| } | ||
| var finalString strings.Builder | ||
| for _, char := range strings.ToLower(word) { | ||
| if freqMap[char] == 1 { | ||
| finalString.WriteString("(") | ||
| } else { | ||
| finalString.WriteString(")") | ||
| } | ||
| } | ||
| return finalString.String() | ||
| } | ||
|
|
||
| func main() { | ||
| fmt.Println(DuplicateEncode("Hello")) | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module findmissingletter | ||
|
|
||
| go 1.22.6 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package main | ||
|
|
||
| import "fmt" | ||
|
|
||
| func FindMissingLetter(chars []rune) rune { | ||
| var missingLetter int32 | ||
| for i := 0; i < len(chars)-1; i++ { | ||
| if chars[i+1]-chars[i] != 1 { | ||
| missingLetter = chars[i+1] - 1 | ||
| } | ||
| } | ||
| return missingLetter | ||
| } | ||
|
|
||
| func main() { | ||
| slice := []rune{'a', 'b', 'c', 'e'} | ||
| fmt.Print(FindMissingLetter(slice)) | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package main | ||
|
|
||
| func merge(arr1, arr2 []interface{}) []interface{} { | ||
| var result []interface{} | ||
| length1 := len(arr1) | ||
| length2 := len(arr2) | ||
| maxLength := length1 | ||
| if length2 > length1 { | ||
| maxLength = length2 | ||
| } | ||
|
|
||
| for i := 0; i < maxLength; i++ { | ||
| if i < length1 { | ||
| result = append(result, arr1[i]) | ||
| } | ||
| if i < length2 { | ||
| result = append(result, arr2[i]) | ||
| } | ||
| } | ||
| return result | ||
| } | ||
|
|
||
| func main() { | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| function mergeArrays(arr1, arr2) { | ||
| let result = []; | ||
| let maxLength = Math.max(arr1.length, arr2.length); | ||
|
|
||
| for (let i = 0; i < maxLength; i++) { | ||
| if (i < arr1.length) { | ||
| result.push(arr1[i]); | ||
| } | ||
| if (i < arr2.length) { | ||
| result.push(arr2[i]); | ||
| } | ||
| } | ||
| return result; | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package main | ||
|
|
||
| func MoveZeros(arr []int) []int { | ||
| nonZero := []int{} | ||
| countZero := 0 | ||
|
|
||
| for _, num := range arr { | ||
| if num != 0 { | ||
| nonZero = append(nonZero, num) | ||
| } else { | ||
| countZero++ | ||
| } | ||
| } | ||
|
|
||
| for i := 0; i < countZero; i++ { | ||
| nonZero = append(nonZero, 0) | ||
| } | ||
|
|
||
| return nonZero | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module rootdigit | ||
|
|
||
| go 1.22.6 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package main | ||
|
|
||
| import "fmt" | ||
|
|
||
| func DigitalRoot(n int) int { | ||
| for n > 9 { | ||
| n = sumDigits(n) | ||
| } | ||
| return n | ||
| } | ||
|
|
||
| func sumDigits(n int) int { | ||
| var sum int | ||
| for n > 0 { | ||
| sum += n % 10 | ||
| n = n / 10 | ||
| } | ||
| return sum | ||
| } | ||
|
|
||
| func main() { | ||
| num := DigitalRoot(12345) | ||
| fmt.Print(num) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
такое же действие на 8 строчке