floccinaucinihilipilification

and palindromes

10/18

Warm Up

Letters of a Word

Go to this starter project and read and run the script. Once you understand how it works, modify the script so that the sprite says every letter in the word.

Once you have completed this prepare for a group discussion about what you just worked on. Skip ahead to the "droW a fo sretteL" exercise below if you finish with extra time.

Group review of the Warm Up

We will be white boarding ideas for how we can make the Warm Up answer work for any word and reviewing list traversal.

droW a fo sretteL

Revisit your solution from the Warm Up exercise and modify it so that it does the following:

  • Takes a word from the user.
  • On key press (you decide which), print out each letter of the provided word individually. This should work for any word.
  • On key press (you decide which), print out each letter of the provided word individually in reverse order


****BONUS**** If you finish these with time to spare, try creating a custom block that returns the provided word BACKWARDS. So, if I were to give the custom block the word "Yoda" it would report "adoY".

4.2 and 4.3

For our lab time let's continue working on the 4.2 and 4.3 assignments. As you have questions make sure to ask neighbors for help and to hop into my Skype office or wave me down on the big screen.

When you complete the assignments send them in with appropriate Subject lines and file names.


It is important you submit these exercises in for both grades and group review at the end of class.

A man a plan a canal panama

Palindromes are words or phrases that read the same forward as they do backwards, like the words MOM or RACECAR.

Use what you learned from our group review and warm ups today to detect if a provided input is a palindrome. Consider how you would solve the problem outside of code. Try to think of your solution in the context of an algorithm. How would you do this without a computer?

First create a custom block that takes in a word or phrase and outputs a boolean TRUE if the value is a palindrome and False if it is not.





You may have issues with phrases containing spaces that mess the whole thing up. For these problems think about what would make your job easier. No spaces! How would you delete all the spaces from a sentence? Could you create a script that takes a value and returns that same value with all of the spaces removed? Try removing all of the spaces of the input and then using your earlier code to test if it is a palindrome.


Premature Optimization

This question is one that appears in professional programmer interviews. The reason being that there are many ways to solve this and once you have an answer there is normally extra changes you can make to your solution that make it even faster. Think of how many steps your code is taking and welcome the challenge of trying to make it perform LESS steps. (** here I refer to steps as how many times you iterate through a loop, for instance a repeat[2] block would be considered 2 steps)

For the word MOM I can think of solutions that would take 6 steps, 3 steps, and a solution that takes only 2 steps.