Skip to content

Commit e5abf04

Browse files
committed
initial commit
1 parent b7c93a3 commit e5abf04

15 files changed

+12300
-2
lines changed

.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

README.md

+42-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
1-
# coding-challenge
2-
2022 Hands-on Coding Challenge
1+
# Take-Home Challenge #2
2+
3+
This challenge consists of both a frontend and backend portion
4+
5+
**Instructions:**
6+
- Clone this repository
7+
- The frontend portion consists of building a simple game, the specs for which can be found below
8+
- This project was created via Create-React-App, so you can just `cd` into the root level and run `npm start` to enable hot reloading while developing the app locally
9+
- Although in a real-life setting this project might be broken into several components, please keep everything in `App.js`
10+
- Feel free to use any styling libraries you are comfortable with
11+
- The backend portion involves writing a handful of Rails methods- the questions and instructions can be found in `/backend-challenge/questions.rb`
12+
- To submit your answer, please email `App.js` and `questions.rb` to [email protected] when finished. Good luck!
13+
14+
<br />
15+
16+
**FRONTEND SPECS**
17+
18+
The task here is to recreate a game called “Quest For Zero”
19+
20+
The rules are:
21+
- Player starts with a random current value of 1-10 (inclusive)
22+
- The object of the game is to get the current value to 0
23+
- The player loses if the current value reaches 10^10 (10,000,000,000)
24+
- On each keystroke of the numbers 1-9, one of four things can happen, occurring randomly:
25+
- The pressed key is appended to the current value
26+
- The pressed key is added to the current value
27+
- The pressed key is subtracted from the current value
28+
- The current value is divided by the pressed key, rounded up
29+
30+
The UI should resemble the attached video. Notable features to include are:
31+
- The current value’s color should be:
32+
- Green if it is less than 1,000
33+
- Orange if it is less than 1,000,000 (but >= 1,000)
34+
- Red if it is greater than 1,000,000
35+
- As the player types, a histogram should display the relative times each key has been pressed
36+
- A button to switch the view, replacing the histogram with numerical counts for each time a number key has been pressed
37+
- (Not pictured in the video) When a player wins or loses:
38+
- A message should should appear saying “YOU WON/LOST”
39+
- If the player lost, the current value should display “Way too big”
40+
- A “Reset” button which starts the game over
41+
42+
DEMO:

backend-challenge/questions.rb

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# INSTRUCTIONS
2+
#
3+
# The following prompts are based off of the schema described in schema.rb
4+
#
5+
# Write the following methods to the best of your ability, and feel free to leave comments about any
6+
# assumptions you make or other notes/thoughts as appropriate. The DBMS is PostgreSQL.
7+
8+
9+
# 1. Write the migration file for creating the `owned_books` table according to schema.rb
10+
# Feel free to improve upon the design of the table, but leave comments about your improvements, if any
11+
12+
class CreateOwnedBooks < ActiveRecord::Migration[7.0]
13+
14+
end
15+
16+
17+
# 2. Given a genre as a string, return an array of Books of that genre. Each Book object should also
18+
# include its Author's full name (as a single string) and the number of Users that own the Book
19+
20+
def self.books_by_genre(genre)
21+
22+
end
23+
24+
25+
# 3. Given an array of case-insensitive query strings, find the Users where first name, last name, full name,
26+
# and/or bio include each string. For example, a User named "John Doe" should match ["Joh", "john doe", "DOE"],
27+
# but not ["John", "asdf"]. The method should return an array of hashes containing the Users' id, first_name,
28+
# and last_name
29+
30+
def self.search_by_query_strings(query_string_array)
31+
32+
end
33+
34+
35+
# 4. Given two user IDs, return the list of Books owned by both Users
36+
37+
def self.mutually_owned_books(first_user_id, second_user_id)
38+
39+
end
40+
41+
42+
# 5. Return an array of Author names (a single string including first + last name) sorted by
43+
# popularity in descending order. Popularity in this context is defined as the number of
44+
# copies of an Author's Books that are owned by Users
45+
46+
def self.author_names_sorted_by_popularity
47+
48+
end

backend-challenge/schema.rb

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# User
2+
#
3+
# has_many :owned_books
4+
# has_many :books, through: :owned_books
5+
#
6+
# Table name: users
7+
#
8+
# id :bigint not null, primary key
9+
# first_name :string not null
10+
# last_name :string not null
11+
# bio :string
12+
# created_at :datetime not null
13+
# updated_at :datetime not null
14+
15+
16+
# Book
17+
#
18+
# belongs_to :author
19+
# has_many :owned_books
20+
# has_many :users, through: :owned_books
21+
#
22+
# Table name: books
23+
#
24+
# id :bigint not null, primary key
25+
# title :string not null
26+
# genre :string
27+
# author_id :string not null
28+
# created_at :datetime not null
29+
# updated_at :datetime not null
30+
31+
32+
# Author
33+
#
34+
# has_many :books
35+
#
36+
# Table name: authors
37+
#
38+
# id :bigint not null, primary key
39+
# first_name :string not null
40+
# last_name :string not null
41+
# created_at :datetime not null
42+
# updated_at :datetime not null
43+
44+
45+
# OwnedBook
46+
#
47+
# belongs_to :user
48+
# belongs_to :book
49+
#
50+
# Table name: owned_books
51+
#
52+
# id :bigint not null, primary key
53+
# user_id :integer not null
54+
# book_id :integer not null
55+
# read_count :integer not null, default(0)
56+
# created_at :datetime not null
57+
# updated_at :datetime not null
58+
59+
# We can assume that each User can only own one copy of a given Book

0 commit comments

Comments
 (0)