Algo problem (Ashish) : array sum

Q: Given a pair of integers (SUM,COUNT), construct every ascending array of COUNT poker cards with sum == SUM. You only have 9 cards, numbered 1 to 9. Clearly COUNT can’t go beyond 9. (In other words, you can only choose 1 to 9 when filling the array, 0 or 1 time, i.e. no repetition.) Note some pairs have no solution. Later we may replace 9 by 999.

Analysis 1: Instead of poker cards, we can think of 9 boxes in a row, numbered 1 to 9, and we put 0 or 1 bean in each of the boxes, to create an array.

Ashish pointed out the "shift" operation. If we shift 2 beans opposite ways then sum remains. Once we have one "good" array, we can shift the 2 outermost beans further out to the limit…

Analysis 2: I feel this is dynamic programming

Analysis 3: start with a smaller deck of cards — 1/2/3/4/5

Observation 1: if COUNT > 4.5 (i.e. 9/2), then the equivalent problem of (45-SUM, 9-COUNT) is probably simpler.

Observation 1: COUNT=2 is easy.

mv-semantic n RVR – %%Lesson #1

#9 std::move()
#8 STL containers using mv-semantic — confusing if we don’t have a firm grounding on …

#7 mv ctor and mv assignment — all the fine details would be poorly understood if we don’t have a grip on …

#5 RVR — is a non-trivial feature by itself. First, we really need to compare…

#3 rval expression vs lval expression — but the “expression” bit is confusing!

#1 lval expression vs lval variable vs objects in a program
This is fundamental concept.

RVR – exclusively(?) used as function parameter

RVR – exclusively(?) used as function parameter

There could be tutorials showing other usages, like a regular variable, but i don’t see any reason. I only understand the motivation for
– move-ctor/move-assignment and
– insertions like push_back()

When there’s a function taking a RVR param, there’s usually a “traditional” overload without RVR, so compiler can choose based on the argument:
* if arg is an rval expression then choose the RVR version [1]
* otherwise, choose the traditional

[1] std::move(myVar) would cast myVar into an rval expression. This is kind of the converter between the 2 overloads.

In some cases, there exists only the RVR version, perhaps because copy is prohibited… Perhaps a class holding a FILE pointer?

Microsoft COM – a few keywords

“COM library” vs “type library”???

I suspect most code (whether people mention COM or not) written before dotnet are probably technically COM code???

— dotnet without the dotnet context —

Client/server — A COM client is whatever code or object that gets a pointer to a COM server and uses its services. A COM server is any object that provides services to clients. In-process servers are implemented in a dynamic linked library (DLL), and out-of-process servers are implemented in an executable file (EXE). Out-of-process servers can reside either on the local computer or on a remote computer.

Registry — COM types are usually listed by GUIDs in the registry, though some COM types are RegFree

DLL — COM components are usually implemented in DLL files, and registration allows only a single version of a DLL. Dotnet classes also exist in DLL or EXE files.

MS-Office – For example COM allows Word documents to dynamically link to data in Excel spreadsheets
Bindings — COM interfaces have bindings in several languages, such as C, C++, Visual Basic

ActiveX – is part of COM

— Excel Addin —
All COM Add-ins must implement each of the five methods of this interface: OnConnection, OnStartupComplete, OnAddinsUpdate, OnBeginShutDown, and OnDisconnection.