Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,53 +0,0 @@
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Numerics.Discrete_Random;
procedure Main is
--Creation of type with all the possible answers
--
type Possible_Answers_Type is (It_Is_Certain, It_Is_Decidedly_So, Without_A_Doubt,
Yes_Definitely, You_May_Rely_On_It, As_I_See_It, Yes_Most_Likely,
Outlook_Good, Signs_Point_To_Yes, Yes_Reply_Hazy,
Try_Again, Ask_Again_Later, Better_Not_Tell_You_Now,
Cannot_Predict_Now, Concentrate_And_Ask_Again,
Dont_Bet_On_It, My_Reply_Is_No, My_Sources_Say_No,
Outlook_Not_So_Good, Very_Doubtful);
---------------------------------------------------------------------
-- Variable declaration
Answer : Possible_Answers_Type := Possible_Answers_Type'First;
User_Question : String := " ";
-----------------------------------------------------------------------------
--Randomizer
--
package Random_Answer is new Ada.Numerics.Discrete_Random (Possible_Answers_Type);
use Random_Answer;
G : Generator;
begin
Reset (G); -- Starts the generator in a unique state in each run
--User get provides question
Put_Line ("Welcome."); New_Line;
Put_Line ("WARNING!!! Please remember that there's no need to shake your device for this program to work, and shaking your device could damage it");
New_Line;
Put_Line ("What's your question? ");
Get (Item => User_Question); New_Line;
--Output Answer
Answer := (Random (G)); --Assigns random answer to variable Answer
Put (Answer'Image); --Prints Answer
end Main;

View file

@ -1,12 +1,11 @@
#include <array>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <random>
#include <string>
#include <unordered_set>
#include <vector>
int main()
{
constexpr std::array<const char*, 20> answers = {
int main() {
const std::vector<std::string> answers = {
"It is certain.",
"It is decidedly so.",
"Without a doubt.",
@ -29,16 +28,27 @@ int main()
"Very doubtful."
};
std::string input;
std::srand(std::time(nullptr));
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int> dist(0, answers.size()-1);
std::unordered_set<std::string> askedQuestions;
std::string line;
while (true) {
std::cout << "\n? : ";
std::getline(std::cin, input);
if (input.empty()) {
std::cout << "Ask your question: " << std::flush;
if (!std::getline(std::cin, line))
break;
}
std::cout << answers[std::rand() % answers.size()] << '\n';
if (line.empty())
break;
if (askedQuestions.contains(line))
std::cout << "Your question has already been answered\n";
else {
std::string answer = answers[dist(gen)];
std::cout << answer << "\n";
askedQuestions.insert(std::move(line));
}
}
}

View file

@ -1,89 +0,0 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. 8BALL.
AUTHOR. Bill Gunshannon
INSTALLATION.
DATE-WRITTEN. 12 March 2024
************************************************************
** Program Abstract:
** Just ask the Magic 8 Ball and all will be revealed.
************************************************************
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 ANSWER-TABLE.
10 ANSWER01 PIC X(40)
VALUE "As I see it, yes ".
10 ANSWER02 PIC X(40)
VALUE "Ask again later ".
10 ANSWER03 PIC X(40)
VALUE "Better not tell you now ".
10 ANSWER04 PIC X(40)
VALUE "Cannot predict now ".
10 ANSWER05 PIC X(40)
VALUE "Concentrate and ask again ".
10 ANSWER06 PIC X(40)
VALUE "Don't bet on it ".
10 ANSWER07 PIC X(40)
VALUE "It is certain ".
10 ANSWER08 PIC X(40)
VALUE "It is decidedly so ".
10 ANSWER09 PIC X(40)
VALUE "Most likely ".
10 ANSWER10 PIC X(40)
VALUE "My reply is no ".
10 ANSWER11 PIC X(40)
VALUE "My sources say maybe ".
10 ANSWER12 PIC X(40)
VALUE "My sources say no ".
10 ANSWER13 PIC X(40)
VALUE "Outlook good ".
10 ANSWER14 PIC X(40)
VALUE "Outlook not so good ".
10 ANSWER15 PIC X(40)
VALUE "Reply hazy, try again ".
10 ANSWER16 PIC X(40)
VALUE "Signs point to yes ".
10 ANSWER17 PIC X(40)
VALUE "Very doubtful ".
10 ANSWER18 PIC X(40)
VALUE "Without a doubt ".
10 ANSWER19 PIC X(40)
VALUE "Yes ".
10 ANSWER20 PIC X(40)
VALUE "Yes, definitely ".
10 ANSWER21 PIC X(40)
VALUE "Yes, probably not ".
10 ANSWER22 PIC X(40)
VALUE "You may rely on it ".
10 ANSWER23 PIC X(40)
VALUE "Your question has already been answered ".
01 PRINT-ANSWER REDEFINES ANSWER-TABLE OCCURS 23 TIMES.
10 THE-BALL-SPEAKS PIC X(40).
01 RND PIC 99999.
01 QUESTION PIC X(72).
01 GREETING PIC X(30)
VALUE "Ask and all will be revealed!!".
PROCEDURE DIVISION.
Main-Program.
DISPLAY GREETING.
ACCEPT QUESTION.
MOVE FUNCTION CURRENT-DATE(1:16) TO RND.
PERFORM 8-BALL.
STOP RUN.
8-BALL.
COMPUTE RND =
FUNCTION RANDOM(RND) * 11111.
DISPLAY PRINT-ANSWER(FUNCTION MOD(RND, 23)).
END-PROGRAM.

View file

@ -1,5 +1,4 @@
eight_ball <- function()
{
eight_ball <- function() {
responses <- c("It is certain", "It is decidedly so", "Without a doubt",
"Yes, definitely", "You may rely on it", "As I see it, yes",
"Most likely", "Outlook good", "Signs point to yes", "Yes",
@ -9,24 +8,14 @@ eight_ball <- function()
"My reply is no", "My sources say no", "Outlook not so good",
"Very doubtful")
question <- ""
cat("Welcome to 8 ball!\n\n", "Please ask yes/no questions to get answers.",
" Type 'quit' to exit the program\n\n")
" Type 'quit' to exit the program\n\n", sep="")
while(TRUE)
{
repeat {
question <- readline(prompt="Enter Question: ")
if(question == 'quit')
{
break
}
randint <- runif(1, 1, 20)
cat("Response: ", responses[randint], "\n")
if(question == 'quit') break
cat("Response: ", sample(responses, 1), "\n", sep="")
}
}
if(!interactive())
{
eight_ball()
}
if(!interactive()) eight_ball()