forked from Aniket965/Hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
165 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
#include<bits/stdc++.h> | ||
|
||
#include<iostream> | ||
using namespace std; | ||
|
||
map<int,int> 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<<fact(5); | ||
int main() | ||
{ | ||
int n; | ||
cout << "Enter a positive integer: "; | ||
cin >> n; | ||
cout << "Factorial of " << n << " = " << factorial(n)<<endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,8 @@ | ||
#include<iostream> | ||
using namespace std; | ||
class Message | ||
{ | ||
public: | ||
void display() { | ||
cout << "Hello World\n"; | ||
} | ||
}; | ||
int main() | ||
{ | ||
Message c; | ||
c.display(); | ||
return 0; | ||
} | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
cout << "Hello, World!"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
<!--Creating a webpage that displays 'Hello World' in webpage--> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<header> | ||
<title>Halo Dunia</title> | ||
<title>Hello World!</title> | ||
</header> | ||
|
||
<body> | ||
<h1><B><U><I>Halo Dunia!</body> | ||
<h1><B><U><I>Hello World!</I></U></B></h1> | ||
<bg>orange</bg> | ||
</body> | ||
|
||
<footer> | ||
<p> Hacktoberfest 2018 </p> | ||
</footer> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
print("Hello World"); | ||
print("Hello World") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] | ||
|