Programming Problems in Ruby
()
About this ebook
This book is intended as a primer for the programming interview. Self-contained, and with problems completely worked out in Ruby, this book covers the fundamentals of computer programming. Sections range from elementary data structures, to searching, selection, and sorting. Each chapter works through the fundamentals of the subject with examples, and closes with more in-depth problems often asked during technical interviews. Provides valuable insights and interesting challenges for beginning programmers and senior engineers.
Read more from Bradley Green
Programming Problems: A Primer for The Technical Interview Rating: 4 out of 5 stars4/5Programming Problems: Advanced Algorithms Rating: 4 out of 5 stars4/5
Related to Programming Problems in Ruby
Related ebooks
Programming Language Concepts: Improving your Software Development Skills Rating: 0 out of 5 stars0 ratingsArt of Clean Code: How to Write Codes for Human Rating: 3 out of 5 stars3/5Software Development Accelerated Essentials: What You Didn't Know, You Needed to Know Rating: 0 out of 5 stars0 ratingsSoftware Engineering & Object Oriented Modeling Rating: 0 out of 5 stars0 ratingsFeature Engineering Bookcamp Rating: 0 out of 5 stars0 ratingsAnalysis and Design of Algorithms: A Beginner’s Hope Rating: 0 out of 5 stars0 ratingsThe Black Book of the Programmer Rating: 0 out of 5 stars0 ratingsHow to Find and Land a Microsoft .NET Development Job Rating: 0 out of 5 stars0 ratingsProgramming Interviews Exposed: Coding Your Way Through the Interview Rating: 0 out of 5 stars0 ratingsRuby For Beginners: Your Guide To Easily Learn Ruby Programming in 7 days Rating: 3 out of 5 stars3/5Surviving the Whiteboard Interview: A Developer’s Guide to Using Soft Skills to Get Hired Rating: 5 out of 5 stars5/5An Introduction to Functional Programming Through Lambda Calculus Rating: 0 out of 5 stars0 ratingsEssential Algorithms: A Practical Approach to Computer Algorithms Using Python and C# Rating: 5 out of 5 stars5/5The Well-Grounded Java Developer, Second Edition Rating: 0 out of 5 stars0 ratingsDistributed Algorithms Rating: 3 out of 5 stars3/5Clojure for Java Developers Rating: 0 out of 5 stars0 ratingsRust In Practice Rating: 0 out of 5 stars0 ratingsDesign Patterns in C#: A Hands-on Guide with Real-world Examples Rating: 0 out of 5 stars0 ratingsSoftware Developer Rating: 0 out of 5 stars0 ratingsFunctional Programming in C#, Second Edition Rating: 0 out of 5 stars0 ratingsLogic for Problem Solving, Revisited Rating: 5 out of 5 stars5/5Learning Object-Oriented Programming Rating: 0 out of 5 stars0 ratingsGetting Started with LLVM Core Libraries Rating: 0 out of 5 stars0 ratingsJava - GUI Applications Rating: 4 out of 5 stars4/5Django Admin Cookbook Rating: 0 out of 5 stars0 ratingsReal-World Functional Programming: With examples in F# and C# Rating: 0 out of 5 stars0 ratingsCloning Internet Applications with Ruby Rating: 5 out of 5 stars5/5Programming Language Structures Rating: 0 out of 5 stars0 ratingsUML A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsThe Way to Go: A Thorough Introduction to the Go Programming Language Rating: 2 out of 5 stars2/5
Programming For You
Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Hacking: Ultimate Beginner's Guide for Computer Hacking in 2018 and Beyond: Hacking in 2018, #1 Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsExcel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5The Unofficial Guide to Open Broadcaster Software: OBS: The World's Most Popular Free Live-Streaming Application Rating: 0 out of 5 stars0 ratingsPython: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Java for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5Python for Beginners: Learn the Fundamentals of Computer Programming Rating: 0 out of 5 stars0 ratingsPYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5HTML in 30 Pages Rating: 5 out of 5 stars5/5Learn JavaScript in 24 Hours Rating: 3 out of 5 stars3/5Python Machine Learning By Example Rating: 4 out of 5 stars4/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5Python QuickStart Guide: The Simplified Beginner's Guide to Python Programming Using Hands-On Projects and Real-World Applications Rating: 0 out of 5 stars0 ratingsLearn SQL in 24 Hours Rating: 5 out of 5 stars5/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5
Reviews for Programming Problems in Ruby
0 ratings0 reviews
Book preview
Programming Problems in Ruby - Bradley Green
_______________________________________________________
Programming Problems in Ruby
A Primer for the Technical Interview
__________________
Jason Brewer and Bradley Green
Copyright 2013 Bradley Green and Jason Brewer
Smashwords Edition
Preface
This book is based on Programming Problems, by Bradley Green. When he approached me about converting it to Ruby, I was very interested - I feel that Ruby’s simplicity and readability make it ideal for reviewing and understanding algorithms.
After graduating college, Microsoft hired me as a Software Developer. This was great for me, because I had very little formal training in software. It was, however, difficult for me to switch jobs - while my team at Microsoft had been willing to take a chance for me, it was still difficult for me to prove myself in software interviews. Eventually, when I finally wanted to change jobs, I had to study extensively - books on algorithms, practiced interviews. I finally went through interviews with Google, Microsoft and Facebook. These covered a lot of ground, much of which I had just learned recently.
This is my attempt at producing the study guide I wish I’d had when preparing for interviews.
I realize now that being able to interview well is a fundamental skill for software developers. The skills I learned practicing for my interviews have made my work more discipline, they’ve lowered my stress level, since now I can switch jobs more easily, and they have helped me do a better job hiring other developers, since I have a better understanding of how important some algorithms and knowledge of them can be.
As with the original, this book is intended as a refresher for seasoned engineers and a handbook for college students and new candidates. In future editions, the references in this book should be compiled into a bibliography. For the moment, I beg your forgiveness for not knowing where many of the techniques used here were first discovered. I have done my best to ensure the code runs with Ruby 1.9.2 and passes some basic test cases.
.1 Structure of the book
There are three main areas that I hope to cover in this work: data structures, searching and sorting, and advanced algorithms. The latter section of the text is broken up into algorithms on strings, numbers, and sequences. As the scope of this work grew, it became clear that the work should be divided into two volumes. The first volume provides a discussion of programming problems covering elementary data structures, abstract data types, searching and sorting. The second volume covers advanced programming problems such as spatial partitioning, substring searching, parsing, and sampling.
The chapter structure is the same within both volumes. Each chapter is a mostly self-contained study guide on a specific topic. Where necessary, I’ve consumed basic algorithms from prior chapters. I attempted to frame it so that complexity increases throughout the chapter. The introductory material should be simply refresher for anyone in the industry; middle sections contain interesting problems and revisions, and the finale an interesting and complex problem. I hope that these problems give the reader some pleasure in thinking about before continuing on to the discussion of the answer.
.2 Programming in Ruby
Ruby is not used very widely in much of industry - C/C++ and Java tend to dominate. Despite this, Ruby has earned itself a wide following for being straightforward, easy to use, and powerful. Ruby has the additional advantages of being concise and readable. Given this, I feel it to be a useful language even for developers not looking to work in Ruby, because it reads a lot like pseudocode. One can learn an algorithm quickly, and write it in another language if necessary during the interview.
In some places, I have not written optimally concise Ruby, instead favoring constructs that translate well to other languages and are hopefully easier to understand. Where it helps make code cleaner, I have encapsulated broader concepts and data structures within classes, but many helper functions I have left as plain functions. In general, I have tried to keep the code as readable as possible. I do use Ruby standard library functions and classes including arrays and hashes freely.
.3 Acknowledgements - Bradley Green
I want to thank L.A.G. for her support and endearing love, and always being there by my side. I also want to thank T.G. for always being there to offer a short diversion to writing, and to my parents R.G. and K.G., for without them I would have never gotten this far.
I also want to thank J. Melvin for a thorough reading, and his helpful comments. The editors of Wikipedia made research extremely efficient, and there is not enough that I can do to thank them for their contribution. And finally, I am grateful to E.M.H. for suggesting this book and her reminder that it should have been completed long ago.
.4 Acknowledgements - Jason Brewer
I would like to thank my parents, Anne and Glen, for kindling my passion for computers, and teaching me to never stop wondering. I want to thank Jennifer for her support, advice, and her contribution of wonderful cover art.
I also want to thank Bradley Green for mentoring me and giving me the opportunity to work with him writing this book.
.5 A last word
In further editions, I hope to make this resemble a proper scientific text. That will require thorough references and proper arguments instead of oblique mentions and assertions of fact. To that end, I am happy to receive your corrections, references, and suggestions regarding any of the material in here at algorithmist@hotmail.com.
Chapter 1
The Technical Interview
For both sides of an interview there is an art. The art is at its best when, at the end of an hour, both parties leave the interview feeling they have spent a productive hour. For the interviewer, it is asking a challenging but tractable question and working with the candidate to find an optimal solution. It is making the candidate feel welcome, valued, and excited to be offered an opportunity to work alongside others who have a passion for technology. And it is being comfortable in the decision to give the candidate a hire or no hire decision.
But of course the candidate has a more complicated role. Even so it is simple to state what must be done; one must be friendly, be straightforward, and know your fundamentals. There is not much else you can do to prepare for an interview.
The main purpose of this book is to provide a refresher for the fundamentals of programming that come up in technical interviews. We do this by presenting interview questions that have been asked in the field, and answering them in as much completeness as will be required by any technical interview. We strive to provide a number of solutions to each question, in order that the reader can understand the difference between a bad and good solution.
1.1 An overview
There is no secret recipe to acing an interview or