Giter Site home page Giter Site logo

rubydemos's Introduction

Ruby problems

in array_runs.rb:

  1. Coding Problem


Given an array of unsorted positive ints, write a function that finds runs of 3 consecutive numbers (ascending or descending) and returns the indices where such runs begin. If no such runs are found, return null.

function findConsecutiveRuns(input:Array):Array Example: [1, 2, 3, 5, 10, 9, 8, 9, 10, 11, 7] would return [0, 4, 6, 7]

TO RUN: run array_runs.rb with csv of integers as argument

ex: ruby array_runs.rb 1,2,3,5,10,9,8,9,10,11,7

  1. Write a backend library for auction house for their online auction system so it supports the following operations (assume that we have a in memory key-value store lib and a unique id generator available)

Auctioneer adds an item that can be auctioned. An item has a unique name and reserved price

Auctioneer starts an auction on an item

Participants submit bids to an auction, a new bid has to have a price higher than the current highest bid otherwise it’s not allowed.

Auctioneer calls the auction (when s/he makes the judgement on her own that there will be no more higher bids coming in). If the current highest bid is higher than the reserved price of the item, the auction is deemed as a success otherwise it’s marked as failure. The item sold should be no longer available for future auctions.

Participant/Auctioneer queries the latest action of an item by item name. The library should return the status of the auction if there is any, if the item is sold, it should return the information regarding the price sold and to whom it was sold to.

ASSUMPTIONS/ADJUSTMENTS: I’m not validating item name uniqueness because an item can have multiple auctions and we’re not storing items separately from auctions. I used SecureRandom to generate guids for things. I also stored info on auctions in a simple hash in AuctionHouse. I’m also returning leading bid info on open auctions as well as winning bids on closed ones. Test is not in RSpec format :).

TO TEST: run auction_test.rb

rubydemos's People

Contributors

joshwolf avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.