Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions AI Stand-Up Heckler/AI_Stand-Up_Heckler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import random
import time

heckles = [
"You call that a joke?",
"Boo! Get off the stage!",
"I've heard better jokes from my pet parrot!",
"You're funnier when you're silent.",
"Is this a comedy show or a nightmare?",
"You should try another career.",
]

def stand_up_comedy():
print("Welcome to the comedy show!")
time.sleep(2)

for _ in range(5): # Simulating a short stand-up routine
joke = input("Comedian: ") # Comedian's joke
print("AI Heckler:", random.choice(heckles))

print("Thanks for the laughs!")

if __name__ == "__main__":
stand_up_comedy()
37 changes: 37 additions & 0 deletions AI Stand-Up Heckler/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# AI Stand-Up Heckler

AI Stand-Up Heckler is a Python script that simulates a humorous scenario where an AI heckler interrupts a stand-up comedian's routine with funny heckles. The script generates random heckles from a predefined list and allows the user (the comedian) to tell jokes.

## Usage

1. **Installation**:

- The script doesn't require any external libraries. You can run it with a standard Python installation.

2. **Running the Program**:

- Start the program by executing the Python script, and it will guide you through a simulated stand-up comedy routine.

- The AI heckler will randomly choose heckles to interrupt your jokes.

3. **Customization**:

- You can customize the list of heckles by modifying the `heckles` list in the code. Add your own humorous remarks or expand the list as you like.

- You can also adjust the number of jokes the comedian tells during the routine by modifying the loop in the `stand_up_comedy` function.

## Requirements

- Python 3.x (no external libraries required)

## Example

Imagine you want to create a fun and interactive stand-up comedy experience. You run the script, and as you tell your jokes, the AI heckler generates funny heckles, making the performance more amusing.

## License

This project is open-source and available under the [MIT License](LICENSE).

Feel free to expand and customize this script to create a more advanced and interactive stand-up comedy simulation. If you have questions or encounter issues, please create an issue in the [GitHub repository](https://github.com/yourusername/ai-stand-up-heckler).

Enjoy some lighthearted comedy with Python!
59 changes: 35 additions & 24 deletions BFS/BFS.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
graph = {
'5' : ['3','7'],
'3' : ['2', '4'],
'7' : ['8'],
'2' : [],
'4' : ['8'],
'8' : []
}
from collections import defaultdict


class Graph:

def __init__(self):
self.graph = defaultdict(list)

visited = []
queue = []
def addEdge(self,u,v):
self.graph[u].append(v)

def bfs(visited, graph, node):
visited.append(node)
queue.append(node)
def BFS(self, s):
visited = [False] * (len(self.graph))
queue = []
queue.append(s)
visited[s] = True

while queue:
s = queue.pop(0)
print (s, end = " ")
for i in self.graph[s]:
if visited[i] == False:
queue.append(i)
visited[i] = True

# Driver code

while queue:
m = queue.pop(0)
print (m, end = " ")

for neighbour in graph[m]:
if neighbour not in visited:
visited.append(neighbour)
queue.append(neighbour)

print("Following is the Breadth-First Search")
bfs(visited, graph, '5')
# g = Graph()
# g.addEdge(0, 1)
# g.addEdge(0, 2)
# g.addEdge(1, 2)
# g.addEdge(2, 0)
# g.addEdge(2, 3)
# g.addEdge(3, 3)

# print ("Following is Breadth First Traversal"
# " (starting from vertex 2)")
# g.BFS(2)
81 changes: 39 additions & 42 deletions Binary Search/BinarySearch.cpp
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
//C++ program to implement Binary search using recursive method
//For this we are hoping that the array is sorted

#include<bits/stdc++.h>

#include <iostream>
using namespace std;

// A function that return the index of the element if found
// If the number is not there then it will return -1

int bSearch(int binarySearchArray[], int low, int high, int searchingNumber){
int mid = (low + high)/2;
// When the array is initialized then low represents 0th index whereas high represents the last index of the array
if(low > high)
return -1;
// we return -1 when low becomes greater than high denoting that the number is not present
if(binarySearchArray[mid] == searchingNumber)
return mid;
// If the number is found we are returning the index of the number where it was found
else if(searchingNumber > binarySearchArray[mid])
bSearch(binarySearchArray, mid + 1, high, searchingNumber);
// Since the number is greater than the mid element in the array so we increase the index of low by mid+1
// becuase the number before do not contain the number we were searching for
else
bSearch(binarySearchArray, low, mid-1, searchingNumber);
// Since the number is less than the mid elemet in the array so we decrease the index of high to mid-1
// because the number after the middle element do not contain the number we were searching for
}

int main(){
int sizeofArray = 10; // Taking the size of array
int binSearchArray[sizeofArray] = {5, 8 ,12, 34, 36, 40, 45, 50, 56, 61}; // Array containing the elements
int searchNumber = 40;

int isNumberFound = bSearch(binSearchArray, 0, sizeofArray - 1, searchNumber);

if(isNumberFound != -1)
cout<<"The number is found at the index : "<<isNumberFound;
// Since the returned index is not -1 we print that the number was found and at what index
else
cout<<"The number is not present in the array";
// else part is activated when the function returns -1 indicating that the number is not present

return 0;
int main()
{
int count, i, arr[30], num, first, last, middle;
cout<<"how many elements would you like to enter?:";
cin>>count;

for (i=0; i<count; i++)
{
cout<<"Enter number "<<(i+1)<<": ";
cin>>arr[i];
}
cout<<"Enter the number that you want to search:";
cin>>num;
first = 0;
last = count-1;
middle = (first+last)/2;
while (first <= last)
{
if(arr[middle] < num)
{
first = middle + 1;

}
else if(arr[middle] == num)
{
cout<<num<<" found in the array at the location "<<middle+1<<"\n";
break;
}
else {
last = middle - 1;
}
middle = (first + last)/2;
}
if(first > last)
{
cout<<num<<" not found in the array";
}
return 0;
}
53 changes: 10 additions & 43 deletions Cyclic Sort/CyclicSort.cpp
Original file line number Diff line number Diff line change
@@ -1,45 +1,12 @@
#include <bits/stdc++.h>
#include<iostream>
using namespace std;

void cyclicSort(vector<int>& arr)
{
int n=arr.size();
int i = 0;
while(i < n)
{
int correct = arr[i] - 1 ;
if(arr[i] != arr[correct])
{
swap(arr[i], arr[correct]) ;
}
else{
i++ ;
}
void cyclicSort(int &arr[],int n){
int i=0;
while(i<n){
int correct=arr[i]-1;
if(arr[i]!=correct){
swap(arr[i],arr[correct]);
}
else{i++;}
}
}

void printArray(vector<int> arr)
{
int size=arr.size();
for (int i = 0; i < size; i++)
{
cout << arr[i] << " ";
}
cout<<endl;
}

int main()
{
int n;
cin>>n;//Size of array
vector<int> v(n);
for(int i=0;i<n;i++)
{
cin>>v[i];//Input Array elements
}
cyclicSort(v);//Cyclic sort function
cout<<"Printing sorted array:"<<endl;
printArray(v);//Printing Sorted array
return 0;
}

}
10 changes: 6 additions & 4 deletions Factorial/Factorial.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
-- Standard inplementation of a factorial in Haskell
factorial :: Integer -> Integer
factorial 0 = 1
factorial n = n * factorial (n - 1)
-- Luis L Reyes
-- Simple factorial function
module Factorial where
factorial :: Integer -> Integer
factorial 1 = 1
factorial n = n * (factorial (n-1))
51 changes: 15 additions & 36 deletions Factorial/Factorial.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,19 @@
import java.util.Scanner;
/*This a example of Factorization*/
public class Main {
public static long factorial(int n){
long accumulator = 1;
class Factorial{

for(; n > 0; n--){
accumulator *= n;
}

return accumulator;
}

public static boolean isInteger(String text){
try{
Integer.parseInt(text);
return true;
}catch(Exception e){
return false;
}
}

public static void main(String[] args){
InputStreamReader reader = new InputStreamReader(System.in);
BufferedReadLine br = new BufferedReadLine(reader);
System.out.println("Enter a number to factorialize: ");
int input = Integer.parseInt();

if(isInteger(input)){
try{
int num = Integer.parseInt(input);
System.out.println("The factorial of " + num + " is " + factorial(num));
}catch(NumberFormatException e){
System.out.println("What happened there ?");
}
}else {
System.out.println("The input was not a number");
}
public static void main(String[] args){

Scanner s=new Scanner(System.in);
System.out.println("Enter a non negative number");
int n=s.nextInt();
int fact=1;
if(n==0 || n==1){
fact=1;
}else{

for(int i=2;i<=n;i++)
fact*=i;
}
System.out.println("Factorial of the number is "+fact);
}
}
19 changes: 9 additions & 10 deletions FibonacciSeq/Fibonacci.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
-- Inplementation of a fibonacci sequence in Haskell
-- Calculating the nth number in the sequence
fibonacci :: Integer -> Integer
fibonacci 0 = 0
fibonacci 1 = 1
fibonacci n = fibonacci (n-1) + fibonacci (n-2)

-- Generating the first n numbers in the sequence
fibseq :: Integer -> [Integer]
fibseq n = [fibonacci x | x <- [1..n]]
-- Luis L Reyes
-- fibonacci function takes in the nth number
-- of the sequence you want where sequence
-- is 1 while n = 0 or 1
module Fibonacci where
fibonacci :: Integer -> Integer
fibonacci 0 = 1
fibonacci 1 = 1
fibonacci n = (fibonacci (n-1)) + (fibonacci(n-2));
27 changes: 12 additions & 15 deletions FibonacciSeq/Fibonacci.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
class Fibonacci
def series
puts "Enter the Fibonacci value"
n=gets.to_i
f1=0
f2=1
f3=0
while f3<n do
f3=f1+f2
puts f3
f1=f2
f2=f3
end
def fib(n)
if n <= 2
return 1
else
return fib(n-1) + fib(n-2)
end
end
obj1=Fibonacci.new
obj1.series

puts "Enter limit : "
limit = gets.to_i

result = fib(limit)

puts "Fib(#{limit}) = #{result}"
Loading