Data update

This commit is contained in:
Ingy döt Net 2025-02-27 18:35:13 -05:00
parent 8e4e15fa56
commit 72eb4943cb
1853 changed files with 35514 additions and 9441 deletions

View file

@ -0,0 +1,15 @@
{ wrd = $0
rwrd = ""
for (i=length(wrd); i>0; --i)
rwrd = rwrd substr(wrd,i,1)
if (rwrd == wrd)
palindromes += 1
else if ( seen[rwrd] ) {
if (++pairs < 7)
print wrd " " rwrd
} else
seen[wrd] = wrd
}
END {
print pairs " pairs, " palindromes " palindromes."
}

View file

@ -1,17 +1,8 @@
require "set"
UNIXDICT = File.read("unixdict.txt").lines
def word?(word : String)
UNIXDICT.includes?(word)
end
# is it a word and is it a word backwards?
semordnilap = UNIXDICT.select { |word| word?(word) && word?(word.reverse) }
# consolidate pairs like [bad, dab] == [dab, bad]
final_results = semordnilap.map { |word| [word, word.reverse].to_set }.uniq
# sets of N=1 mean the word is identical backwards
# print out the size, and 5 random pairs
puts final_results.size, final_results.sample(5)
words = File.read("unixdict.txt").each_line.to_set
semordnilap = words.compact_map {|word|
reversed = word.reverse
if word < reversed && words.includes? reversed
{ word, reversed }
end
}
p semordnilap.size, semordnilap.sample(5)

View file

@ -8,7 +8,7 @@ func$ reverse s$ .
for i = 1 to len a$[] div 2
swap a$[i] a$[len a$[] - i + 1]
.
return strjoin a$[]
return strjoin a$[] ""
.
func search s$ .
max = len w$[] + 1

View file

@ -0,0 +1,38 @@
#plist NSAppTransportSecurity @{NSAllowsArbitraryLoads:YES}
local fn Dictionary as CFArrayRef
CFURLRef url = fn URLWithString( @"http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" )
CFStringRef string = fn StringWithContentsOfURL( url, NSASCIIStringEncoding, NULL )
end fn = fn StringComponentsSeparatedByCharactersInSet( string, fn CharacterSetNewlineSet )
local fn ReverseString( inString as CFStringRef ) as CFStringRef
CFMutableStringRef outString = fn MutableStringNew
for long index = len(inString) - 1 to 0 step -1
MutableStringAppendString( outString, mid(inString,index,1) )
next
end fn = outString
void local fn Doit
CFMutableArrayRef pairs = fn MutableArrayNew
CFArrayRef words = fn Dictionary
NSUInteger count = len(words), i, index
for i = 0 to count - 2
CFStringRef wd1 = words[i]
CFStringRef wd2 = fn ReverseString( wd1 )
index = fn ArrayIndexOfObjectInRange( words, wd2, fn CFRangeMake( i+1, count-(i+1) ) )
if ( index != NSNotFound ) then MutableArrayAddObject( pairs, @{@"wd1":wd1,@"wd2":wd2} )
next
text ,,,,, 60
for i = 1 to 5
count = len(pairs)
index = rnd(count)-1
CFDictionaryRef dict = pairs[index]
print dict[@"wd1"],dict[@"wd2"]
MutableArrayRemoveObjectAtIndex( pairs, index )
next
end fn
fn DoIt
HandleEvents