This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Header file section | |
| // Do you actually need stdafx or was it auto appended by VS? | |
| //#include "stdafx.h" | |
| #include<iostream> | |
| #include<string> | |
| //using namespace std; | |
| //Funtion declaration | |
| float Average (int *scores,int number) ; | |
| void SortTestScores (int *scores,string *Names,int n) ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Investor | |
| def initialize(*args) | |
| @c, @f, @x = args | |
| @income = 2.0 | |
| @seconds = 0 | |
| end | |
| def solve | |
| return proper_seconds if (@x-@c)/@income < @x/(@income + @f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GuessingGame | |
| attr_reader :total_tricks, :trick_config, :results | |
| def initialize(trick_config) | |
| @total_tricks = trick_config.slice!(0).to_i | |
| @trick_config = trick_config | |
| @results = [] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FizzBuzz | |
| attr_reader :output | |
| def initialize(iterations = 100) | |
| @output = (1..iterations).map { |i| fizz_buzz_test(i) } | |
| end | |
| def fizz_buzz_test(iteration) | |
| case |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_problems(total, max) | |
| 1.upto(total).map { |i| num_swap(rand(1..max), rand(1..max)) } | |
| end | |
| def num_swap(a, b) | |
| return [a, b] if a > b | |
| a = a+b | |
| b = a-b | |
| a = a-b | |
| [a, b] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| aaas | |
| aarh | |
| arhu | |
| rhus | |
| aaro | |
| abab | |
| bacu | |
| balo | |
| bbas | |
| bbey |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =begin | |
| a | |
| / \ | |
| b c | |
| / / \ | |
| d e f | |
| tree = ['a', ['b', 'd' ], ['c', 'e', 'f']] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create_tag(tag, **args) | |
| attributes = args.map { |k,v| " #{k}=\"#{v}\"" }.join | |
| block = yield if block_given? | |
| "<%s%s>%s</%s>" % [tag, attributes, block, tag] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // relation = ['Mother', 'Father', 'Son', 'Daughter', etc] | |
| { | |
| "name": "", | |
| "relation": "", | |
| "branch": [ | |
| "name": "", | |
| "relation": "", | |
| "branch": [ | |
| "name": "", | |
| "relation": "", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tree = [ | |
| // branch eles | |
| [ | |
| // spouse ele | |
| [] | |
| // spouse ele | |
| [], | |
| // spouse ele | |
| [], | |
| // branch eles |