new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
21
Task/Ordered-words/CoffeeScript/ordered-words-1.coffee
Normal file
21
Task/Ordered-words/CoffeeScript/ordered-words-1.coffee
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
ordered_word = (word) ->
|
||||
for i in [0...word.length - 1]
|
||||
return false unless word[i] <= word[i+1]
|
||||
true
|
||||
|
||||
show_longest_ordered_words = (candidates, dict_file_name) ->
|
||||
words = ['']
|
||||
for word in candidates
|
||||
continue if word.length < words[0].length
|
||||
if ordered_word word
|
||||
words = [] if word.length > words[0].length
|
||||
words.push word
|
||||
return if words[0] == '' # we came up empty
|
||||
console.log "Longest Ordered Words (source=#{dict_file_name}):"
|
||||
for word in words
|
||||
console.log word
|
||||
|
||||
dict_file_name = 'unixdict.txt'
|
||||
file_content = require('fs').readFileSync dict_file_name
|
||||
dict_words = file_content.toString().split '\n'
|
||||
show_longest_ordered_words dict_words, dict_file_name
|
||||
18
Task/Ordered-words/CoffeeScript/ordered-words-2.coffee
Normal file
18
Task/Ordered-words/CoffeeScript/ordered-words-2.coffee
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
> coffee ordered_words.coffee
|
||||
Longest Ordered Words (source=unixdict.txt):
|
||||
abbott
|
||||
accent
|
||||
accept
|
||||
access
|
||||
accost
|
||||
almost
|
||||
bellow
|
||||
billow
|
||||
biopsy
|
||||
chilly
|
||||
choosy
|
||||
choppy
|
||||
effort
|
||||
floppy
|
||||
glossy
|
||||
knotty
|
||||
Loading…
Add table
Add a link
Reference in a new issue