about | help | code help+videos | done | prefs |
testIt
Remember ABC blocks? Take a 2D array of ABC blocks (like the ones when you were a kid), and see if you can build a word with them. There are 13 blocks with two letters on each block.A complete alphabet is guaranteed amongst all sides of the blocks. Task: Write a method that takes a string (word) and determines whether the word can be spelled with the given collection of blocks. Do NOT "hardcode" any if statements with block letters in your code. The code should work with ANY collection of blocks, just use the following example for this program. Copy and paste the following code to create the block array: String[][] letters={ {"A","Z"}, {"B","O"}, {"E","I"}, {"J","V"}, {"P","C"}, {"H","K"}, {"Q","S"}, {"L","W"}, {"D","R"}, {"T","X"}, {"U","F"}, {"M","Y"}, {"G","N"}, }; The rules are simple: Once a letter on a block is used that block cannot be used again. The function should be case-sensitive. testIt("A") → true testIt("BOOK") → false testIt("BLACK") → true ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 100 Post-solution available
Copyright Nick Parlante 2017 - privacy