├── .gitignore
├── python
├── .gitignore
├── funding_raised.pyc
├── README.md
├── test.py
└── funding_raised.py
├── java
├── funding-raised
│ ├── .gitignore
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── checkr
│ │ │ └── interviews
│ │ │ └── FundingRaised.java
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── checkr
│ │ └── interviews
│ │ └── FundingRaisedTest.java
└── Readme.md
├── ruby
├── Gemfile
├── Readme.md
├── Gemfile.lock
├── funding_raised.rb
└── funding_raised_spec.rb
├── .travis.yml
├── go
├── README.md
├── funding_raised.go
└── funding_raised_test.go
├── node
├── package.json
├── README-node.md
├── .gitignore
├── test
│ └── funding_raised.js
├── funding_raised.js
└── yarn.lock
├── Readme.md
└── startup_funding.csv
/.gitignore:
--------------------------------------------------------------------------------
1 | node/node_modules
2 |
--------------------------------------------------------------------------------
/python/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__
2 |
--------------------------------------------------------------------------------
/java/funding-raised/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 |
--------------------------------------------------------------------------------
/ruby/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | gem 'rspec'
4 | gem 'pry'
5 |
--------------------------------------------------------------------------------
/python/funding_raised.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lamchau/refactoring-exercise/HEAD/python/funding_raised.pyc
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - 12
4 | - node
5 |
6 | script:
7 | - cd node
8 | - yarn
9 | - yarn test
10 |
--------------------------------------------------------------------------------
/go/README.md:
--------------------------------------------------------------------------------
1 | ##### GO Instructions
2 | * Run tests with `go test`
3 | * Refactor the fundingraised package in funding_raised.go, making sure to:
4 | * DRY up duplicated
5 | * improve method & variable names
6 | * improve readability and maintainability
7 | * ensure tests continue to pass
8 |
--------------------------------------------------------------------------------
/python/README.md:
--------------------------------------------------------------------------------
1 | ##### Python Instructions
2 | * run tests with `python test.py`
3 | * refactor the `FundingRaised` class in `funding_raised.py`, making sure to:
4 | * DRY up duplicated
5 | * improve method & variable name
6 | * improve readability and maintainability
7 | * ensure tests continue to pass
8 |
--------------------------------------------------------------------------------
/ruby/Readme.md:
--------------------------------------------------------------------------------
1 | ##### Ruby Instructions
2 | * run tests with `rspec funding_raised_spec.rb`
3 | * refactor the `FundingRaised` class in `funding_raised.rb`, making sure to:
4 | * DRY up duplicated
5 | * improve method & variable name
6 | * improve readability and maintainability
7 | * ensure tests continue to pass
8 |
--------------------------------------------------------------------------------
/java/Readme.md:
--------------------------------------------------------------------------------
1 | ##### Java Instructions
2 | * Install maven
3 | * `mvn package` to build
4 | * `mvn test` to run tests
5 | * refactor the `FundingRaised` class in `FundingRaised.java`, making sure to:
6 | * DRY up duplicated
7 | * improve method & variable name
8 | * improve readability and maintainability
9 | * ensure tests continue to pass
10 |
--------------------------------------------------------------------------------
/node/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "refactor",
3 | "version": "0.6.9",
4 | "description": "ACME Node refactor exercise",
5 | "main": "funding_raised.js",
6 | "scripts": {
7 | "test": "mocha"
8 | },
9 | "author": "Eric Psalmond",
10 | "license": "ISC",
11 | "dependencies": {
12 | "chai": "^4.2.0",
13 | "commander": "^6.1.0",
14 | "csv": "^5.3.2",
15 | "mocha": "^8.1.3"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/node/README-node.md:
--------------------------------------------------------------------------------
1 | ### Node notes
2 | Run `mocha` to make sure your test output is correct.
3 |
4 | Style is up to you. Promises, better callbacks, async, etc.
5 | But pick a style with which you're comfortable.
6 |
7 | You're encouraged to use any modules from NPM or any other
8 | resources you'd normally use in your work day. This is
9 | not a memorization test.
10 |
11 | Prioritize what you think will make this code the most readable,
12 | testable, and versitile. Comments are your friend.
13 |
14 |
--------------------------------------------------------------------------------
/ruby/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | coderay (1.1.0)
5 | diff-lcs (1.2.5)
6 | method_source (0.8.2)
7 | pry (0.10.3)
8 | coderay (~> 1.1.0)
9 | method_source (~> 0.8.1)
10 | slop (~> 3.4)
11 | rspec (3.4.0)
12 | rspec-core (~> 3.4.0)
13 | rspec-expectations (~> 3.4.0)
14 | rspec-mocks (~> 3.4.0)
15 | rspec-core (3.4.2)
16 | rspec-support (~> 3.4.0)
17 | rspec-expectations (3.4.0)
18 | diff-lcs (>= 1.2.0, < 2.0)
19 | rspec-support (~> 3.4.0)
20 | rspec-mocks (3.4.1)
21 | diff-lcs (>= 1.2.0, < 2.0)
22 | rspec-support (~> 3.4.0)
23 | rspec-support (3.4.1)
24 | slop (3.6.0)
25 |
26 | PLATFORMS
27 | ruby
28 |
29 | DEPENDENCIES
30 | pry
31 | rspec
32 |
33 | BUNDLED WITH
34 | 1.11.2
35 |
--------------------------------------------------------------------------------
/java/funding-raised/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.acme.interviews
5 | funding-raised
6 | jar
7 | 1.0-SNAPSHOT
8 | funding-raised
9 | http://maven.apache.org
10 |
11 |
12 | junit
13 | junit
14 | 3.8.1
15 | test
16 |
17 |
18 |
19 | com.opencsv
20 | opencsv
21 | 3.3
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | ## Refactoring Exercise
2 |
3 | ### Goal
4 | Here's some really bad code! It is (intentionally) bad, with lots of
5 | duplicated/copied and pasted code, improper use of method/classes, bad naming
6 | of variables and methods, etc. The only good thing about this code is the
7 | tests, which will help guide you through the exercise and ensure that the
8 | interface/functionality of the code remains intact with your refactor.
9 |
10 | Feel free to create new classes, helper methods, etc as you see fit.
11 | Feel free to split things into new files and folders as you like, but
12 | keeping everything in one file is fine too. Don't worry about
13 | editing/refactoring tests, they are just there to guide you and we don't
14 | expect you to spend time working on them.
15 |
16 | You have 45 minutes to complete this exercise. You are not expected to have
17 | enough time to make all of the changes you would like. Part of the exercise
18 | is the time constraint: you have to prioritize what you think will be the most
19 | beneficial refactor, and weigh it with how much time it will take you.
20 |
--------------------------------------------------------------------------------
/node/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | # Logs
4 | logs
5 | *.log
6 | npm-debug.log*
7 | yarn-debug.log*
8 | yarn-error.log*
9 |
10 | # Runtime data
11 | pids
12 | *.pid
13 | *.seed
14 | *.pid.lock
15 |
16 | # Directory for instrumented libs generated by jscoverage/JSCover
17 | lib-cov
18 |
19 | # Coverage directory used by tools like istanbul
20 | coverage
21 |
22 | # nyc test coverage
23 | .nyc_output
24 |
25 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26 | .grunt
27 |
28 | # Bower dependency directory (https://bower.io/)
29 | bower_components
30 |
31 | # node-waf configuration
32 | .lock-wscript
33 |
34 | # Compiled binary addons (https://nodejs.org/api/addons.html)
35 | build/Release
36 |
37 | # Dependency directories
38 | node_modules/
39 | jspm_packages/
40 |
41 | # TypeScript v1 declaration files
42 | typings/
43 |
44 | # Optional npm cache directory
45 | .npm
46 |
47 | # Optional eslint cache
48 | .eslintcache
49 |
50 | # Optional REPL history
51 | .node_repl_history
52 |
53 | # Output of 'npm pack'
54 | *.tgz
55 |
56 | # Yarn Integrity file
57 | .yarn-integrity
58 |
59 | # dotenv environment variables file
60 | .env
61 |
62 | # next.js build output
63 | .next
64 |
65 | # vuepress build output
66 | .vuepress/dist
67 |
68 | # Serverless directories
69 | .serverless
70 |
--------------------------------------------------------------------------------
/python/test.py:
--------------------------------------------------------------------------------
1 | from funding_raised import FundingRaised
2 |
3 | def test_where_returns_events():
4 | assert len(FundingRaised.where({'company_name': 'Facebook'})) == 7
5 |
6 | def test_where_returns_correct_keys():
7 | row = FundingRaised.where({'company_name': 'Facebook'})[0]
8 | keys = ['permalink', 'company_name', 'number_employees', 'category', 'city', 'state', 'funded_date', 'raised_amount', 'raised_currency', 'round']
9 | values = ['facebook', 'Facebook', '450', 'web', 'Palo Alto', 'CA', '1-Sep-04', '500000', 'USD', 'angel']
10 | for i in range(0, len(keys)):
11 | assert row[keys[i]] == values[i]
12 |
13 | def test_where_returns_events_by_city():
14 | assert len(FundingRaised.where({'city': 'Tempe'})) == 3
15 |
16 | def test_where_returns_events_by_state():
17 | assert len(FundingRaised.where({'state': 'CA'})) == 873
18 |
19 | def test_where_returns_events_by_company():
20 | assert len(FundingRaised.where({'company_name': 'Facebook', 'round': 'a'})) == 1
21 |
22 | def test_where_returns_events_by_type():
23 | assert len(FundingRaised.where({'round': 'a'})) == 582
24 |
25 | def test_where_returns_no_events():
26 | assert len(FundingRaised.where({'company_name': 'NotFacebook'})) == 0
27 |
28 | def test_find_by_event_by_company_name():
29 | row = FundingRaised.find_by({'company_name': 'Facebook'})
30 | keys = ['permalink', 'company_name', 'number_employees', 'category', 'city', 'state', 'funded_date', 'raised_amount', 'raised_currency', 'round']
31 | values = ['facebook', 'Facebook', '450', 'web', 'Palo Alto', 'CA', '1-Sep-04', '500000', 'USD', 'angel']
32 | for i in range(0, len(keys)):
33 | assert row[keys[i]] == values[i]
34 |
35 | def test_find_by_event_by_state():
36 | row = FundingRaised.find_by({'state': 'CA'})
37 | keys = ['permalink', 'company_name', 'number_employees', 'category', 'city', 'state', 'funded_date', 'raised_amount', 'raised_currency', 'round']
38 | values = ['digg', 'Digg', '60', 'web', 'San Francisco', 'CA', '1-Dec-06', '8500000', 'USD', 'b']
39 | for i in range(0, len(keys)):
40 | assert row[keys[i]] == values[i]
41 |
42 | test_where_returns_events()
43 | test_where_returns_correct_keys()
44 | test_where_returns_events_by_city()
45 | test_where_returns_events_by_state()
46 | test_where_returns_events_by_company()
47 | test_where_returns_events_by_type()
48 | test_where_returns_no_events()
49 | test_find_by_event_by_company_name()
50 | test_find_by_event_by_state()
51 |
--------------------------------------------------------------------------------
/node/test/funding_raised.js:
--------------------------------------------------------------------------------
1 | const assert = require('chai').assert;
2 |
3 | const FundingRaised = require('../funding_raised');
4 |
5 | describe('FundingRaised', () => {
6 | describe('#where', () => {
7 | describe('company_name is Facebook', () => {
8 | const rows = FundingRaised.where({company_name: 'Facebook'});
9 | const row = rows[0];
10 |
11 | it('returns 7 results', () => {
12 | assert.lengthOf(rows, 7);
13 | });
14 |
15 | it('returns the permalink key', () => {
16 | assert.equal(row.permalink, 'facebook');
17 | });
18 |
19 | it('returns the company_name key', () => {
20 | assert.equal(row.company_name, 'Facebook');
21 | });
22 |
23 | it('returns the number_employees key', () => {
24 | assert.equal(row.number_employees, '450');
25 | });
26 |
27 | it('returns the category key', () => {
28 | assert.equal(row.category, 'web');
29 | });
30 |
31 | it('returns the city key', () => {
32 | assert.equal(row.city, 'Palo Alto');
33 | });
34 |
35 | it('returns the state key', () => {
36 | assert.equal(row.state, 'CA');
37 | });
38 |
39 | it('returns the funded_date key', () => {
40 | assert.equal(row.funded_date, '1-Sep-04');
41 | });
42 | });
43 |
44 | describe('city is Tempe', () => {
45 | const rows = FundingRaised.where({city: 'Tempe'});
46 |
47 | it('returns 3 results', () => {
48 | assert.lengthOf(rows, 3);
49 | });
50 | });
51 |
52 | describe('state is CA', () => {
53 | const rows = FundingRaised.where({state: 'CA'});
54 |
55 | it('returns 873 results', () => {
56 | assert.lengthOf(rows, 873);
57 | });
58 | });
59 |
60 | describe('company_name is Facebook and round is a', () => {
61 | const rows = FundingRaised.where({company_name: 'Facebook', round: 'a'});
62 |
63 | it('returns 1 result', () => {
64 | assert.lengthOf(rows, 1);
65 | });
66 | });
67 | });
68 |
69 | describe('#findBy', () => {
70 | describe('company_name is Facebook', () => {
71 | const row = FundingRaised.findBy({company_name: 'Facebook'});
72 |
73 | it('returns the permalink key', () => {
74 | assert.equal(row.permalink, 'facebook');
75 | });
76 | });
77 |
78 | describe('state is CA', () => {
79 | const row = FundingRaised.findBy({state: 'CA'});
80 |
81 | it('returns the permalink key', () => {
82 | assert.equal(row.permalink, 'digg');
83 | });
84 |
85 | it('returns the number_employees key', () => {
86 | assert.equal(row.number_employees, 60);
87 | });
88 |
89 | it('returns the round key', () => {
90 | assert.equal(row.round, 'b');
91 | });
92 | });
93 |
94 | //
95 | // Pending tests that currently fail (change xit => it)
96 | //
97 | describe('company_name is YouTube and round is b', () => {
98 | const row = FundingRaised.findBy({company_name: 'YouTube', round: 'b'});
99 |
100 | xit('returns correct result', () => {
101 | assert.equal(row.round, 'b');
102 | });
103 | });
104 |
105 | describe('async', () => {
106 | xit('returns a promise instead of results', () => {
107 | return FundingRaised.asyncWhere({company_name: 'Facebook', round: 'a'})
108 | .then((rows) => {
109 | assert.lengthOf(rows, 1);
110 | })
111 | });
112 | });
113 | });
114 | });
115 |
--------------------------------------------------------------------------------
/node/funding_raised.js:
--------------------------------------------------------------------------------
1 | const parseCsvSync = require('csv-parse/lib/sync');
2 | const fs = require('fs');
3 | const path = require('path');
4 |
5 | class FundingRaised {
6 | static where(options = {}) {
7 | const funding_file = 'startup_funding.csv';
8 | const file_data = fs.readFileSync(path.join(__dirname, '..', funding_file)).toString();
9 | let csv_data = parseCsvSync(file_data);
10 |
11 | const funding_data = [];
12 |
13 | if (options.company_name) {
14 | csv_data = csv_data.filter(row => options.company_name == row[1]);
15 | }
16 |
17 | if (options.city) {
18 | csv_data = csv_data.filter(row => options.city == row[4]);
19 | }
20 |
21 | if (options.state) {
22 | csv_data = csv_data.filter(row => options.state == row[5]);
23 | }
24 |
25 | if (options.round) {
26 | csv_data = csv_data.filter(row => options.round == row[9]);
27 | }
28 |
29 | csv_data.forEach((row) => {
30 | const mapped = {};
31 | mapped.permalink = row[0];
32 | mapped.company_name = row[1];
33 | mapped.number_employees = row[2];
34 | mapped.category = row[3];
35 | mapped.city = row[4];
36 | mapped.state = row[5];
37 | mapped.funded_date = row[6];
38 | mapped.raised_amount = row[7];
39 | mapped.raised_currency = row[8];
40 | mapped.round = row[9];
41 | funding_data.push(mapped);
42 | });
43 |
44 | return funding_data;
45 | }
46 |
47 | static findBy(options = {}) {
48 | const funding_file = 'startup_funding.csv';
49 | const file_data = fs.readFileSync(path.join(__dirname, '..', funding_file)).toString();
50 | let csv_data = parseCsvSync(file_data);
51 |
52 | if (options.company_name) {
53 | csv_data = csv_data.filter(row => options.company_name == row[1]);
54 | const row = csv_data[0];
55 | const mapped = {};
56 | mapped.permalink = row[0];
57 | mapped.company_name = row[1];
58 | mapped.number_employees = row[2];
59 | mapped.category = row[3];
60 | mapped.city = row[4];
61 | mapped.state = row[5];
62 | mapped.funded_date = row[6];
63 | mapped.raised_amount = row[7];
64 | mapped.raised_currency = row[8];
65 | mapped.round = row[9];
66 | return mapped;
67 | }
68 |
69 | if (options.city) {
70 | csv_data = csv_data.filter(row => options.city == row[4]);
71 | const row = csv_data[0];
72 | const mapped = {};
73 | mapped.permalink = row[0];
74 | mapped.company_name = row[1];
75 | mapped.number_employees = row[2];
76 | mapped.category = row[3];
77 | mapped.city = row[4];
78 | mapped.state = row[5];
79 | mapped.funded_date = row[6];
80 | mapped.raised_amount = row[7];
81 | mapped.raised_currency = row[8];
82 | mapped.round = row[9];
83 | return mapped;
84 | }
85 |
86 | if (options.state) {
87 | csv_data = csv_data.filter(row => options.state == row[5]);
88 | const row = csv_data[0];
89 | const mapped = {};
90 | mapped.permalink = row[0];
91 | mapped.company_name = row[1];
92 | mapped.number_employees = row[2];
93 | mapped.category = row[3];
94 | mapped.city = row[4];
95 | mapped.state = row[5];
96 | mapped.funded_date = row[6];
97 | mapped.raised_amount = row[7];
98 | mapped.raised_currency = row[8];
99 | mapped.round = row[9];
100 | return mapped;
101 | }
102 |
103 | if (options.round) {
104 | csv_data = csv_data.filter(row => options.round == row[9]);
105 | const row = csv_data[0];
106 | const mapped = {};
107 | mapped.permalink = row[0];
108 | mapped.company_name = row[1];
109 | mapped.number_employees = row[2];
110 | mapped.category = row[3];
111 | mapped.city = row[4];
112 | mapped.state = row[5];
113 | mapped.funded_date = row[6];
114 | mapped.raised_amount = row[7];
115 | mapped.raised_currency = row[8];
116 | mapped.round = row[9];
117 | return mapped;
118 | }
119 | }
120 | }
121 |
122 | module.exports = FundingRaised;
123 |
--------------------------------------------------------------------------------
/ruby/funding_raised.rb:
--------------------------------------------------------------------------------
1 | require 'csv'
2 | require 'rspec'
3 | require 'rspec/expectations'
4 | require 'pry'
5 |
6 | class FundingRaised
7 | def self.where(options = {})
8 | csv_data = CSV.read("../startup_funding.csv")
9 |
10 | @funding = []
11 | if options[:company_name]
12 | csv_data.select! do |row|
13 | row[1] == options.fetch(:company_name)
14 | end
15 | end
16 |
17 | if options[:city]
18 | csv_data.select! do |row|
19 | row[4] == options.fetch(:city)
20 | end
21 | end
22 |
23 | if options[:state]
24 | csv_data.select! do |row|
25 | row[5] == options.fetch(:state)
26 | end
27 | end
28 |
29 | if options[:round]
30 | csv_data.select! do |row|
31 | row[9] == options.fetch(:round)
32 | end
33 | end
34 |
35 | @output = []
36 | csv_data.each do |row|
37 | mapped = {}
38 | mapped['permalink'] = row[0]
39 | mapped['company_name'] = row[1]
40 | mapped['number_employees'] = row[2]
41 | mapped['category'] = row[3]
42 | mapped['city'] = row[4]
43 | mapped['state'] = row[5]
44 | mapped['funded_date'] = row[6]
45 | mapped['raised_amount'] = row[7]
46 | mapped['raised_currency'] = row[8]
47 | mapped['round'] = row[9]
48 | @output << mapped
49 | end
50 |
51 | @output
52 | end
53 |
54 | def self.find_by(options)
55 | csv_data = CSV.read("../startup_funding.csv")
56 |
57 | if options[:company_name]
58 | csv_data.each do |row|
59 | if row[1] == options.fetch(:company_name)
60 | mapped = {}
61 | mapped['permalink'] = row[0]
62 | mapped['company_name'] = row[1]
63 | mapped['number_employees'] = row[2]
64 | mapped['category'] = row[3]
65 | mapped['city'] = row[4]
66 | mapped['state'] = row[5]
67 | mapped['funded_date'] = row[6]
68 | mapped['raised_amount'] = row[7]
69 | mapped['raised_currency'] = row[8]
70 | mapped['round'] = row[9]
71 | return mapped
72 | end
73 | end
74 | end
75 |
76 | if options[:city]
77 | csv_data.each do |row|
78 | if row[4] == options.fetch(:city)
79 | mapped = {}
80 | mapped['permalink'] = row[0]
81 | mapped['company_name'] = row[1]
82 | mapped['number_employees'] = row[2]
83 | mapped['category'] = row[3]
84 | mapped['city'] = row[4]
85 | mapped['state'] = row[5]
86 | mapped['funded_date'] = row[6]
87 | mapped['raised_amount'] = row[7]
88 | mapped['raised_currency'] = row[8]
89 | mapped['round'] = row[9]
90 | return mapped
91 | end
92 | end
93 | end
94 |
95 | if options[:state]
96 | csv_data.each do |row|
97 | if row[5] == options.fetch(:state)
98 | mapped = {}
99 | mapped['permalink'] = row[0]
100 | mapped['company_name'] = row[1]
101 | mapped['number_employees'] = row[2]
102 | mapped['category'] = row[3]
103 | mapped['city'] = row[4]
104 | mapped['state'] = row[5]
105 | mapped['funded_date'] = row[6]
106 | mapped['raised_amount'] = row[7]
107 | mapped['raised_currency'] = row[8]
108 | mapped['round'] = row[9]
109 | return mapped
110 | end
111 | end
112 | end
113 |
114 | if options[:round]
115 | csv_data.each do |row|
116 | if row[9] == options.fetch(:round)
117 | mapped = {}
118 | mapped['permalink'] = row[0]
119 | mapped['company_name'] = row[1]
120 | mapped['number_employees'] = row[2]
121 | mapped['category'] = row[3]
122 | mapped['city'] = row[4]
123 | mapped['state'] = row[5]
124 | mapped['funded_date'] = row[6]
125 | mapped['raised_amount'] = row[7]
126 | mapped['raised_currency'] = row[8]
127 | mapped['round'] = row[9]
128 | return mapped
129 | end
130 | end
131 | end
132 |
133 | raise RecordNotFound
134 | end
135 | end
136 |
137 | class RecordNotFound < StandardError
138 | end
139 |
--------------------------------------------------------------------------------
/python/funding_raised.py:
--------------------------------------------------------------------------------
1 | import csv
2 |
3 | class FundingRaised:
4 | @staticmethod
5 | def where(options = {}):
6 | with open("../startup_funding.csv", "rt") as csvfile:
7 | data = csv.reader(csvfile, delimiter=',', quotechar='"')
8 | # skip header
9 | next(data)
10 | csv_data = []
11 | for row in data:
12 | csv_data.append(row)
13 |
14 | funding = []
15 | if 'company_name' in options:
16 | result = []
17 | for row in csv_data:
18 | if row[1] == options['company_name']:
19 | result.append(row)
20 | csv_data = result
21 |
22 | if 'city' in options:
23 | result = []
24 | for row in csv_data:
25 | if row[4] == options['city']:
26 | result.append(row)
27 | csv_data = result
28 |
29 | if 'state' in options:
30 | result = []
31 | for row in csv_data:
32 | if row[5] == options['state']:
33 | result.append(row)
34 | csv_data = result
35 |
36 | if 'round' in options:
37 | result = []
38 | for row in csv_data:
39 | if row[9] == options['round']:
40 | result.append(row)
41 | csv_data = result
42 |
43 | output = []
44 | for row in csv_data:
45 | mapped = {}
46 | mapped['permalink'] = row[0]
47 | mapped['company_name'] = row[1]
48 | mapped['number_employees'] = row[2]
49 | mapped['category'] = row[3]
50 | mapped['city'] = row[4]
51 | mapped['state'] = row[5]
52 | mapped['funded_date'] = row[6]
53 | mapped['raised_amount'] = row[7]
54 | mapped['raised_currency'] = row[8]
55 | mapped['round'] = row[9]
56 | output.append(mapped)
57 |
58 | return output
59 |
60 | @staticmethod
61 | def find_by(options):
62 | with open("../startup_funding.csv", "rt") as csvfile:
63 | data = csv.reader(csvfile, delimiter=',', quotechar='"')
64 | # skip header
65 | next(data)
66 | csv_data = []
67 | for row in data:
68 | csv_data.append(row)
69 |
70 | if 'company_name' in options:
71 | for row in csv_data:
72 | if row[1] == options['company_name']:
73 | mapped = {}
74 | mapped['permalink'] = row[0]
75 | mapped['company_name'] = row[1]
76 | mapped['number_employees'] = row[2]
77 | mapped['category'] = row[3]
78 | mapped['city'] = row[4]
79 | mapped['state'] = row[5]
80 | mapped['funded_date'] = row[6]
81 | mapped['raised_amount'] = row[7]
82 | mapped['raised_currency'] = row[8]
83 | mapped['round'] = row[9]
84 | return mapped
85 |
86 | if 'city' in options:
87 | for row in csv_data:
88 | if row[4] == options['city']:
89 | mapped = {}
90 | mapped['permalink'] = row[0]
91 | mapped['company_name'] = row[1]
92 | mapped['number_employees'] = row[2]
93 | mapped['category'] = row[3]
94 | mapped['city'] = row[4]
95 | mapped['state'] = row[5]
96 | mapped['funded_date'] = row[6]
97 | mapped['raised_amount'] = row[7]
98 | mapped['raised_currency'] = row[8]
99 | mapped['round'] = row[9]
100 | return mapped
101 |
102 | if 'state' in options:
103 | for row in csv_data:
104 | if row[5] == options['state']:
105 | mapped = {}
106 | mapped['permalink'] = row[0]
107 | mapped['company_name'] = row[1]
108 | mapped['number_employees'] = row[2]
109 | mapped['category'] = row[3]
110 | mapped['city'] = row[4]
111 | mapped['state'] = row[5]
112 | mapped['funded_date'] = row[6]
113 | mapped['raised_amount'] = row[7]
114 | mapped['raised_currency'] = row[8]
115 | mapped['round'] = row[9]
116 | return mapped
117 |
118 | if 'round' in options:
119 | for row in csv_data:
120 | if row[9] == options['round']:
121 | mapped = {}
122 | mapped['permalink'] = row[0]
123 | mapped['company_name'] = row[1]
124 | mapped['number_employees'] = row[2]
125 | mapped['category'] = row[3]
126 | mapped['city'] = row[4]
127 | mapped['state'] = row[5]
128 | mapped['funded_date'] = row[6]
129 | mapped['raised_amount'] = row[7]
130 | mapped['raised_currency'] = row[8]
131 | mapped['round'] = row[9]
132 | return mapped
133 |
134 | raise RecordNotFound
135 |
136 | class RecordNotFound(Exception):
137 | pass
138 |
--------------------------------------------------------------------------------
/go/funding_raised.go:
--------------------------------------------------------------------------------
1 | package fundingraised
2 |
3 | import (
4 | "bufio"
5 | "encoding/csv"
6 | "errors"
7 | "io"
8 | "os"
9 | )
10 |
11 | func Where(options map[string]string) []map[string]string {
12 | f, _ := os.Open("../startup_funding.csv")
13 | reader := csv.NewReader(bufio.NewReader(f))
14 | csv_data := [][]string{}
15 |
16 | for {
17 | row, err := reader.Read()
18 |
19 | if err == io.EOF {
20 | break
21 | }
22 |
23 | csv_data = append(csv_data, row)
24 | }
25 |
26 | _, ok := options["company_name"]
27 | if ok == true {
28 | results := [][]string{}
29 | for i := 0; i < len(csv_data); i++ {
30 | if csv_data[i][1] == options["company_name"] {
31 | results = append(results, csv_data[i])
32 | }
33 | }
34 | csv_data = results
35 | }
36 |
37 | _, ok = options["city"]
38 | if ok == true {
39 | results := [][]string{}
40 | for i := 0; i < len(csv_data); i++ {
41 | if csv_data[i][4] == options["city"] {
42 | results = append(results, csv_data[i])
43 | }
44 | }
45 | csv_data = results
46 | }
47 |
48 | _, ok = options["state"]
49 | if ok == true {
50 | results := [][]string{}
51 | for i := 0; i < len(csv_data); i++ {
52 | if csv_data[i][5] == options["state"] {
53 | results = append(results, csv_data[i])
54 | }
55 | }
56 | csv_data = results
57 | }
58 |
59 | _, ok = options["round"]
60 | if ok == true {
61 | results := [][]string{}
62 | for i := 0; i < len(csv_data); i++ {
63 | if csv_data[i][9] == options["round"] {
64 | results = append(results, csv_data[i])
65 | }
66 | }
67 | csv_data = results
68 | }
69 |
70 | output := []map[string]string{}
71 | for i := 0; i < len(csv_data); i++ {
72 | mapped := make(map[string]string)
73 | mapped["permalink"] = csv_data[i][0]
74 | mapped["company_name"] = csv_data[i][1]
75 | mapped["number_employees"] = csv_data[i][2]
76 | mapped["category"] = csv_data[i][3]
77 | mapped["city"] = csv_data[i][4]
78 | mapped["state"] = csv_data[i][5]
79 | mapped["funded_date"] = csv_data[i][6]
80 | mapped["raised_amount"] = csv_data[i][7]
81 | mapped["raised_currency"] = csv_data[i][8]
82 | mapped["round"] = csv_data[i][9]
83 | output = append(output, mapped)
84 | }
85 |
86 | return output
87 | }
88 |
89 | func FindBy(options map[string]string) (map[string]string, error) {
90 | f, _ := os.Open("../startup_funding.csv")
91 | reader := csv.NewReader(bufio.NewReader(f))
92 | csv_data := [][]string{}
93 |
94 | for {
95 | row, err := reader.Read()
96 |
97 | if err == io.EOF {
98 | break
99 | }
100 |
101 | csv_data = append(csv_data, row)
102 | }
103 |
104 | for i := 0; i < len(csv_data); i++ {
105 | var ok bool
106 | mapped := make(map[string]string)
107 |
108 | _, ok = options["company_name"]
109 | if ok == true {
110 | if csv_data[i][1] == options["company_name"] {
111 | mapped["permalink"] = csv_data[i][0]
112 | mapped["company_name"] = csv_data[i][1]
113 | mapped["number_employees"] = csv_data[i][2]
114 | mapped["category"] = csv_data[i][3]
115 | mapped["city"] = csv_data[i][4]
116 | mapped["state"] = csv_data[i][5]
117 | mapped["funded_date"] = csv_data[i][6]
118 | mapped["raised_amount"] = csv_data[i][7]
119 | mapped["raised_currency"] = csv_data[i][8]
120 | mapped["round"] = csv_data[i][9]
121 | } else {
122 | continue
123 | }
124 | }
125 |
126 | _, ok = options["city"]
127 | if ok == true {
128 | if csv_data[i][4] == options["city"] {
129 | mapped["permalink"] = csv_data[i][0]
130 | mapped["company_name"] = csv_data[i][1]
131 | mapped["number_employees"] = csv_data[i][2]
132 | mapped["category"] = csv_data[i][3]
133 | mapped["city"] = csv_data[i][4]
134 | mapped["state"] = csv_data[i][5]
135 | mapped["funded_date"] = csv_data[i][6]
136 | mapped["raised_amount"] = csv_data[i][7]
137 | mapped["raised_currency"] = csv_data[i][8]
138 | mapped["round"] = csv_data[i][9]
139 | } else {
140 | continue
141 | }
142 | }
143 |
144 | _, ok = options["state"]
145 | if ok == true {
146 | if csv_data[i][5] == options["state"] {
147 | mapped["permalink"] = csv_data[i][0]
148 | mapped["company_name"] = csv_data[i][1]
149 | mapped["number_employees"] = csv_data[i][2]
150 | mapped["category"] = csv_data[i][3]
151 | mapped["city"] = csv_data[i][4]
152 | mapped["state"] = csv_data[i][5]
153 | mapped["funded_date"] = csv_data[i][6]
154 | mapped["raised_amount"] = csv_data[i][7]
155 | mapped["raised_currency"] = csv_data[i][8]
156 | mapped["round"] = csv_data[i][9]
157 | } else {
158 | continue
159 | }
160 | }
161 |
162 | _, ok = options["round"]
163 | if ok == true {
164 | if csv_data[i][9] == options["round"] {
165 | mapped["permalink"] = csv_data[i][0]
166 | mapped["company_name"] = csv_data[i][1]
167 | mapped["number_employees"] = csv_data[i][2]
168 | mapped["category"] = csv_data[i][3]
169 | mapped["city"] = csv_data[i][4]
170 | mapped["state"] = csv_data[i][5]
171 | mapped["funded_date"] = csv_data[i][6]
172 | mapped["raised_amount"] = csv_data[i][7]
173 | mapped["raised_currency"] = csv_data[i][8]
174 | mapped["round"] = csv_data[i][9]
175 | } else {
176 | continue
177 | }
178 | }
179 |
180 | return mapped, nil
181 | }
182 |
183 | return make(map[string]string), errors.New("Record Not Found")
184 | }
185 |
--------------------------------------------------------------------------------
/ruby/funding_raised_spec.rb:
--------------------------------------------------------------------------------
1 | require_relative 'funding_raised'
2 |
3 | RSpec.configure do |config|
4 | config.color = true
5 | end
6 |
7 | RSpec.describe FundingRaised do
8 | describe '.where' do
9 | describe 'company_name is Facebook' do
10 | let(:rows) { FundingRaised.where(company_name: 'Facebook') }
11 | let(:row) { rows[0] }
12 |
13 | it 'returns the fund raising events for a given company' do
14 | expect(rows.size).to eq(7)
15 | end
16 |
17 | it 'returns the correct key' do
18 | expect(row['permalink']).to eq('facebook')
19 | end
20 |
21 | it 'returns the correct key' do
22 | expect(row['company_name']).to eq('Facebook')
23 | end
24 |
25 | it 'returns the correct key' do
26 | expect(row['number_employees']).to eq('450')
27 | end
28 |
29 | it 'returns the correct key' do
30 | expect(row['category']).to eq('web')
31 | end
32 |
33 | it 'returns the correct key' do
34 | expect(row['city']).to eq('Palo Alto')
35 | end
36 |
37 | it 'returns the correct key' do
38 | expect(row['state']).to eq('CA')
39 | end
40 |
41 | it 'returns the correct key' do
42 | expect(row['funded_date']).to eq('1-Sep-04')
43 | end
44 |
45 | it 'returns the correct key' do
46 | expect(row['raised_amount']).to eq('500000')
47 | end
48 |
49 | it 'returns the correct key' do
50 | expect(row['raised_currency']).to eq('USD')
51 | end
52 |
53 | it 'returns the correct key' do
54 | expect(row['round']).to eq('angel')
55 | end
56 | end
57 |
58 | describe 'city is Tempe' do
59 | it 'returns the fund raising events for Tempe' do
60 | expect(FundingRaised.where(city: 'Tempe').size).to eq(3)
61 | end
62 | end
63 |
64 | describe 'state is CA' do
65 | it 'returns the fund raising events for CA' do
66 | expect(FundingRaised.where(state: 'CA').size).to eq(873)
67 | end
68 | end
69 |
70 | describe 'company_name is Facebook and Round is A' do
71 | it 'returns the fund raising events for a given company' do
72 | expect(FundingRaised.where(company_name: 'Facebook', round: 'a').size).to eq(1)
73 | end
74 | end
75 |
76 | describe 'Round is A' do
77 | it 'returns the fund raising events for a given type' do
78 | expect(FundingRaised.where(round: 'a').size).to eq(582)
79 | end
80 | end
81 |
82 | describe 'company_name does not exist' do
83 | it 'returns an empty array' do
84 | expect(FundingRaised.where(company_name: 'NotFacebook').size).to eq(0)
85 | end
86 | end
87 |
88 | describe 'extra credit' do
89 | pending 'allows chaining of where methods' do
90 | expect(FundingRaised.where(company_name: 'Facebook').where(round: 'a').size).to eq(1)
91 | end
92 | end
93 | end
94 |
95 | describe '.find_by' do
96 | describe 'company_name is Facebook' do
97 | let(:row) { FundingRaised.find_by(company_name: 'Facebook') }
98 |
99 | it 'returns the first fund raising event for a given company name' do
100 | expect(row['permalink']).to eq('facebook')
101 | end
102 |
103 | it 'returns the first fund raising event for a given company name' do
104 | expect(row['company_name']).to eq('Facebook')
105 | end
106 |
107 | it 'returns the first fund raising event for a given company name' do
108 | expect(row['number_employees']).to eq('450')
109 | end
110 |
111 | it 'returns the first fund raising event for a given company name' do
112 | expect(row['category']).to eq('web')
113 | end
114 |
115 | it 'returns the first fund raising event for a given company name' do
116 | expect(row['city']).to eq('Palo Alto')
117 | end
118 |
119 | it 'returns the first fund raising event for a given company name' do
120 | expect(row['state']).to eq('CA')
121 | end
122 |
123 | it 'returns the first fund raising event for a given company name' do
124 | expect(row['funded_date']).to eq('1-Sep-04')
125 | end
126 |
127 | it 'returns the first fund raising event for a given company name' do
128 | expect(row['raised_amount']).to eq('500000')
129 | end
130 |
131 | it 'returns the first fund raising event for a given company name' do
132 | expect(row['raised_currency']).to eq('USD')
133 | end
134 |
135 | it 'returns the first fund raising event for a given company name' do
136 | expect(row['round']).to eq('angel')
137 | end
138 | end
139 |
140 | describe 'state passed in is CA' do
141 | let(:row) { FundingRaised.find_by(state: 'CA') }
142 |
143 | it 'returns the first fund raising event' do
144 | expect(row['permalink']).to eq('digg')
145 | end
146 |
147 | it 'returns the first fund raising event' do
148 | expect(row['company_name']).to eq('Digg')
149 | end
150 |
151 | it 'returns the first fund raising event' do
152 | expect(row['number_employees']).to eq('60')
153 | end
154 |
155 | it 'returns the first fund raising event' do
156 | expect(row['category']).to eq('web')
157 | end
158 |
159 | it 'returns the first fund raising event' do
160 | expect(row['city']).to eq('San Francisco')
161 | end
162 |
163 | it 'returns the first fund raising event' do
164 | expect(row['state']).to eq('CA')
165 | end
166 |
167 | it 'returns the first fund raising event' do
168 | expect(row['funded_date']).to eq('1-Dec-06')
169 | end
170 |
171 | it 'returns the first fund raising event' do
172 | expect(row['raised_amount']).to eq('8500000')
173 | end
174 |
175 | it 'returns the first fund raising event' do
176 | expect(row['raised_currency']).to eq('USD')
177 | end
178 |
179 | it 'returns the first fund raising event' do
180 | expect(row['round']).to eq('b')
181 | end
182 | end
183 | end
184 | end
185 |
--------------------------------------------------------------------------------
/go/funding_raised_test.go:
--------------------------------------------------------------------------------
1 | package fundingraised
2 |
3 | import "testing"
4 |
5 | func TestWhereGivenCompany(t *testing.T) {
6 | options := map[string]string{
7 | "company_name": "Facebook",
8 | }
9 |
10 | rows := len(Where(options))
11 | if rows != 7 {
12 | t.Error("Expected 7 rows. Got ", rows)
13 | }
14 | }
15 |
16 | func TestWhereCorrectKeys(t *testing.T) {
17 | options := map[string]string{
18 | "company_name": "Facebook",
19 | }
20 |
21 | rows := Where(options)
22 | row := rows[0]
23 |
24 | if row["permalink"] != "facebook" {
25 | t.Error("Expected permalink to be facebook. Got", row["permalink"])
26 | }
27 |
28 | if row["company_name"] != "Facebook" {
29 | t.Error("Expected company name to be Facebook. Got", row["company_name"])
30 | }
31 |
32 | if row["number_employees"] != "450" {
33 | t.Error("Expected number of employees to be 450. Got", row["number_employees"])
34 | }
35 |
36 | if row["category"] != "web" {
37 | t.Error("Expected category to be web. Got", row["category"])
38 | }
39 |
40 | if row["city"] != "Palo Alto" {
41 | t.Error("Expected city to be Palo Alto. Got", row["city"])
42 | }
43 |
44 | if row["state"] != "CA" {
45 | t.Error("Expected state to be CA. Got", row["state"])
46 | }
47 |
48 | if row["funded_date"] != "1-Sep-04" {
49 | t.Error("Expected funded date to be 1-Sep-04. Got", row["funded_date"])
50 | }
51 |
52 | if row["raised_amount"] != "500000" {
53 | t.Error("Expected raised amount to be 500000. Got", row["raised_amount"])
54 | }
55 |
56 | if row["round"] != "angel" {
57 | t.Error("Expected round to be angel. Got", row["round"])
58 | }
59 | }
60 |
61 | func TestWhereGivenCity(t *testing.T) {
62 | options := map[string]string{
63 | "city": "Tempe",
64 | }
65 |
66 | rows := len(Where(options))
67 | if rows != 3 {
68 | t.Error("Expected 3 rows having city == Tempe. Got", rows)
69 | }
70 | }
71 |
72 | func TestWhereGivenState(t *testing.T) {
73 | options := map[string]string{
74 | "state": "CA",
75 | }
76 |
77 | rows := len(Where(options))
78 | if rows != 873 {
79 | t.Error("Expected 873 rows having state == CA. Got", rows)
80 | }
81 | }
82 |
83 | func TestWhereGivenRound(t *testing.T) {
84 | options := map[string]string{
85 | "round": "a",
86 | }
87 |
88 | rows := len(Where(options))
89 | if rows != 582 {
90 | t.Error("Expected 582 rows having round == a. Got", rows)
91 | }
92 | }
93 |
94 | func TestWhereMultipleOptions(t *testing.T) {
95 | options := map[string]string{
96 | "company_name": "Facebook",
97 | "round": "a",
98 | }
99 |
100 | rows := len(Where(options))
101 | if rows != 1 {
102 | t.Error("Expected 1 row having company name == Facebook and round == a. Got", rows)
103 | }
104 | }
105 |
106 | func TestWhereNonExistence(t *testing.T) {
107 | options := map[string]string{
108 | "company_name": "NotFacebook",
109 | }
110 |
111 | rows := len(Where(options))
112 | if rows != 0 {
113 | t.Error("Expected an empty list. Got", rows)
114 | }
115 | }
116 |
117 | func TestFindByGivenCompanyName(t *testing.T) {
118 | options := map[string]string{
119 | "company_name": "Facebook",
120 | }
121 |
122 | row, err := FindBy(options)
123 |
124 | if err != nil {
125 | t.Error("Expected FindBy to return no errors")
126 | }
127 |
128 | if row["permalink"] != "facebook" {
129 | t.Error("Expected permalink to be facebook. Got", row["permalink"])
130 | }
131 |
132 | if row["company_name"] != "Facebook" {
133 | t.Error("Expected company name to be Facebook. Got", row["company_name"])
134 | }
135 |
136 | if row["number_employees"] != "450" {
137 | t.Error("Expected number of employees to be 450. Got", row["number_employees"])
138 | }
139 |
140 | if row["category"] != "web" {
141 | t.Error("Expected category to be web. Got", row["category"])
142 | }
143 |
144 | if row["city"] != "Palo Alto" {
145 | t.Error("Expected city to be Palo Alto. Got", row["city"])
146 | }
147 |
148 | if row["state"] != "CA" {
149 | t.Error("Expected state to be CA. Got", row["state"])
150 | }
151 |
152 | if row["funded_date"] != "1-Sep-04" {
153 | t.Error("Expected funded date to be 1-Sep-04. Got", row["funded_date"])
154 | }
155 |
156 | if row["raised_amount"] != "500000" {
157 | t.Error("Expected raised amount to be 500000. Got", row["raised_amount"])
158 | }
159 |
160 | if row["raised_currency"] != "USD" {
161 | t.Error("Expected raised currency to be USD. Got", row["raised_currency"])
162 | }
163 |
164 | if row["round"] != "angel" {
165 | t.Error("Expected round to be angel. Got", row["round"])
166 | }
167 | }
168 |
169 | func TestFindByGivenState(t *testing.T) {
170 | options := map[string]string{
171 | "state": "CA",
172 | }
173 |
174 | row, err := FindBy(options)
175 |
176 | if err != nil {
177 | t.Error("Expected FindBy to return no errors")
178 | }
179 |
180 | if row["permalink"] != "digg" {
181 | t.Error("Expected permalink to be digg. Got", row["permalink"])
182 | }
183 |
184 | if row["company_name"] != "Digg" {
185 | t.Error("Expected company name to be Digg. Got", row["company_name"])
186 | }
187 |
188 | if row["number_employees"] != "60" {
189 | t.Error("Expected number of employees to be 60. Got", row["number_employees"])
190 | }
191 |
192 | if row["category"] != "web" {
193 | t.Error("Expected category to be web. Got", row["category"])
194 | }
195 |
196 | if row["city"] != "San Francisco" {
197 | t.Error("Expected city to be San Francisco. Got", row["city"])
198 | }
199 |
200 | if row["state"] != "CA" {
201 | t.Error("Expected state to be CA. Got", row["state"])
202 | }
203 |
204 | if row["funded_date"] != "1-Dec-06" {
205 | t.Error("Expected funded date to be 1-Dec-06. Got", row["funded_date"])
206 | }
207 |
208 | if row["raised_amount"] != "8500000" {
209 | t.Error("Expected raised amount to be 8500000. Got", row["raised_amount"])
210 | }
211 |
212 | if row["raised_currency"] != "USD" {
213 | t.Error("Expected raised currency to be USD. Got", row["raised_currency"])
214 | }
215 |
216 | if row["round"] != "b" {
217 | t.Error("Expected round to be b. Got", row["round"])
218 | }
219 | }
220 |
221 | func TestFindByMultipleOptions(t *testing.T) {
222 | options := map[string]string{
223 | "company_name": "Facebook",
224 | "round": "c",
225 | }
226 |
227 | row, err := FindBy(options)
228 |
229 | if err != nil {
230 | t.Error("Expected FindBy to return no errors")
231 | }
232 |
233 | if row["permalink"] != "facebook" {
234 | t.Error("Expected permalink to be facebook. Got", row["permalink"])
235 | }
236 |
237 | if row["company_name"] != "Facebook" {
238 | t.Error("Expected company name to be Facebook. Got", row["company_name"])
239 | }
240 |
241 | if row["number_employees"] != "450" {
242 | t.Error("Expected number of employees to be 450. Got", row["number_employees"])
243 | }
244 |
245 | if row["category"] != "web" {
246 | t.Error("Expected category to be web. Got", row["category"])
247 | }
248 |
249 | if row["city"] != "Palo Alto" {
250 | t.Error("Expected city to be Palo Alto. Got", row["city"])
251 | }
252 |
253 | if row["state"] != "CA" {
254 | t.Error("Expected state to be CA. Got", row["state"])
255 | }
256 |
257 | if row["funded_date"] != "1-Oct-07" {
258 | t.Error("Expected funded date to be 1-Oct-07. Got", row["funded_date"])
259 | }
260 |
261 | if row["raised_amount"] != "300000000" {
262 | t.Error("Expected raised amount to be 300000000. Got", row["raised_amount"])
263 | }
264 |
265 | if row["raised_currency"] != "USD" {
266 | t.Error("Expected raised currency to be USD. Got", row["raised_currency"])
267 | }
268 |
269 | if row["round"] != "c" {
270 | t.Error("Expected round to be c. Got", row["round"])
271 | }
272 | }
273 |
274 | func TestFindByNonExistence(t *testing.T) {
275 | options := map[string]string{
276 | "company_name": "NotFacebook",
277 | }
278 |
279 | _, err := FindBy(options)
280 |
281 | if err == nil {
282 | t.Error("Expected FindBy to return an error")
283 | }
284 | }
285 |
--------------------------------------------------------------------------------
/java/funding-raised/src/main/java/com/checkr/interviews/FundingRaised.java:
--------------------------------------------------------------------------------
1 | package com.acme.interviews;
2 |
3 | import java.util.*;
4 | import com.opencsv.CSVReader;
5 | import java.io.FileReader;
6 | import java.io.IOException;
7 |
8 | public class FundingRaised {
9 | public static List