diff --git a/README.md b/README.md index 4fb1f22..d0abc4e 100644 --- a/README.md +++ b/README.md @@ -40,13 +40,15 @@ We are glad to partner with IIT Kharagpur as a part of the Kharagpur Winter of C * [Translations of Hamlet](https://github.com/prateekiiest/Code-Sleep-Python#translations-of-hamlet) * [Classification](https://github.com/prateekiiest/Code-Sleep-Python#classification) * [Whisky Classification](https://github.com/prateekiiest/Code-Sleep-Python#whisky-classification) -* [Bird Migration](https://github.com/prateekiiest/Code-Sleep-Python#Bird_mirgation) -* [Social Network Analysis](https://github.com/prateekiiest/Code-Sleep-Python#social_network) -* [Prime](https://github.com/prateekiiest/Code-Sleep-Python#prime-number-finder) -* [Website status check](https://github.com/prateekiiest/Code-Sleep-Python#website_status_check) -* [Encryption-Techniques](https://github.com/prateekiiest/Code-Sleep-Python#Encryption-Techniques) -* [Inception Tic-Tac-Toe](https://github.com/prateekiiest/Code-Sleep-Python#inception_tic-tac-toe) + +* [Bird Migration](https://github.com/prateekiiest/Code-Sleep-Python#bird-migration) +* [Social Network Analysis](https://github.com/prateekiiest/Code-Sleep-Python#social-network-analysis) +* [Prime](https://github.com/prateekiiest/Code-Sleep-Python#Prime) +* [Website status check](https://github.com/prateekiiest/Code-Sleep-Python#website-status-check) +* [Encryption-Techniques](#encryption-techniques) +* [Inception Tic-Tac-Toe](https://github.com/prateekiiest/Code-Sleep-Python#inception-tic-tac-toe) * [Sprint](https://github.com/prateekiiest/Code-Sleep-Python#sprint) +* [Floating Text](#floating-text) ---------------------------------- @@ -54,7 +56,9 @@ We are glad to partner with IIT Kharagpur as a part of the Kharagpur Winter of C Tic-Tac-Toe (or noughts and crosses) is a simple strategy game in which two players take turns placing a mark on a 3x3 board, attempting to make a row, column, or diagonal of three with their mark. In this homework, we will use the tools we've covered in the past two weeks to create a Tic-Tac-Toe simulator and evaluate basic winning strategies. -![](https://upload.wikimedia.org/wikipedia/commons/8/8e/TicTacToe-6549127nnXOp.gif) Players soon discover that best play from both parties leads to a draw. Because of the simplicity of Tic-Tac-Toe, it is often used as a pedagogical tool for teaching the concepts of good sportsmanship and the branch of artificial intelligence that deals with the searching of game trees. It is straightforward to write a computer program to play Tic-Tac-Toe perfectly, to enumerate the 765 essentially different positions (the state space complexity), or the 26.830 possible games up to rotations and reflections (the game tree complexity) on this space. +![](https://upload.wikimedia.org/wikipedia/commons/8/8e/TicTacToe-6549127nnXOp.gif) + +Players soon discover that best play from both parties leads to a draw. Because of the simplicity of Tic-Tac-Toe, it is often used as a pedagogical tool for teaching the concepts of good sportsmanship and the branch of artificial intelligence that deals with the searching of game trees. It is straightforward to write a computer program to play Tic-Tac-Toe perfectly, to enumerate the 765 essentially different positions (the state space complexity), or the 26.830 possible games up to rotations and reflections (the game tree complexity) on this space. **[CODE](https://github.com/prateekiiest/Code-Sleep-Python/blob/master/tic-tac-toe/code.py)** @@ -63,6 +67,7 @@ Tic-Tac-Toe (or noughts and crosses) is a simple strategy game in which two play ### Hangman Hangman is a simple game where a player will guess a word letter by letter. + ![](http://daramcq.github.io/img/hangman-game-5.png) In this project, you will create a program that generates a random word that you must guess. @@ -178,6 +183,15 @@ Encryption is an interesting piece of technology that works by scrambling data s ---------------------------------------------------- +### Floating Text + +Floating Text is a simple program which displays a given String as a floating string on the terminal. + +![demo](/floating_text/floating_text.gif) + +**[CODE](/floating_text/floating_text.py)** + +---------------------------------------------------- ## Getting started with Python diff --git a/floating_text/floating_text.gif b/floating_text/floating_text.gif new file mode 100644 index 0000000..143321a Binary files /dev/null and b/floating_text/floating_text.gif differ diff --git a/floating_text/floating_text.py b/floating_text/floating_text.py new file mode 100644 index 0000000..ef01b2a --- /dev/null +++ b/floating_text/floating_text.py @@ -0,0 +1,248 @@ +#import os +import time + +width =79 + +text = raw_input("Enter the text: ").upper() + +printedtext = [ "","","","","" ] + +characters = { " " : [ " ", + " ", + " ", + " ", + " " ], + + "A" : [ " * ", + " * * ", + "* *", + "*****", + "* *" ], + + "B" : [ "**** ", + "* *", + "**** ", + "* *", + "**** " ], + + "C" : [ " ****", + "* ", + "* ", + "* ", + " ****" ], + + "D" : [ "**** ", + "* *", + "* *", + "* *", + "**** " ], + + "E" : [ "*****", + "* ", + "*****", + "* ", + "*****" ], + + "F" : [ "*****", + "* ", + "*****", + "* ", + "* " ], + + "G" : [ " ****", + "* ", + "* ***", + "* *", + " ****" ], + + "H" : [ "* *", + "* *", + "*****", + "* *", + "* *" ], + + "I" : [ "*****", + " * ", + " * ", + " * ", + "*****" ], + + "J" : [ "*****", + " * ", + " * ", + "* * ", + "**** " ], + + "K" : [ "* *", + "* * ", + "*** ", + "* * ", + "* *" ], + + "L" : [ "* ", + "* ", + "* ", + "* ", + "*****" ], + + "M" : [ "* *", + "** **", + "* * *", + "* *", + "* *" ], + + "N" : [ "* *", + "** *", + "* * *", + "* **", + "* *" ], + + "O" : [ " *** ", + "* *", + "* *", + "* *", + " *** " ], + + "P" : [ "**** ", + "* *", + "**** ", + "* ", + "* " ], + + "Q" : [ " *** ", + "** *", + "* * *", + " *** ", + " * " ], + + "R" : [ "**** ", + "* *", + "**** ", + "* * ", + "* *" ], + + "S" : [ " ****", + "* ", + " *** ", + " *", + "**** " ], + + "T" : [ "*****", + " * ", + " * ", + " * ", + " * " ], + + "U" : [ "* *", + "* *", + "* *", + "* *", + " *** " ], + + "V" : [ "* *", + "* *", + "* *", + " * * ", + " * " ], + + "W" : [ "* *", + "* *", + "* * *", + "** **", + "* *" ], + + "X" : [ "* *", + " * * ", + " * ", + " * * ", + "* *" ], + + "Y" : [ "* *", + "* *", + " * * ", + " * ", + " * " ], + + "Z" : [ "*****", + " * ", + " * ", + " * ", + "*****" ], + + "1" : [ " ** ", + "* * ", + " * ", + " * ", + "*****" ], + + "2" : [ "*****", + " *", + "*****", + "* ", + "*****" ], + + "3" : [ "*****", + " *", + " ****", + " *", + "*****" ], + + "4" : [ "* *", + "* *", + "*****", + " *", + " *" ], + + "5" : [ "*****", + "* ", + "*****", + " *", + "*****" ], + + "6" : [ "*****", + "* ", + "*****", + "* *", + "*****" ], + + "7" : [ "*****", + " * ", + " * ", + " * ", + "* " ], + + "8" : [ "*****", + "* *", + "*****", + "* *", + "*****" ], + + "9" : [ "*****", + "* *", + "*****", + " *", + "*****" ], + + "0" : [ "*****", + "* *", + "* *", + "* *", + "*****" ] + + } + + +for row in range(5): + for char in text: + printedtext[row] += (str(characters[char][row]) + " ") + +offset = width +while True: + #os.system("cls") #clears the terminal to show the output. + for row in range(5): + print(" " * offset + printedtext[row][max(0,offset*-1):width - offset]) + offset -=1 + + if offset <= ((len(text)+2)*6) * -1: + offset = width + time.sleep(0.1)