Okay... I know that many of us might be thinking about having (owning your own) "Offline Oracle" AI LLM right at hand...But... "What can IT DO that a General String Search in an Internet Browser can't also DO?" Really? Well...There simply is NO comparison...But Okay... For the sake of argument, let's use something that we can all identify with as the focus of an experiment that strictly involves an On Topic Subject Matter we can all relate with:
The VIN
Wouldn't it be nice to have a handy VIN Decoder to double check VINs in Salvage Yards for any specious stolen vehicles being parted out? Here are the actual conversational dialogue requests that I had this evening with Dolphin right along with *IT's* responses as follows:
mrrsm@mrrsm-Precision-M6800:~$ ollama run dolphin-llama3
>>> Write a program in Python that will allow me to decode any General Motors VIN (Vehicle Identification Number)
Sure! Here's a Python program to decode a General Motors VIN:
```python
def decode_vin(vin):
vin_dict = {
'1': 'Passenger Car',
'2': 'Coupe or Convertible',
'3': 'Sport Utility Vehicle (SUV)',
'4': 'Van or Minivan',
'5': 'Heavy Duty Pickup Truck or Van',
'6': 'Light Duty Truck or Van',
'7': 'Medium Duty Truck or Van',
'8': 'Motor Home or Recreational Vehicle (RV)',
'9': 'Four-Door Passenger Car'
}
# First character - vehicle type
print(f"Vehicle Type: {vin_dict[vin[0]]}")
# Second through eighth characters - brand, model, and options
for i in range(1, 9):
index = int(vin) - 1
if i == 1:
print(f"Brand: {['Chevrolet', 'Buick', 'Cadillac',
'GMC'][index]}")
elif i == 2:
print(f"Model: {' '.join([{'A', 'B', 'C', 'D', 'E', 'F'},
['R', 'V', 'P'], ['J', 'K', 'L'], ['M', 'N', 'O']][int(vin) - 1])")
elif i == 3:
print(f"Options: {' '.join([{'1', '2', '3'}, ['4', '5', '6',
'7'], ['8', '9', 'A', 'B']])(int(vin) - 1))")
else:
print(f"Option: {['0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'A', 'B', 'C', 'D', 'E', 'F'][index]}")
# Ninth character - check digit
check_sum = 0
for i in range(8):
check_sum += int(vin) * (10 ** (8 - i))
if vin[8] == str((check_sum % 11) + 1):
print("Check Digit: Valid")
else:
print("Check Digit: Invalid")
vin = input("Enter the VIN: ")
decode_vin(vin)
```
To use this program, call the `decode_vin` function with a valid General Motors VIN as its argument.
>>> Now, create the same Python Program using C++
Here is an equivalent C++ program to decode a General Motors VIN:
```c++
#include <iostream>
#include <map>
std::map<char, std::string> vin_dict{
{'1', "Passenger Car"},
{'2', "Coupe or Convertible"},
{'3', "Sport Utility Vehicle (SUV)"},
{'4', "Van or Minivan"},
{'5', "Heavy Duty Pickup Truck or Van"},
{'6', "Light Duty Truck or Van"},
{'7', "Medium Duty Truck or Van"},
{'8', "Motor Home or Recreational Vehicle (RV)"},
{'9', "Four-Door Passenger Car"}
};
void decodeVIN(std::string vin) {
std::cout << "Vehicle Type: " << vin_dict[vin[0]] << '\n';
for(int i = 1; i < 9; ++i) {
int index = vin - '0' - 1;
if(i == 1)
std::cout << "Brand: " << std::string({ {'C', 'B'}, {'A', 'E'}, {'V', 'R'}, {'G', 'M'}, {'M', 'N'} })[index];
else if(i == 2)
std::cout << "Model: " << std::string({ {'P', 'T'}, {'U', 'H'}, {'J', 'X'}, {'K', 'Y'}, {'L', 'Z'}, {'M', 'B'}, {'N', 'C'}, {'O', 'D'} })[index];
else if(i == 3)
std::cout << "Options: " << (std::string({ {'1', '2'}, {'4', '6'}, {'7', '8'}, {'9', 'A'}, {'0', 'B'} })[index];
else
std::cout << f"Option {i - 3}: {(std::string({{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E'})[index])}\n";
}
int check_sum = 0;
for(int i = 0; i < 8; ++i)
check_sum += (vin - '0') * pow(10, 8 - i);
if(vin[8] != ((check_sum % 11) + 48))
std::cout << "Check Digit: Invalid\n";
else
std::cout << "Check Digit: Valid\n";
}
std::string vin;
std::cout << "Enter the VIN: ";
std::cin >> vin;
decodeVIN(vin);
```
>>> Now, compile the decoderVIN program into an Executable Program
To compile a C++ program, you need to have a C++ compiler installed on your system. If you are using Linux or macOS, you can use the `g++` compiler; if you are using Windows, you can install MinGW or MSYS2. Once you have a C++ compiler installed, navigate to the directory containing the `decoderVIN.cpp` file in your terminal or command prompt. Then run the following command:
```
g++ -o decoderVIN decoderVIN.cpp
```
This will create an executable named 'decoderVIN' that you can run by typing './decoderVIN' into your terminal or command prompt.
>>> Send a message (/? for help)
Now ...Try getting THAT Job done (Twice ...in Two Different Programming Languages) from a Simple Internet Search...and if it can be done WITHOUT using (PAYING) any of the Corporate Online AI LLMs... I'll Eat My Flat Hat...Oh and Yes...THIS entire matter was performed on a Laptop Computer in less than ten minutes... while OFF LINE. :>)