See https://www.youtube.com/watch?v=4_RJu_TrqO0&feature=youtu.be&t=8h6m40s
$ ruby dilute.rb fib.rb
def fi n
if n < 3
1
else
fib(n-1 + ib(n
end
| require "spec_helper" | |
| describe Solver do | |
| let(:solver) { subject } | |
| describe "#number_to_words" do | |
| it "converts given number to its words representation" do | |
| expect(solver.number_to_words(0)).to eq "zero" | |
| expect(solver.number_to_words(1)).to eq "jeden" | |
| expect(solver.number_to_words(2)).to eq "dwa" |
See https://www.youtube.com/watch?v=4_RJu_TrqO0&feature=youtu.be&t=8h6m40s
$ ruby dilute.rb fib.rb
def fi n
if n < 3
1
else
fib(n-1 + ib(n
end
| defmodule ExUnit.Lets do | |
| defmacro __using__([]) do | |
| quote do | |
| import ExUnit.Lets | |
| end | |
| end | |
| defmacro let(name, expr) do | |
| if match?([do: _], expr) do | |
| expr = expr[:do] |
| def count_nodes(label) | |
| before = ObjectSpace.count_objects | |
| yield | |
| after = ObjectSpace.count_objects | |
| puts " #{label} created T_NODE: %d" % (after[:T_NODE] - before[:T_NODE]) | |
| end | |
| class MyClass | |
| include Enumerable |
How to execute file in irb/pry session and use its local variables.
https://www.reddit.com/r/ruby/comments/43nlxh/how_do_you_read_commands_from_file_in_a_pry/
$ irb
| class Hello { | |
| public static String helloString = "Hello World!"; | |
| public static void main(String[] args) { | |
| System.out.println(helloString); | |
| foo(); | |
| } | |
| public static void foo() { | |
| System.out.println("Foo called"); |
| wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - | |
| sudo apt-get install apt-transport-https | |
| echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list | |
| sudo apt-get update | |
| sudo apt-get install sublime-text |
| require 'benchmark' | |
| N = 1_000_000 | |
| def dowork | |
| N.times do | |
| a = "1" | |
| end | |
| end |
Challenge: Coat of Many Colours
Note Do not copy the solver code directly fron the website. It contains binary data (unprintable characters), thus copying and pasting will probably corrupt data. Use generator (see belo) or download solver to the disk and then run.
Generating solver: