Commits

Steven! Ragnarök committed 49516b4

Initial commit.

  • Participants

Comments (0)

Files changed (12)

13/complex_board.txt

+bK -- -- -- -- bB -- --
+-- -- -- -- -- bP -- --
+-- bP wR -- wB -- bN --
+wN -- bP bR -- -- -- wP
+-- -- -- -- wK wQ -- wP
+wR -- bB wN wP -- -- --
+-- wP bQ -- -- wP -- --
+-- -- -- -- -- wB -- --

13/complex_moves.txt

+b2 b3
+f2 b7
+b4 a8
+a8 g5
+b2 b4
+h7 f6
+e3 b1
+b7 e4
+b2 b5
+g7 g2
+f7 f8
+g7 e8
+f5 g5
+f7 f6
+c3 a2
+e1 c1
+f7 f5
+g8 c6
+b2 d5
+f7 f4
+f6 f3
+c5 f4
+b6 a5
+c3 d7
+b2 f6
+e4 d8
+d2 g6
+b2 c3
+a3 g5
+h6 e8
+d3 b5
+d6 f3
+c5 c4
+f6 a3
+b7 c1
+f1 f1
+b6 b4
+a7 e5
+b6 c5
+c2 e7
+d4 f5
+a7 g8
+a7 d1
+c5 b4
+c4 e3
+h4 h3
+b5 b2
+b2 g4
+h3 h4
+h8 d3
+h8 h7
+h2 h3
+e8 c4
+a3 a1
+d3 b5
+a3 a1
+d5 d3
+d5 f5
+b4 f6
+d5 g2
+c8 d4
+d5 b5
+c6 d5
+f3 b5
+a1 g6
+g6 e5
+d3 e6
+g6 a7
+g6 h4
+c6 d8
+a3 h8
+g8 f8
+c7 f2
+d3 c4
+a5 a4
+a5 b5
+f1 a8
+c2 g1
+e5 a4
+h5 f1
+e6 g4
+g5 h2
+c3 b2
+h2 c7
+e6 f3
+c3 c4
+f1 c4
+b3 a6
+c4 b3
+c1 h6
+a5 c5
+f4 f7
+c2 c6
+f6 g2
+d2 a1
+e4 a3
+c2 d3
+a8 c6
+d6 d1
+c2 e4
+d6 g2
+a6 a7
+c2 c4
+a8 a7
+c4 d3
+c3 h5
+b4 c7
+e6 d5
+b6 d6
+e5 f8
+f1 f6
+a8 a6
+a8 c6
+e4 e5
+h2 a5
+c8 e1
+e3 h2
+f3 h3

13/simple_board.txt

+bR bN bB bQ bK bB bN bR
+bP bP bP bP bP bP bP bP
+-- -- -- -- -- -- -- --
+-- -- -- -- -- -- -- --
+-- -- -- -- -- -- -- --
+-- -- -- -- -- -- -- --
+wP wP wP wP wP wP wP wP
+wR wN wB wQ wK wB wN wR

13/simple_moves.txt

+a2 a3
+a2 a4
+a2 a5
+a7 a6
+a7 a5
+a7 a4
+a7 b6
+b8 a6
+b8 c6
+b8 d7
+e2 e3
+e3 e2

13/simple_results.txt

+LEGAL
+LEGAL
+ILLEGAL
+LEGAL
+LEGAL
+ILLEGAL
+ILLEGAL
+LEGAL
+LEGAL
+ILLEGAL
+LEGAL
+ILLEGAL

14/complex_input.txt

+daniella_hamill: @madelyn, @concepcion_hoppe: Power is in nature the essential measure  of right
+kaia_jerde: Corresponding abstract name /cc @nella_hackett, @madelyn, @vincent
+delaney_ferry: @brook_metz: I do not readily remember any poem, play, sermon, novel, or oration, that our press vents in the last few years
+mariana: this makes botany the most alluring of studies, and wins it from the farmer and the herb-woman :D /cc @terrell_senger, @florence_vonrueden
+mariana: In nature every moment is new; the past is always swallowed and forgotten /cc @leon_greenfelder, @darrel_skiles, @madelyn
+nella_hackett: @daniella_hamill, @madelyn: After graduating from college he taught school for a time, and then entered the Harvard Divinity School
+hilton: Nothing can bring you peace but yourself
+magali: @kaia_jerde, @florence_vonrueden: The universe is fluid and volatile
+terrell_senger: These varieties are lost sight of at a little distance, at a little height of thought @emiliano_gaylord
+kaia_jerde: If the gatherer gathers too much, nature takes out of the man what she puts into his chest, swells the estate, but kills the owner /cc
+terrell_senger: @nella_hackett It's become commonplace to criticize the "Occupy" movement for failing to offer an alternative vision
+delaney_ferry: Chaucer's chief work is the "Canterbury Tales," a series of  stories told by pilgrims traveling /cc @concepcion_hoppe, @mariana, @daniella_hamill
+concepcion_hoppe: The greatest of Italian poets, author of the Divina Commedia /cc @mariana
+leta: Emerson here refers to the military operations carried on from 1808 to 1814 in Portugal, Spain, and ... /cc @terrell_senger, @darrel_skiles
+emiliano_gaylord: If a man loses his balance and immerses himself in any trades or pleasures for their own sake, he may be a good wheel or pin, but he is ...
+darrel_skiles: Society is a joint-stock company, in which the members agree, for the better securing of his bread to each shareholder /cc @concepcion_hoppe
+emiliano_gaylord: The Colossus of Rhodes was a gigantic statue--over a hundred feet in height--of the Rhodian sun god /cc @daniella_hamill, @elmo
+magali: @madelyn: He carried his powerful execution into minute details, to a hair point; finishes an eyelash or a dimple as firmly as he draws a...
+darrel_skiles: Each new step we take in thought reconciles twenty seemingly  discordant facts, as expressions of one law
+lawson_brown: The pastures are full of ghosts for me, the morning woods full of angels /cc @emiliano_gaylord, @elmo
+darrel_skiles: @lawson_brown, @brook_metz: Must we have a good understanding with one another's palates? as foolish people who have lived long together...
+elmo: Each returns to his degree in the scale of good society, porcelain remains porcelain /cc @delaney_ferry, @magali, @terrell_senger
+leta: The retribution in the circumstance is seen by the understanding; it is inseparable from the thing, but is often spread over a long time
+lawson_brown: @leon_greenfelder: So, 'tis well; Never one object underneath the sun  Will I behold before my Sophocles: Farewell; now teach the Romans ...
+magali: The swindler swindles himself
+concepcion_hoppe: @magali François Joseph Talma was a French tragic actor, to whom Napoleon showed favor
+daniella_hamill: @cruz_rice, @brook_metz, @emiliano_gaylord: It was as a record of personal experiences that he wrote in his journal: "Shakespeare fills us...
+elmo: @hilton: His manner was very quiet, his smile was pleasant, but he did not like explosive laughter any better than Hawthorne did
+darrel_skiles: @cruz_rice, @leon_greenfelder, @hilton: "Blessed be nothing" and "The worse things are, the better they are" are proverbs ...
+daniella_hamill: @leon_greenfelder: This old proverb is quoted by Sophocles
+leta: Heroism feels and never reasons, and therefore is always right; and although a different breeding, different /cc @nella_hackett, @delaney_ferry
+mariana: @kaia_jerde, @elmo: why?
+daniella_hamill: @florence_vonrueden: Translated in the previous sentence
+hilton: not sure about that /cc @emiliano_gaylord
+madelyn: It began with Henry VII /cc @nella_hackett
+madelyn: @darrel_skiles, @emiliano_gaylord, @nella_hackett: To ignorance and sin it is flint
+leon_greenfelder: @mariana: The Shakspeare Society have inquired in all directions, advertised the missing facts, offered money for any information that will
+vincent: A man is reputed to have thought and eloquence; he cannot, for all that, say a word to his cousin or his uncle
+hilton: John Lydgate was an English poet who lived a generation later than Chaucer; in his _Troy Book_ and other poems he probably borrowed fro...
+nella_hackett: @brook_metz: I see
+florence_vonrueden: @aomame A Persian poet of the fourteenth century
+vincent: @delaney_ferry, @kaia_jerde, @brook_metz: He recreates what he imitates
+madelyn: The first in time and the first in importance of the influences upon  the mind is that of nature /cc @emiliano_gaylord
+florence_vonrueden: The blindness of the preacher consisted in deferring to the base estimate of the market of what constitutes a manly success /cc @hilton
+delaney_ferry: @kaia_jerde, @terrell_senger: He claps wings to the sides of all the solid old lumber of the world, and I am capable once more of ...
+leon_greenfelder: @mariana, @delaney_ferry: The work he is best known by is the exhaustive "Essay on the Human Understanding," in which he combated the theo...
+kaia_jerde: We rapidly approach a brink over which no enemy can follow us /cc @nella_hackett, @terrell_senger, @madelyn
+hilton: The stag in the fable admired his horns and blamed his feet, but when the hunter came, his feet saved him ... /cc @kaia_jerde
+leon_greenfelder: In punishment for this Jupiter chained him to a rock and set  an eagle to prey upon his liver /cc @nella_hackett
+concepcion_hoppe: Each man's rank in that perfect graduation depends on some symmetry in his structure, or some agreement in ... /cc @nella_hackett, @leta
+leon_greenfelder: Follow the path your genius traces like the galaxy of  heaven for you to walk in /cc @leta, @cruz_rice
+daniella_hamill: Jupiter, the supreme god of Roman mythology /cc @emiliano_gaylord, @madelyn
+mariana: @nella_hackett: The same idea exalts conversation with him
+cruz_rice: Information about the Project Gutenberg Literary Archive  Foundation /cc @lawson_brown, @mariana
+emiliano_gaylord: The prudence which secures an outward well-being is not to be studied by one set of men, whilst heroism /cc @nella_hackett, @florence_vonrueden
+leta: Many economists say that what matters are questions like whether markets are competitive or monopolistic /cc @cruz_rice, @delaney_ferry, @leon_greenfelder
+emiliano_gaylord: We can find these enchantments without visiting the Como  Lake, or the Madeira Islands /cc @elmo, @lawson_brown, @vincent
+elmo: A boy is in the parlor what the pit is in the playhouse; independent, irresponsible, looking out from his corner ... /cc @hilton, @magali
+concepcion_hoppe: @vincent, @leon_greenfelder, @daniella_hamill: To refuse to discuss ideas such as types of capitalism deprives us of language
+kaia_jerde: @emiliano_gaylord After every foolish day we sleep off the fumes and furies of its hours; and though we are always engaged with particulars...
+hilton: You will find it interesting to read _Behavior_ in connection with this essay /cc @brook_metz
+florence_vonrueden: @elmo, @kaia_jerde, @delaney_ferry: The swallow over my window should interweave that thread or straw he carries in his bill into my web ...
+lawson_brown: @kaia_jerde, It is, for my money, a perfect opening: fast, funny, suspenseful
+leon_greenfelder: @elmo But if we explore the literature of Heroism, we shall quickly come to Plutarch, who is its Doctor and historian
+elmo: @lawson_brown? is a great happiness to get off without injury and heart-burning, from one who has had the ill luck to be ...
+emiliano_gaylord: Our housekeeping is mendicant, our arts, our occupations,  our marriages, our religion, we have not chosen, but society has chosen for us
+leon_greenfelder: @madelyn: What is the end sought? Plainly to secure the ends of good sense and beauty, from the intrusion of deformity or vulgarity of ...
+vincent: If I know your sect, I anticipate your argument /cc @madelyn
+darrel_skiles: @nella_hackett, @mariana: Here is perfect representation, at last; and now let the world of figures sit for their portraits
+darrel_skiles: @magali, @leta: But though we cannot find the god under this disguise of a sutler, yet, on the other hand, we cannot forgive the poet
+nella_hackett: @cruz_rice: Were the ends of nature so great and cogent, as to  exact this immense sacrifice of men?
+delaney_ferry: @leon_greenfelder, @emiliano_gaylord, @mariana: A play by the German poet, Goethe, founded on the belief that the imprisonment of Tasso was...
+delaney_ferry: That’s a nod to science fiction, where the archetypal marker of strangeness is two moons /cc @leon_greenfelder
+cruz_rice: See note 53 @daniella_hamill, @emiliano_gaylord
+florence_vonrueden: The Germans regard Goethe with the same veneration we accord to Shakespeare /cc @nella_hackett, @magali
+brook_metz: This is fundamentally a detective story, albeit a distinctly heterodox one /cc @darrel_skiles, @madelyn
+delaney_ferry: @lawson_brown: A preface or introduction

14/sample_input.txt

+alberta: @bob "It is remarkable, the character of the pleasure we derive from the best books."
+bob: "They impress us ever with the conviction that one nature wrote and the same reads." /cc @alberta
+alberta: hey @christie. what will we be reading at the book club meeting tonight?
+christie: 'Every day, men and women, conversing, beholding and beholden.' /cc @alberta, @bob
+bob: @duncan, @christie so I see it is Emerson tonight
+duncan: We'll also discuss Emerson's friendship with Walt Whitman /cc @bob
+alberta: @duncan, hope you're bringing those peanut butter chocolate cookies again :D
+emily: Unfortunately, I won't be able to make it this time /cc @duncan
+duncan: @emily, oh what a pity. I'll fill you in next week.
+christie: @emily, "Books are the best of things, well used; abused, among the worst." -- Emerson
+emily: Ain't that the truth ... /cc @christie
+duncan: hey @farid, can you pick up some of those cookies on your way home?
+farid: @duncan, might have to work late tonight, but I'll try and get away if I can

14/sample_output.txt

+alberta
+bob, christie
+duncan, emily
+farid
+
+bob
+alberta, christie, duncan
+emily, farid
+
+christie
+alberta, bob, emily
+duncan
+farid
+
+duncan
+bob, emily, farid
+alberta, christie
+
+emily
+christie, duncan
+alberta, bob, farid
+
+farid
+duncan
+bob, emily
+alberta, christie

15/challenge.stack

+PROCEDURE DIVISIBLE
+MOD 
+0
+=
+/PROCEDURE
+
+PROCEDURE FB
+  15
+  DIVISIBLE
+  IF
+    :fizzbuzz
+  ELSE
+    DUP
+    3
+    DIVISIBLE
+    IF
+      :fizz
+    ELSE
+      DUP
+      5
+      DIVISIBLE
+      IF
+        :buzz
+      ELSE
+        DUP
+      THEN
+    THEN
+  THEN
+/PROCEDURE
+
+100
+99
+TIMES
+  DUP
+  FB
+  SWAP
+  1
+  SUBTRACT
+/TIMES
+PROCEDURE UPTO
+  DUP 
+  1
+  SUBTRACT
+  TIMES 
+    DUP
+    1 
+    SUBTRACT 
+  /TIMES
+/PROCEDURE
+
+PROCEDURE DROP_UNTIL
+  DUP
+  ROT
+  =
+  IF
+    :true
+  ELSE
+    DROP_UNTIL
+  THEN
+/PROCEDURE
+
+100
+UPTO
+
+65
+DROP_UNTIL

15/sample_output.txt

+:true
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100

15/stacker_test.rb

+# note, if you are using Ruby 1.9.2 or earlier you may need to install 
+# the minitest gem and then uncomment the following line.
+#
+# gem "minitest"
+
+require "minitest/autorun"
+
+describe "Stacker::Interpreter" do
+
+  let(:interpreter) { Stacker::Interpreter.new }
+
+  it "implements ADD" do
+    execute %w[
+      2
+      3
+      ADD
+    ]
+
+    interpreter.stack.must_equal([5])
+  end
+
+  it "implements SUBTRACT command" do
+    execute %w[
+      1
+      2
+      SUBTRACT
+    ]
+    
+    interpreter.stack.must_equal([-1])
+  end
+  
+  it "implements MULTIPLY" do
+    execute %w[
+      3
+      10
+      MULTIPLY
+    ]
+    
+    interpreter.stack.must_equal([30])
+  end
+
+  it "implements DIVIDE" do
+    execute %w[
+      6
+      2
+      DIVIDE
+      ]
+      
+    interpreter.stack.must_equal([3])
+  end
+  
+  it "implements MOD" do
+    execute %w[
+      4
+      3
+      MOD
+      15
+      3
+      MOD
+    ]
+    
+    interpreter.stack.must_equal([1,0])
+  end
+  
+  it "implements <" do
+    execute %w[
+      3
+      10
+      <
+      5
+      4
+      <
+    ]
+
+    interpreter.stack.must_equal([:true, :false])
+  end
+  
+  it "implements >" do
+    execute %w[
+      3
+      10
+      >
+      5
+      4
+      >
+    ]
+    
+    interpreter.stack.must_equal([:false, :true])
+  end
+
+  it "implements =" do
+    execute %w[
+      1
+      1
+      =
+      1
+      2
+      =
+    ]
+
+    interpreter.stack.must_equal([:true, :false])
+  end
+  
+  it "implements the IF command" do
+    execute %w[
+      :true
+      IF
+      1
+      2
+      ADD
+      ELSE
+      5
+      THEN
+      2
+      5
+      MULTIPLY
+    ]
+    
+    interpreter.stack.must_equal([3, 10])
+  end
+  
+  it "implements the IF command in nesting" do
+    execute %w[ 
+       :true
+       IF
+       :false
+       IF
+       1
+       ELSE
+       2
+       THEN
+       3
+       ELSE
+       :true
+       IF
+       4
+       ELSE
+       5
+       THEN
+       6
+       THEN
+       7
+     ]
+
+    interpreter.stack.must_equal([2,3,7])
+  end
+  
+  it "implements the IF command in another 2-level nesting" do
+    execute %w[
+      :false
+      IF
+      0
+      :false
+      IF
+      1
+      2
+      ELSE
+      3
+      2
+      2
+      ADD
+      THEN
+      5
+      2
+      3
+      MULTIPLY
+      ELSE
+      3
+      4
+      ADD
+      7
+      8
+      <
+      IF
+      2
+      4
+      MULTIPLY
+      3
+      3
+      MULTIPLY
+      ELSE
+      10
+      11
+      THEN
+      12
+      13
+      THEN
+      14
+      15
+    ]
+    
+    interpreter.stack.must_equal([7,8,9,12,13,14,15])
+  end
+
+  it "implements the IF command in 3-level nesting" do
+    execute %w[
+      :true
+      IF
+      :false
+        IF
+        :false
+          IF
+          1
+          ELSE
+          2
+          THEN
+          3
+        ELSE
+        :true
+          IF
+          4
+          ELSE
+          5
+          THEN
+          6
+        THEN
+        7
+      ELSE
+      :false
+        IF
+        :true
+          IF
+          8
+          ELSE
+          9
+          THEN
+          10
+        ELSE
+        :true
+          IF
+          11
+          ELSE
+          12
+          THEN
+          13
+        THEN
+        14
+      THEN
+      15
+      ]
+    interpreter.stack.must_equal([4,6,7,15])
+  end
+
+  it "implements TIMES command" do
+    execute %w[
+      5
+      3
+      TIMES
+      1
+      ADD
+      /TIMES
+    ]
+
+    interpreter.stack.must_equal([8])
+  end
+
+  it "implements TIMES inside of IF command" do
+    execute %w[
+      :true
+      IF
+      5
+      3
+      TIMES
+      2
+      ADD
+      /TIMES
+      ELSE
+      2
+      4
+      TIMES
+      2
+      MULTIPLY
+      /TIMES
+      THEN
+      3
+      5
+      TIMES
+      2
+      ADD
+      /TIMES
+      ADD
+    ]
+
+    interpreter.stack.must_equal([24])
+  end
+  
+  it "implements IF inside of TIMES command" do
+    execute %w[
+      5
+      3
+      TIMES
+      :true
+      IF
+      1
+      ADD
+      ELSE
+      2
+      ADD
+      THEN
+      3
+      ADD
+      /TIMES
+    ]
+
+
+    interpreter.stack.must_equal([17])
+  end
+
+  it "implements PROCEDURE command" do
+    execute %w[
+      PROCEDURE\ DOUBLE
+      2
+      MULTIPLY
+      /PROCEDURE
+      100
+      DOUBLE
+      DOUBLE
+    ]
+
+    interpreter.stack.must_equal([400])
+  end
+  
+  it "implements DUP command" do
+    execute %w[
+      1
+      2
+      DUP
+    ]
+    
+    interpreter.stack.must_equal([1,2,2])
+  end
+
+  it "implements SWAP command" do
+    execute %w[
+      1
+      2
+      SWAP
+    ]
+    
+    interpreter.stack.must_equal([2,1])
+  end
+  
+  it "implements DROP" do
+    execute %w[
+      1
+      2
+      DROP
+    ]
+    
+    interpreter.stack.must_equal([1]) 
+  end
+  
+  it "implements ROT" do
+    execute %w[
+      :foo
+      :bar
+      :baz
+      :foobar
+      :quux
+      ROT
+    ]
+   
+    # ROT takes the third element on the stack and places it on the
+    # top of the stack, pushing the first and second element downwards
+    interpreter.stack.must_equal([:foo,:bar,:foobar, :quux, :baz])
+  end
+
+  it "implements support for adding arbitrary symbols to the stack" do
+    execute %w[
+      :foo
+      :bar
+      :baz
+    ]
+
+    interpreter.stack.must_equal([:foo,:bar,:baz])
+  end
+
+  def execute(commands)
+    commands.each { |c| interpreter.execute(c) }
+  end
+  
+end