From 73d0deef8bad64e542f73982789bebeb50e347a4 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 23 Jul 2017 19:59:49 +0200 Subject: clear --- ruby/lswf.rb | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 ruby/lswf.rb (limited to 'ruby/lswf.rb') diff --git a/ruby/lswf.rb b/ruby/lswf.rb deleted file mode 100644 index 236847e..0000000 --- a/ruby/lswf.rb +++ /dev/null @@ -1,44 +0,0 @@ -fib = [] -fib.push 1 -fib.push 1 - -def fibonacci(n, fib) - for i in 2...n do - fib.push fib[i-1] + fib[i-2] - - break if fib[i] > n - end - - return i -end - -File.open('input.txt', 'r') do |fin| - N = fin.gets.to_i -end - -fibonacci(N, fib) - -fib = fib.reverse - -somma = 0 -seq = [] - -for i in 0...fib.length-1 do - potSomma = somma + fib[i] - - if potSomma < N - somma = potSomma - seq << 1 - else - seq << 0 - end -end - -seq << 1 -seq = seq.reverse - -seq.pop if N == 1 || N > 4 - -File.open('output.txt', 'w') do |fout| - seq.each {|c| fout.print c} -end -- cgit v1.2.3-18-g5258