Skip to content

Commit

Permalink
add sig/fibonacci.rbs
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhull committed Jun 15, 2024
1 parent 3f8d102 commit 5930a8d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ target :lib do
check "lib/compsci/byte_pack.rb"
check "lib/compsci/collatz.rb"
check "lib/compsci/elo.rb"
check "lib/compsci/fibonacci.rb"

# library "pathname" # Standard libraries
# library "strong_json" # Gems

library "zlib"
# library "matrix"

# configure_code_diagnostics(D::Ruby.strict)
end
2 changes: 1 addition & 1 deletion lib/compsci/fibonacci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def self.dynamic(n)

# https://ianthehenry.com/posts/fibonacci/
def self.matrix(n)
(Matrix[[1, 1], [1, 0]] ** n.pred)[0, 0]
(Matrix[[1, 1], [1, 0]] ** n.pred)[0, 0] # steep:ignore
end
end
end
10 changes: 10 additions & 0 deletions sig/fibonacci.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module CompSci
module Fibonacci
def self.classic: (Integer n) -> Integer
def self.cache_recursive: (Integer n, ?Hash[Integer, Integer] cache) ->
Integer
def self.cache_iterative: (Integer n) -> Integer
def self.dynamic: (Integer n) -> Integer
def self.matrix: (Integer n) -> Integer
end
end

0 comments on commit 5930a8d

Please sign in to comment.