diff --git a/C++/factorial.cpp b/C++/factorial.cpp index 4fd7cf379..728113db6 100644 --- a/C++/factorial.cpp +++ b/C++/factorial.cpp @@ -1,19 +1,17 @@ -#include - +#include using namespace std; - -map f; - -int fact(int n){ - - if(n==1 || n==0) - return 1; - else if(f[n]) - return f[n]; - else - return f[n]=n*fact(n-1); +int factorial(int n) +{ + if(n==1 || n==0) + return 1; + else + return n*factorial(n-1); } - -int main(){ - cout<> n; + cout << "Factorial of " << n << " = " << factorial(n)< - using namespace std; - class Message - { - public: - void display() { - cout << "Hello World\n"; - } - }; - int main() - { - Message c; - c.display(); - return 0; - } +#include +using namespace std; + +int main() +{ + cout << "Hello, World!"; + return 0; +} diff --git a/Golang/helloworld.go b/Golang/helloworld.go index 1675319cf..eb735bb3f 100644 --- a/Golang/helloworld.go +++ b/Golang/helloworld.go @@ -1,9 +1,8 @@ package main -import "fmt" -// this is a comment +import "fmt" func main() { - fmt.Println("Hello World") + fmt.Println("Hey, Hello Go. I started learning you") } diff --git a/Html/helloworld.html b/Html/helloworld.html index 0849af8e8..294f53b91 100644 --- a/Html/helloworld.html +++ b/Html/helloworld.html @@ -1,11 +1,16 @@ -
- Halo Dunia + Hello World!
-

Halo Dunia! +

Hello World!

+ orange + + + diff --git a/Python/helloworld.py b/Python/helloworld.py index 012788f01..ad35e5ae3 100644 --- a/Python/helloworld.py +++ b/Python/helloworld.py @@ -1 +1 @@ -print("Hello World"); +print("Hello World") diff --git a/Python/rockpaperscissors.py b/Python/rockpaperscissors.py index 2b53342c2..f13b94678 100644 --- a/Python/rockpaperscissors.py +++ b/Python/rockpaperscissors.py @@ -1,83 +1,44 @@ -# Simple console rock paper scissors game, -# If you want to play it you can paste this code to a site like -# https://www.onlinegdb.com/online_python_compiler - -import random -from time import sleep - -choices = [ - 'rock', - 'paper', - 'scissors', -] - -def get_input(): - valid = False - while valid == False: - global player_choice - player_choice = str(input('Rock paper or scissors?: ')).lower() - if player_choice == 'rock' or player_choice == "paper" or player_choice == "scissors": - valid = True - else: - print('Please choose a valid option. Rock, paper and scissors only') - -def again(): - sleep(0.5) - again = str(input("Do you want to play again (y/n) ?: ")) - if again == 'y': - get_result() - elif again == 'n': - return - else: - print("You can only respon with 'y' or 'n'") - -def loss(): - msg = """ - You lost. - The computer chose {} - """ - print(msg.format(computer_choice)) - again() -def win(): - msg = """ - You won! - The computer chose {} - """ - print(msg.format(computer_choice)) - again() -def draw(): - msg = """ - It's a draw. - The computer chose {} - """ - print(msg.format(computer_choice)) - again() - -def get_result(): - get_input() - global computer_choice - computer_choice = random.choice(choices) - if player_choice == 'rock': - if computer_choice == 'rock': - draw() - elif computer_choice == 'paper': - loss() - else: - win() - elif player_choice == 'paper': - if computer_choice == 'rock': - win() - elif computer_choice == 'paper': - draw() - else: - loss() - elif player_choice == 'scissors': - if computer_choice == 'rock': - loss() - elif computer_choice == 'paper': - win() - else: - draw() - -get_result() - +import random + +r = "rock" +p = "paper" +s = "scissors" + +choices = [r, p, s] + +win = False + +player = input("Enter 'rock', 'paper', or 'scissors': ") + +if player not in choices: + print("invalid input") + +else: + + robot = choices[random.randint(0,2)] # pick a random element from choices[] + + # rock beats scissors, paper beats rock, scissors beats paper + + if player == r: + if robot == s: + win = True + if player == p: + if robot == r: + win = True + if player == s: + if robot == p: + win = True + if player == robot: + win = None + + # print end screen + + print("You picked " + player) + print("I picked " + robot) + if win: + print("You win >:(") + elif win == None: + print("Draw") + else: + print("YOU LOSE!!!!!!") + print("MUAHAHAHAAHAH") diff --git a/Shakespeare/hello.spl b/Shakespeare/hello.spl new file mode 100644 index 000000000..35074d39d --- /dev/null +++ b/Shakespeare/hello.spl @@ -0,0 +1,88 @@ +Romeo, a young man with a remarkable patience. +Juliet, a likewise young woman of remarkable grace. +Ophelia, a remarkable woman much in dispute with Hamlet. +Hamlet, the flatterer of Andersen Insulting A/S. + + + Act I: Hamlet's insults and flattery. + + Scene I: The insulting of Romeo. + +[Enter Hamlet and Romeo] + +Hamlet: + You lying stupid fatherless big smelly half-witted coward! + You are as stupid as the difference between a handsome rich brave + hero and thyself! Speak your mind! + + You are as brave as the sum of your fat little stuffed misused dusty + old rotten codpiece and a beautiful fair warm peaceful sunny summer's + day. You are as healthy as the difference between the sum of the + sweetest reddest rose and my father and yourself! Speak your mind! + + You are as cowardly as the sum of yourself and the difference + between a big mighty proud kingdom and a horse. Speak your mind. + + Speak your mind! + +[Exit Romeo] + + Scene II: The praising of Juliet. + +[Enter Juliet] + +Hamlet: + Thou art as sweet as the sum of the sum of Romeo and his horse and his + black cat! Speak thy mind! + +[Exit Juliet] + + Scene III: The praising of Ophelia. + +[Enter Ophelia] + +Hamlet: + Thou art as lovely as the product of a large rural town and my amazing + bottomless embroidered purse. Speak thy mind! + + Thou art as loving as the product of the bluest clearest sweetest sky + and the sum of a squirrel and a white horse. Thou art as beautiful as + the difference between Juliet and thyself. Speak thy mind! + +[Exeunt Ophelia and Hamlet] + + + Act II: Behind Hamlet's back. + + Scene I: Romeo and Juliet's conversation. + +[Enter Romeo and Juliet] + +Romeo: + Speak your mind. You are as worried as the sum of yourself and the + difference between my small smooth hamster and my nose. Speak your + mind! + +Juliet: + Speak YOUR mind! You are as bad as Hamlet! You are as small as the + difference between the square of the difference between my little pony + and your big hairy hound and the cube of your sorry little + codpiece. Speak your mind! + +[Exit Romeo] + + Scene II: Juliet and Ophelia's conversation. + +[Enter Ophelia] + +Juliet: + Thou art as good as the quotient between Romeo and the sum of a small + furry animal and a leech. Speak your mind! + +Ophelia: + Thou art as disgusting as the quotient between Romeo and twice the + difference between a mistletoe and an oozing infected blister! Speak + your mind! + +[Exeunt] +