Enable contrast version

Tutor profile: Daniel S.

Inactive
Daniel S.
Robotics Engineer
Tutor Satisfaction Guarantee

Questions

Subject: Python Programming

TutorMe
Question:

Write a one-line lambda function in python to extract the parentheses count of a string. The parentheses count is the sum of openings and closings of parentheses, which should be 0 for a well formed code snippet. $$count("(this(is(a(good(example)))))) = 0"$$ $$count("(this(is(a(bad(example)) ) = 3"$$ Note the limitations of your function in evaluating code, if any. Use only standard library functions for either Python2.7 or 3.

Inactive
Daniel S.
Answer:

count = lambda test_string: sum(1 if clean_val=="(" else -1 for clean_val in filter(lambda val: val in ["(",")"], test_string)) This function will accurately get the overall count, but the count itself is not a perfect metric. For instance, the snippet $$")("$$, which is clearly invalid, has a count of 0.

Subject: SAT

TutorMe
Question:

Aaron is staying at a hotel that charges $99.95 per night plus tax for a room. A tax of 8% is applied to the room rate, and an additional onetime untaxed fee of $5.00 is charged by the hotel. Which of the following represents Aaron’s total charge, in dollars, for staying x nights?

Inactive
Daniel S.
Answer:

$$ f(x) = 5 + (99.95 * x) * (1 + 8/100) $$ This is easily understood if we break it down into component costs. There's a one-time cost of $5 (keywords: $$onetime$$, $$untaxed$$ tell us we don't need to modify it at all) which is where we start our formula. Next we have the cost of the daily room rate, plus tax. To calculate the cost of the room we simply multiply the daily rate by the number of days, i.e. $$ 99.95 * x$$. Finally we need to add tax to the daily rate. Taxing is increasing the base cost by $$ 1 + pct/100 $$, where pct is the tax rate. In our case the tax rate is 8. There's how you get the whole formula.

Subject: C++ Programming

TutorMe
Question:

Create a class that implements a "never-ending" deque; i.e. a deque that returns a default value when it would otherwise be empty. Implement core non-iterator methods, but don't worry about every single constructor, etc. Use C++11 and STL.

Inactive
Daniel S.
Answer:

#include <deque> #include <iostream> template<class T> class NeverendingDeque { protected: std::deque<T> _underlyingQueue; T _defaultValue {}; public: /* Empty constructor */ NeverendingDeque(T defaultValue) { NeverendingDeque(0, T(), defaultValue); } /* List constructor */ NeverendingDeque(int numberOfElements, T valueOfElements, T defaultValue) : _defaultValue(defaultValue), _underlyingQueue(numberOfElements, valueOfElements) { } /* return the size of the underlying container or 1 if it's empty */ int size() { int _currentSize = _underlyingQueue.size(); return (_currentSize == 0) ? 1 : _currentSize; } /* a little silly, but we're never empty */ bool empty() { // we're never empty return false; } T front() { return (_underlyingQueue.size() == 0) ? this->_defaultValue : _underlyingQueue.front(); } T back() { return (_underlyingQueue.size() == 0) ? this->_defaultValue : _underlyingQueue.back(); } /* pass through methods */ void pop_back() { if (_underlyingQueue.size() != 0) _underlyingQueue.pop_back(); } void pop_front() { if (_underlyingQueue.size() != 0) _underlyingQueue.pop_front(); } void push_back(T value) { _underlyingQueue.push_back(value); } void push_front(T value) { _underlyingQueue.push_front(value); } };

Contact tutor

Send a message explaining your
needs and Daniel will reply soon.
Contact Daniel

Request lesson

Ready now? Request a lesson.
Start Lesson

FAQs

What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Lesson" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.