Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
46
Task/Ordered-words/PureBasic/ordered-words.basic
Normal file
46
Task/Ordered-words/PureBasic/ordered-words.basic
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
Procedure.s sortLetters(*word.Character, wordLength) ;returns a string with the letters of a word sorted
|
||||
Protected Dim letters.c(wordLength)
|
||||
Protected *letAdr = @letters()
|
||||
|
||||
CopyMemoryString(*word, @*letAdr)
|
||||
SortArray(letters(), #PB_Sort_Ascending, 0, wordLength - 1)
|
||||
ProcedureReturn PeekS(@letters(), wordLength)
|
||||
EndProcedure
|
||||
|
||||
Structure orderedWord
|
||||
word.s
|
||||
length.i
|
||||
EndStructure
|
||||
|
||||
Define filename.s = "unixdict.txt", fileNum = 0, word.s
|
||||
|
||||
If OpenConsole()
|
||||
NewList orderedWords.orderedWord()
|
||||
If ReadFile(fileNum, filename)
|
||||
While Not Eof(fileNum)
|
||||
word = ReadString(fileNum)
|
||||
If word = sortLetters(@word, Len(word))
|
||||
AddElement(orderedWords())
|
||||
orderedWords()\word = word
|
||||
orderedWords()\length = Len(word)
|
||||
EndIf
|
||||
Wend
|
||||
Else
|
||||
MessageRequester("Error", "Unable to find dictionary '" + filename + "'")
|
||||
End
|
||||
EndIf
|
||||
|
||||
SortStructuredList(orderedWords(), #PB_Sort_Ascending, OffsetOf(orderedWord\word), #PB_String)
|
||||
SortStructuredList(orderedWords(), #PB_Sort_Descending, OffsetOf(orderedWord\length), #PB_Integer)
|
||||
Define maxLength
|
||||
FirstElement(orderedWords())
|
||||
maxLength = orderedWords()\length
|
||||
ForEach orderedWords()
|
||||
If orderedWords()\length = maxLength
|
||||
Print(orderedWords()\word + " ")
|
||||
EndIf
|
||||
Next
|
||||
|
||||
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
Loading…
Add table
Add a link
Reference in a new issue