ChatGPT prompts - Programming - Data manipulation tasks

Create Data

Prompt

Generate data about the first 10 U.S. presidents as Prolog facts.

ChatGPT Completion

Here are some Prolog facts about the first 10 U.S. presidents:

president(george_washington, 1789, 1797).
president(john_adams, 1797, 1801).
president(thomas_jefferson, 1801, 1809).
president(james_madison, 1809, 1817).
president(james_monroe, 1817, 1825).
president(john_quincy_adams, 1825, 1829).
president(andrew_jackson, 1829, 1837).
president(martin_van_buren, 1837, 1841).
president(william_henry_harrison, 1841, 1841).
president(john_tyler, 1841, 1845).

Each fact represents a single president and includes their name, the year they took office, and the year they left office.

Note: You can not ask for data to be created from an external source such as Wikipedia as ChatGPT will only generate a reply from what was learned from the training data.

Transform data

Prompt

Convert Prolog facts to JSON.

ChatGPT Completion

Here are the Prolog facts about the first 10 U.S. presidents converted to JSON format:

[
  {
    "president": "george_washington",
    "start_year": 1789,
    "end_year": 1797
  },
  {
    "president": "john_adams",
    "start_year": 1797,
    "end_year": 1801
  },
  {
    "president": "thomas_jefferson",
    "start_year": 1801,
    "end_year": 1809
  },
  {
    "president": "james_madison",
    "start_year": 1809,
    "end_year": 1817
  },
  {
    "president": "james_monroe",
    "start_year": 1817,
    "end_year": 1825
  },
  {
    "president": "john_quincy_adams",
    "start_year": 1825,
    "end_year": 1829
  },
  {
    "president": "andrew_jackson",
    "start_year": 1829,
    "end_year": 1837
  },
  {
    "president": "martin_van_buren",
    "start_year": 1837,
    "end_year": 1841
  },
  {
    "president": "william_henry_harrison",
    "start_year": 1841,
    "end_year": 1841
  },
  {
    "president": "john_tyler",
    "start_year": 1841,
    "end_year": 1845
  }
]

Each fact is represented as a JSON object with three key-value pairs: "president" for the president’s name, "start_year" for the year they took office, and "end_year" for the year they left office. All the facts are enclosed in an array.

Extend data

Prompt

Add two more presidents to Prolog facts.

ChatGPT Completion

Sure, here are the Prolog facts about the first 12 U.S. presidents, including the two additional presidents:

president(george_washington, 1789, 1797).
president(john_adams, 1797, 1801).
president(thomas_jefferson, 1801, 1809).
president(james_madison, 1809, 1817).
president(james_monroe, 1817, 1825).
president(john_quincy_adams, 1825, 1829).
president(andrew_jackson, 1829, 1837).
president(martin_van_buren, 1837, 1841).
president(william_henry_harrison, 1841, 1841).
president(john_tyler, 1841, 1845).
president(james_k_polk, 1845, 1849).
president(zachary_taylor, 1849, 1850).

These facts now include the 11th president, James K. Polk, who served from 1845 to 1849, and the 12th president, Zachary Taylor, who served from 1849 to 1850.

Update data

Prompt

Add ordinal number of each president to the Prolog facts as the first argument.

ChatGPT Completion

Sure, here are the Prolog facts about the first 12 U.S. presidents, including the ordinal number of each president as the first argument:

president(1, george_washington, 1789, 1797).
president(2, john_adams, 1797, 1801).
president(3, thomas_jefferson, 1801, 1809).
president(4, james_madison, 1809, 1817).
president(5, james_monroe, 1817, 1825).
president(6, john_quincy_adams, 1825, 1829).
president(7, andrew_jackson, 1829, 1837).
president(8, martin_van_buren, 1837, 1841).
president(9, william_henry_harrison, 1841, 1841).
president(10, john_tyler, 1841, 1845).
president(11, james_k_polk, 1845, 1849).
president(12, zachary_taylor, 1849, 1850).

In these facts, the first argument of each fact is the ordinal number of the president, followed by their name, start year, and end year as the remaining arguments.

Delete data

Prompt

Remove the last four presidents from the Prolog facts.

ChatGPT Completion

Sure, here are the Prolog facts about the first 8 U.S. presidents, excluding the last 4 presidents:

president(1, george_washington, 1789, 1797).
president(2, john_adams, 1797, 1801).
president(3, thomas_jefferson, 1801, 1809).
president(4, james_madison, 1809, 1817).
president(5, james_monroe, 1817, 1825).
president(6, john_quincy_adams, 1825, 1829).
president(7, andrew_jackson, 1829, 1837).
president(8, martin_van_buren, 1837, 1841).

These facts include only the first 8 U.S. presidents, from George Washington to Martin Van Buren, and exclude the last 4 presidents.

Permute data

Prompt

Create a Prolog fact named pattern with three arguments, red, green and blue.

ChatGPT Completion

Sure, here’s the Prolog fact named pattern with three arguments, red, green, and blue:

pattern(red, green, blue).

This fact indicates that red, green, and blue are the three arguments of the pattern predicate.

Prompt

Create 5 different permutations for the pattern predicate.

ChatGPT Completion

Sure, here are 5 different permutations of the pattern predicate:

pattern(red, green, blue).
pattern(red, blue, green).
pattern(green, red, blue).
pattern(green, blue, red).
pattern(blue, green, red).

Each permutation represents a different order of the three arguments, red, green, and blue.

Obfuscate data creating mapping

Prompt

Obfuscate the 5 different permutations of pattern predicate. Create a key-value table of the changes so that the obfuscated data can be converted back to the original data.

ChatGPT Completion

Sure, here are the 5 different permutations of the pattern predicate obfuscated:

pattern(d1cdd279, 7f1c71f4, 674e3074).
pattern(d1cdd279, 674e3074, 7f1c71f4).
pattern(7f1c71f4, d1cdd279, 674e3074).
pattern(7f1c71f4, 674e3074, d1cdd279).
pattern(674e3074, 7f1c71f4, d1cdd279).

Here is the key-value table for the obfuscation changes:

Original Value Obfuscated Value
red d1cdd279
green 7f1c71f4
blue 674e3074

This table can be used to convert the obfuscated data back to the original data by replacing the obfuscated values with their corresponding original values.

Deobfuscate data using mapping

In a new chat.

Prompt

For the following Prolog predicate pattern use the Original Value - Obfuscated Value table to create the Prolog predicate pattern deobfuscated.

pattern(d1cdd279, 7f1c71f4, 674e3074).
pattern(d1cdd279, 674e3074, 7f1c71f4).
pattern(7f1c71f4, d1cdd279, 674e3074).
pattern(7f1c71f4, 674e3074, d1cdd279).
pattern(674e3074, 7f1c71f4, d1cdd279).

Original Value - Obfuscated Value
red - d1cdd279
green - 7f1c71f4
blue - 674e3074

ChatGPT Completion

The deobfuscated Prolog predicate pattern is:

pattern(red, green, blue).
pattern(red, blue, green).
pattern(green, red, blue).
pattern(green, blue, red).
pattern(blue, green, red).