The 20% Rule:
“In every introduction to programming course, 20% of the students just get it effortlessly – you could lock them in a dimly lit closet with a reference manual, and they’d still figure out how to program.
Another 20% of the class never seems to get it.”
Praxis is the process by which a theory, lesson, or skill is enacted, practiced, embodied and realized.
The best people in any field are those who devote the most hours to what the researchers call “deliberate practice”. It’s activity that’s explicitly intended to improve performance, that reaches for objectives just beyond one’s level of competence, provides feedback on results and involves high levels of repetition and reflection.
– Geoffrey Colvin
Kata (方 literally: form) is a Japanese word describing a way of doing something or a pattern of behaviour that is practiced to various levels of mastery.
A Code Kata is an exercise in programming which helps hone your skills through practice and repetition.
Overlearning the basics allows our students to excel at the more difficult tasks.
“Learners will implement an e-commerce system using the Ruby on Rails web-programming framework through a series of graduated assignments.”
Demo of Final Assignment: http://ghostydepot.heroku.com
Ruby is a dynamically-typed scripting language similar to Perl, Python and Bash.
Try reading the following Ruby code out loud:
4.times { puts "Chunky Bacon!" }
Students need to master:
Create a program that prints your initials to the console using nine rows of asterisks.
** *** * *******
** *** *** *********
** *** ** ** ** **
** *** ** ** **
***** ********* ** ***
** *** *********** ** *****
** *** ** ** ** **
** *** ** ** **********
** *** * * ********
Simple, but ensure that students can run code and print strings.
carl = {
:start => 'We are a way',
:middle => ' for the cosmos ',
:punctuation => [ ',', '.', '?' ]
}
sagan = [
"to ",
"know ",
"itself"
]
Use the provided Hash and Array to print out:
“We are a way for the cosmos to know itself.”
sentence = carl[:start] + carl[:middle]
sentence += sagan[0] + sagan[1] + sagan[2]
sentence += carl[:punctuation][1]
puts sentence
Generate an array that contains 20 random numbers.
Once the array is built, iterate through its elements printing out the value of twice each number.
random_numbers = Array.new
20.times { random_numbers << rand(100) }
random_numbers.each { |num| puts 2 * num }
Start by coding a program that print every number from 1 to 100 to seperate lines in the console.
Next, modify your code so that:
See: Fizz Buzz Posters
1.upto(100) do |n|
print "Wowza" if wowza = (n % 3).zero?
print "Cowza" if cowza = (n % 5).zero?
print n unless (wowza || cowza)
puts
end
There is a famous mathematical sequence of numbers called the Fibonacci sequence.
The beginning of the sequence goes like this:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144…
Starting with the first two numbers (zero and one) the rest of the sequence can be calculated:
Each number (after the first two) is calculated by summing the previous two numbers.
# Recursive
def fib(n)
return n if (0..1).include? n
fib(n-1) + fib(n-2)
end
# Iterative
def fib(n)
curr, succ = 0, 1
n.times do |i|
curr, succ = succ, curr + succ
end
curr
end
A Secret Code:
rwpeitg x. sdlc iwt gpqqxi-wdat
paxrt lph qtvxccxcv id vti ktgn ixgts du hxiixcv qn wtg hxhitg dc iwt
qpcz, pcs du wpkxcv cdiwxcv id sd: dcrt dg ilxrt hwt wps ettets xcid iwt
qddz wtg hxhitg lph gtpsxcv, qji xi wps cd exrijgth dg rdcktghpixdch xc
xi, 'pcs lwpi xh iwt jht du p qddz,' iwdjvwi paxrt 'lxiwdji exrijgth dg
rdcktghpixdc?'
hd hwt lph rdchxstgxcv xc wtg dlc bxcs (ph ltaa ph hwt rdjas, udg iwt
wdi spn bpst wtg utta ktgn hatten pcs hijexs), lwtiwtg iwt eatphjgt
du bpzxcv p spxhn-rwpxc ldjas qt ldgiw iwt igdjqat du vtiixcv je pcs
exrzxcv iwt spxhxth, lwtc hjsstcan p lwxit gpqqxi lxiw excz tnth gpc
radht qn wtg.
Every character has been shifting by a set number of alphabet positions.
Terse Obfuscated Solution:
s = IO.read('code.txt')
shift = ('e'.ord - ('a'..'z').reduce(['',0]) do |m, l|
s.count(l) > m[1] ? [l, s.count(l)] : m
end[0].ord) % 26
puts s.tr('a-z', (('a'..'z').to_a*2)[shift...shift+26].join)
As instructors we should be coding on a regular basis too.
The easiest way to do this is to live code in class. Your students will want to code along which means super engagement.
YOU WILL MAKE MISTAKES. THIS IS AWESOME FOR TEACHING DEBUGGING!
If you do any coding outside of work, share your successes with your students.
For example: You could maintain a Github Repo.
Oodles of coding challenge examples: