|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
student "student"
|
|
|
|
|
|
|
|
"github.com/01-edu/public/go/tests/lib"
|
|
|
|
)
|
|
|
|
|
|
|
|
func isAnagram(s, t string) bool {
|
|
|
|
alph := make([]int, 26)
|
|
|
|
for i := 0; i < len(s); i++ {
|
|
|
|
if s[i] < 'a' || s[i] > 'z' {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
alph[s[i]-'a']++
|
|
|
|
}
|
|
|
|
for i := 0; i < len(t); i++ {
|
|
|
|
if t[i] < 'a' || t[i] > 'z' {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
alph[t[i]-'a']--
|
|
|
|
}
|
|
|
|
for i := 0; i < 26; i++ {
|
|
|
|
if alph[i] != 0 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
table := [][2]string{
|
|
|
|
{"listen", "silent"},
|
|
|
|
{"alem", "school"},
|
|
|
|
{"neat", "a net"},
|
|
|
|
{"anna madrigal", "a man and a girl"},
|
|
|
|
{"abcc", "abcd"},
|
|
|
|
{"aaaac", "caaaa"},
|
|
|
|
{"", ""},
|
|
|
|
{" ", ""},
|
|
|
|
{"lyam", "meow"},
|
|
|
|
{"golang", "lang go"},
|
|
|
|
{"verylongword", "v e r y l o n g w o r d"},
|
|
|
|
{"chess", "ches"},
|
|
|
|
{"anagram", "nnagram"},
|
|
|
|
{"chess", "board"},
|
|
|
|
{"mmm", "m"},
|
|
|
|
{"pulp", "fiction"},
|
|
|
|
}
|
|
|
|
for i := 0; i < 15; i++ {
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
table = append(table, [2]string{
|
|
|
|
lib.RandStr(lib.RandIntBetween(15, 20), "qwertyuiopasdfghjklzxcvbnm "),
|
|
|
|
lib.RandStr(lib.RandIntBetween(15, 20), "qwertyuiopasdfghjklzxcvbnm "),
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, arg := range table {
|
|
|
|
lib.Challenge("IsAnagram", student.IsAnagram, isAnagram, arg[0], arg[1])
|
|
|
|
}
|
|
|
|
}
|