Challenge
Write the shortest program that implements the minimum requirements for a linked list, stack and queue.
Minimum requirements
- Functions that allow the user to add and remove elements from the linked list, stack and queue.
- Any data type can be added to the linked list, stack and queue (string, int, etc.).
- One special function (e.g. sort letters alphabetically).
- The program must work (compile without errors and operations and results should make sense in the context of linked lists, stacks and queues)!
- Lastly, this program must be hard-coded. Arrays, however, are allowed (please refer to the restrictions section).
Winning criteria
- Standard Codegolf rules.
- Number of characters based on the summation of characters for linked list, stack and queue.
Restrictions
- No trivial answers (i.e. 0 or 1 for a stack based language).
- You are allowed to write the program in any language except for stack-based languages (let me know if this is unfair).
- You cannot simply use the functions of another class. If a language (like Ruby) already has
push
andpop
functions in arrays or any other class, you must write your ownpush
andpop
functions.
Little blurb: If this code golf challenge is too simple, I will add more requirements. I'm also open to any suggestions.
class A extends java.util.Stack {}
? \$\endgroup\$push
,pop
, andshift
, so technically arrays are stacks and queues. They behave like linked lists, because linked lists are basically just arrays, so the default array already pretty much meets these requirements... \$\endgroup\$