A small scratch collection of competitive-programming and recursion practice — mostly Ruby, with a couple of ported variants.
A handful of solutions and experiments from Aizu Online Judge (AOJ) and paiza, plus some self-study scripts.
| File | Demonstrates |
|---|---|
ITP1_1_B.rb |
The classic "cube of an integer" warm-up — reading input and printing n**3. |
vol2000.rb |
A grid simulation: moving a set of points by N/S/E/W directions and removing any that reach a target cell. |
| File | Demonstrates |
|---|---|
D005.rb |
Reopening Integer with a repeat method built on Enumerator to lazily generate an arithmetic sequence. |
D009.rb |
Trivial difference of two whitespace-separated integers. |
Hanoi.rb |
Recursive Tower of Hanoi that prints every move (depends on starter.rb). |
Hanoi2.rb |
A variant that only prints the board at a specified step number. |
hanoi.js |
The same Hanoi solver ported to JavaScript. |
hanoi.lisp |
The same Hanoi solver ported to Common Lisp. |
integer.rb |
Monkey-patching Integer#! to compute factorial (5.!). |
Mod7.rb |
A combinatorics count: triples whose sum is divisible by 7, using bucket counts and factorial deduplication. |
my_script.rb |
A one-line curiosity — a script that re-invokes itself with system. |
POH6plus.rb |
String puzzle building a palindrome from reversible-pair words. |
recursion.rb |
A minimal recursive factorial that prints each step. |
starter.rb |
Shared helpers: a Range#each patched to count downward, String#to_ia for parsing int arrays, and gets_ia. |
Each script reads from standard input and prints to standard output, matching the judge it was written for.
# Ruby
ruby aoj/ITP1_1_B.rb # then type input, e.g. 3
echo 3 | ruby aoj/ITP1_1_B.rb
# The Hanoi scripts require starter.rb (already require'd via a relative path)
echo 3 | ruby paiza/Hanoi.rb
# JavaScript variant (the original used a Rhino-style print(); adapt as needed)
node paiza/hanoi.js
# Common Lisp variant (e.g. with SBCL)
sbcl --script paiza/hanoi.lisp 3.
├── aoj/
│ ├── ITP1_1_B.rb
│ └── vol2000.rb
└── paiza/
├── D005.rb
├── D009.rb
├── Hanoi.rb
├── Hanoi2.rb
├── hanoi.js
├── hanoi.lisp
├── integer.rb
├── Mod7.rb
├── my_script.rb
├── POH6plus.rb
├── recursion.rb
└── starter.rb
Migrated from Bitbucket. Commit history preserved as-is.
