Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
15
Task/ABC-Problem/CoffeeScript/abc-problem.coffee
Normal file
15
Task/ABC-Problem/CoffeeScript/abc-problem.coffee
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
canMakeWord = (word="") ->
|
||||
# Create a shallow clone of the master blockList
|
||||
blocks = blockList.slice 0
|
||||
# Check if blocks contains letter
|
||||
checkBlocks = (letter) ->
|
||||
# Loop through every remaining block
|
||||
for block, idx in blocks
|
||||
# If letter is in block, blocks.splice will return an array, which will evaluate as true
|
||||
return blocks.splice idx, 1 if letter.toUpperCase() in block
|
||||
return false
|
||||
# Return true if there are no falsy values
|
||||
return false not in (checkBlocks letter for letter in word)
|
||||
|
||||
# Expect true, true, false, true, false, true, true, true
|
||||
console.log (canMakeWord word for word in ["A", "BARK", "BOOK", "TREAT", "COMMON", "squad", "CONFUSE", "STORM"])
|
||||
Loading…
Add table
Add a link
Reference in a new issue