+ All Categories
Home > Education > Google Applied CS - Day 1

Google Applied CS - Day 1

Date post: 14-Apr-2017
Category:
Upload: harsh-vakharia
View: 217 times
Download: 0 times
Share this document with a friend
18
GOOGLE'S APPLIED CS WITH ANDROID DAY 1
Transcript

GOOGLE'S

APPLIED CSWITH ANDROID

DAY 1

ANAGRAMS

WHAT IS AN ANAGRAM?An anagram is a word formed by rearranging the letters of another

word.— Wikipedia

EXAMPLECinema is an anagram of iceman.

MECHANICS1. Provide user a word from the dictionary.

2. The user tries to create as many words as possible that contain all the letters of the given word plus one additional letter.

3. The user can give up and see the words that they did not guess.

CATCHThe addition of extra letter at the beginning or the end without

reordering the other letters is not valid.

MEANINGIf the game picks the word 'ore' as a starter, the user might guess

'rose' or 'zero' but not 'sore'.

i.e.

1. rose ✅2. s(ore) ❌

STARTER CODE

ANAGRAMDICTIONARY'S CONSTRUCTORWHAT IS NEEDED?

1. Word validation2. Random word selection3. Get word's anagrams

4. Get words by length (ext)

WORD VALIDATIONSet<String> wordSet = new HashSet<>();

ACCESS TIME: O(1)

RANDOM WORD SELECTIONArrayList<String> wordList = new ArrayList<>();

RANDOM ACCESS TIME: O(1)

GET WORD'S ANAGRAMSMap<String, ArrayList<String>> lettersToWord = new HashMap<>();

ACCESS TIME: O(1)

GET WORDS BY LENGTHMap<Integer, ArrayList<String>> sizeToWords = new HashMap<>();

SCARNE'S DICE

RULES1. if they roll a 1, score no points and lose their turn

2. if they roll a 2 to 6:▸ add the rolled value to their points

▸ choose to either reroll or keep their score and end their turn

STARTER CODE

THIS IS IT FOR TODAY

ANY DOUBTS?


Recommended