Interesting, reminds me of a practical exam we had in intro to programming class that was taught in Java. We were asked to implement a FIFO data structure class with methods push and pop (something along these lines).
We'd just learned about OO principles and extending classes the week before. After reading the task for the practical I nervously raised my hand, "Would it be acceptable to just extend array list and create methods just named as described but using the existing methods?" The teacher kind of looked at me blankly and said yes.
I was the first person finished, no one else apparently thought of that approach. I'm not a programmer, but given that we'd just discussed this days before it seemed like an obvious solution...
The exam was probably mostly about the algorithms involved in managing FIFO data. Whether you extend an array list or create a custom class wrapping a buffer does not change the algorithm. Hence the blank look from the teacher.
Keyword there being exam. I think that's a great approach for a high-enough level course; that is, let the students do whatever they want with whatever language they want in the assignments (hard to generalize a build-test-diff system though for submissions), then test concepts on the test.
I have a friend in a Python intro whose assignment was to make a program encrypting user input with the Caesar Cipher and (optionally) decrypting, and optionally supporting ROT13 as well. I'm pretty sure the teacher wanted them using ord(), chr(), for loops, etc., but the solution I suggested after my friend tried that way is much simpler:
import string
normal = 'abcd...ABCD...'
caesar = 'defg...DEFG...'
caesar_table = string.maketrans(normal, caesar)
reverse_caesar_table = string.maketrans(caesar, normal)
msg.translate(caesar_table) # for encryption
msg.translate(reverse_caesar_table) # for decryption
Add in string.ascii_letters, string.ascii_uppercase, string.ascii_lowercase, and collections.deque (for string rotation) to generalize the alphabet sets, it was all very simple. And used a completely different 'algorithm' of a translation table that's done in C and performs super-fast, easily handles non-ascii characters (since the translation just leaves them alone), easily generalizable to whatever simple encryption scheme, etc.
Of course my friend doesn't want to learn programming therefore everything's complicated and she doesn't remember anything and even after 6 months which ends in a couple weeks I doubt she could do FizzBuzz. :(
We'd just learned about OO principles and extending classes the week before. After reading the task for the practical I nervously raised my hand, "Would it be acceptable to just extend array list and create methods just named as described but using the existing methods?" The teacher kind of looked at me blankly and said yes.
I was the first person finished, no one else apparently thought of that approach. I'm not a programmer, but given that we'd just discussed this days before it seemed like an obvious solution...