Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/ABC-problem/UTFool/abc-problem-2.utfool
Normal file
34
Task/ABC-problem/UTFool/abc-problem-2.utfool
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
···
|
||||
http://rosettacode.org/wiki/ABC_Problem
|
||||
···
|
||||
import java.util.Arrays
|
||||
import java.util.Collections
|
||||
import java.util.List
|
||||
■ ABC
|
||||
§ static
|
||||
▶ main
|
||||
• args⦂ String[]
|
||||
blocks⦂ List⟨String⟩:
|
||||
Arrays.asList "BO", "XK", "DQ", "CP", "NA",
|
||||
"GT", "RE", "TG", "QD", "FS",
|
||||
"JW", "HU", "VI", "AN", "OB",
|
||||
"ER", "FS", "LY", "PC", "ZM"
|
||||
words⦂ List⟨String⟩:
|
||||
Arrays.asList "A", "BARK", "BOOK", "TREAT",
|
||||
"COMMON", "SQUAD", "CONFUSE"
|
||||
for each word in words
|
||||
System.out.println "⸨word⸩: ⸨canMakeWord word, blocks⸩"
|
||||
|
||||
▶ canMakeWord⦂ boolean
|
||||
• word⦂ String
|
||||
• blocks⦂ List⟨String⟩
|
||||
if word.isEmpty°
|
||||
return true
|
||||
for each block #i in blocks⦂ String
|
||||
if 0 ≤ block.indexOf word.charAt 0
|
||||
Collections.swap blocks, 0, i
|
||||
if canMakeWord (word.substring 1),
|
||||
blocks.subList 1, blocks.size°
|
||||
return true
|
||||
Collections.swap blocks, 0, i
|
||||
return false
|
||||
Loading…
Add table
Add a link
Reference in a new issue