kenzo-tanaka / algorithm_sandbox Goto Github PK
View Code? Open in Web Editor NEWアルゴリズムを実際に書いてみるrepo
アルゴリズムを実際に書いてみるrepo
a = gets.to_i
b = gets.to_i
c = gets.to_i
@x = gets.to_i
@payment_pattern = 0
def one_type_coin_payment(coin_type, coin)
# ここで再帰的な処理が必要そう
if @x % coin_type == 0 && (@x/coin_type) <= coin
@payment_pattern += 1
end
end
one_type_coin_payment(500, a)
one_type_coin_payment(100, b)
one_type_coin_payment(50, c)
print @payment_pattern
そのアルゴリズムが処理を終了させるまでにどれくらい時間がかかるかを測定する指標。
例えば単純探索のような、要素を一つずつ調べていくようなアルゴリズムに関してはO(n) と表記。
ビッグオーは最悪の場合の計算時間を意味する。
複数関数の変数を保存するためのスタックをコールスタックという。
ある関数から他の関数を呼び出している時、呼び出し元の関数は部分的に終了している状態である。
なので、他の関数を呼び出す前に代入した変数はスタックに残った状態になっている。
再帰的な計算や処理をするときもコールスタックが使われる。
再帰的な処理のようなスタックを使う場面では、メモリをより多く使用する必要があるので、パフォーマンスが落ちる可能性がある。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.