Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
25
Task/Eertree/FutureBasic/eertree.basic
Normal file
25
Task/Eertree/FutureBasic/eertree.basic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
BOOL local fn IsPalindrome( string as CFStringRef )
|
||||
CFStringRef revString = @""
|
||||
for long i = len(string) - 1 to 0 step -1
|
||||
revString = concat( revString, mid( string, i, 1 ) )
|
||||
next
|
||||
end fn = ( fn StringLocalizedCaseInsensitiveCompare( string, revString ) == NSOrderedSame )
|
||||
|
||||
void local fn DoEertree( wrd as CFStringRef )
|
||||
mda_clear
|
||||
long length = len(wrd)
|
||||
for long i = 0 to length - 1
|
||||
for long j = 1 to length
|
||||
CFStringRef string = mid( wrd, i, j )
|
||||
if ( fn IsPalindrome( string ) )
|
||||
long index = mda_find , string
|
||||
if ( index == NSNotFound ) then mda_add = string
|
||||
end if
|
||||
next
|
||||
next
|
||||
print mda_text
|
||||
end fn
|
||||
|
||||
fn DoEertree( @"eertree" )
|
||||
|
||||
HandleEvents
|
||||
31
Task/Eertree/V-(Vlang)/eertree.v
Normal file
31
Task/Eertree/V-(Vlang)/eertree.v
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import arrays
|
||||
|
||||
struct PalFinder {
|
||||
mut:
|
||||
str string
|
||||
pal []string
|
||||
}
|
||||
|
||||
fn (mut pf PalFinder) is_palindrome(word string) bool {
|
||||
if word == word.runes().reverse().string() { return true }
|
||||
return false
|
||||
}
|
||||
|
||||
fn (mut pf PalFinder) process_palindromes() {
|
||||
for nir := 0; nir < pf.str.len; nir++ {
|
||||
for mir := 1; mir <= pf.str.len - nir; mir++ {
|
||||
str_pal := pf.str.substr_ni(nir, mir)
|
||||
if pf.is_palindrome(str_pal) && str_pal !="" { pf.pal << str_pal }
|
||||
}
|
||||
}
|
||||
pf.pal = arrays.uniq[string](pf.pal.sorted())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
mut pf := PalFinder{}
|
||||
pf.str = "eertree"
|
||||
pf.process_palindromes()
|
||||
println("Processing string: '${pf.str}'")
|
||||
println("Number of sub-palindromes: ${pf.pal.len}")
|
||||
println("Sub-palindromes: ${pf.pal}")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue