My Codes - Python, C, Stata


My python codes:

1. Cipher's:
  • Atbash Cipher
    • The Atbash cipher is a substitution cipher with a specific key where the letters of the alphabet are reversed. I.e. all As are replaced with Zs, all Bs are replaced with Ys, and so on (Atbash.py)
  • Autokey Cipher
    • The Autokey cipher is closely related to the Vigenere cipher, it differs in how the key material is generated. The Autokey cipher uses a key word in addition to the plaintext as its key material, this makes it more secure than Vigenere (autokey.py)
  • Beaufort Cipher
    • Very similar to the Vigenere cipher, but slightly different algorithm (beaufort.py)
  • Caesar Cipher
    • The caesar cipher (a.k.a the shift cipher, Caesar's Code or Caesar Shift) is one of the earliest known and simplest ciphers (casesar.py)
  • Columnar transposition Cipher
    • Another simple transposition cipher in which letters are arranged in rows and the columns are transposed according to a key (columnar_transposition.py)
  • Four Square Cipher
    • The Four-square cipher encrypts pairs of letters (four_sqaures.py)
  • Fractioned morse Cipher
    • Fractionated Morse first converts the plaintext to morse code, then enciphers fixed size blocks of morse code back to letters. This procedure means plaintext letters are mixed into the ciphertext letters i.e. one plaintext letter does not map to one ciphertext letter (fractioned_morse.py)
  • Hill Cipher
    • An algorithm based on matrix theory. Very good at the diffusion (hill.py)
  • Polybius square Cipher
    • The Polybius Square is essentially identical to the simple substitution cipher, except that each plaintext character is enciphered as 2 ciphertext characters (polybius-sqaure.py)
  • Porta Cipher
    • The Porta cipher is a polyalphabetic substitution cipher that uses a keyword to choose which alphabet to encipher letters (porta.py)
  • Rail fence Cipher
    • A simple transposition cipher (rail-fence.py)
  • ROT13 Cipher
    • The ROT13 cipher is not really a cipher, more just a way to obscure information temporarily. It is often used to hide e.g. movie spoilers (ROT13.py)
  • Simple substitution Cipher
    • A simple cipher used by governments for hundreds of years (simple-substitution.py)
  • Vigenere and gronsfeld Cipher
    • A more complex polyalphabetic substitution cipher (vigenere_and_gronsfeld.py)
2. 2/3rd of average
  • This is the game where player's guess 2/3rd of the average where numbers are restricted between two bounds. The winner is the one closest to 2/3 of the average. This game is used in some game theory classes and is a good example of rationality and common knowledge. Danish Newspaper Politiken conducted this experiment on 19,196 people and the winning value was larger than 0, i.e. 21.6. We can use this to think how far the common knowledge's iteration goes inside the head of agent (approximately). (2-3_of_the_average.py)
3. Game
  • This was a gift birth-day gift made by me for a harry-potter fan (game.py)
4. Is-Palindrome
  • A simple code to check if the entered word/sentence is a palindrome or not (ispall.py)
5. Laspeyres Price Index
  • Calculates quantities, utilities, income levels and price index based on Laspeyres formulation under Homothetic utilities (homo-pL.py)
  • Computes same under non-homothetic utilities (non-homo-pL.py)
6. Pasche Price Index
  • Calculates quantities, utilities, income levels and price index based on Paasche formulation under Homothetic utilities (homo-pP.py)
  • Computes same under non-homothetic utilities (non-homo-pP.py)
7. Merry Christmas
  • Makes Christmas tree, a simple wish for Christmas (merry-christmas.py)
8. Anagram
  • Given two words it tells if they are an anagram of each other (anagram.py)
9. Sorting algorithms
  • Binary search (binsearchiter.py)
  • Merge sort (mergesort.py)
  • Selection sort (selectionsort.py)
  • Insertion sort (insertionsort.py)
10. Integrate (integrate.py)

11. Leap year
  • Enter the year and find out if it is/was/will be the leap year (leapyear.py)
12. Ramanujam
  • Use Ramanujan's formulae to calculate the value of pi
13. Diamond
  • Give the max-width and it makes a diamond
14. Luhn's algorithm
  • Checks if the credit card number, IMEI number etc is valid or not (luhn.py)
15. Rummy
  • Calculate the scores at the end of the rummy-card-game and tells who owes what amount of money. (rummy.py)
16. Tower of Hanoi
  • Asks the number of discs and tells how to solve the game Tower of Hanoi (tower_of_hanoi.py)
17. Cyclone Separator
  • Takes fluid and particle densities, pressure difference, viscosity, inlet area, exit diameter, volumetric flow and eu as input from the file and calculates radial, tangential and axial velocities in the barrel, cone and inner vortex. It also calculates the number of turns, distance travelled, total distance travelled and total time taken in the cone and the barrel. (cyclone_separator_5.py)
18. Sieve of Eratosthenes
  • Inputs a number and gives all the primes up to that number. (seieve.py)
19. Bisection method 
  • Gives roots of a polynomial by bisection method (bisection.py,lab2a.txt,lab2b.txt,lab2c.txt)
20. Fibonacci 
  • Inputs a number and gives Fibonacci sum till then (fib.py, fin_iter.py)
21. Weak form hypothesis - compass rose
  • Making a random walk process and then charting the past return-today return. We find a structure due to tick mark but no predictability (weak_form_test.py)
22. Average stock price analysis
  • Calculates the average price of stocks when different quantities are bought at different prices. Given a specific price, it also tells at a specific price, a range of different quantities which could be bought and the subsequent average price. In addition, for specific quantity, it tells the range of prices it could be bought at and the resulting average price  (average stocks.py)
23. Extract stock prices
  • Given the list of stock names (NIFTY-500) in names.txt file, this code reads those names from the text file and then extract live prices of those stocks and prints them in the file prices.xlsx (scrape-stock-price.py)
24. Assist in Literature survey
  • Export the literature search results as .txt from JSTOR and sciencedirect. The code will read the text files and organize information like author, title, journal name etc into different text files which can then be copied and pasted into excel for making a literature survey document quickly. Note, however, that the obtained text files from export need to be slightly amended before analysis could be done. The format in which it should be is also given the the folder (as the text files which is read by the code is available). The folder also contains code (split_nos.py) which takes the page numbers in the exported text files (as XX--XX or X-X) and splits it to give the initial and final page numbers separately (i.e. XX--YY converted to XX list and YY list) (neuroecon folder)

My STATA codes:

1. Impact of diesel price reforms on asymmetricity of exchange rate passthrough to inflation: Indian perspective (ERPT to inflation.do and respective data-file)
2. Impact of diesel price reforms on asymmetricity of oil price passthrough to inflation: Indian perspective (Oil shock to inflation.do and respective data-file)
3. ARDL models for the impact of different factors on CO2 emissions in India (co2 emissions india.do and respective data-file)
4. Code for NARDL model in which short and long run asymmetries are introduced via positive and negative partial sum decompositions of the explanatory variables. Here its demonstrated using Okun's law for the USA

My C codes:

1. Methods to solve the system of linear equations

  • Gauss Siedel, Jacobi, Successive Over Relaxation  All the three codes in a zip file (g_gs_sor.zip)
  • Gauss elimination, LU Decomposition (gelim_lu.zip)
2. Heat-transfer
  • Consider the problem of source-free heat conduction in an insulated rod whose ends are maintained at a constant temperature of 100 and 500-degree celsius respectively. In this 1D problem calculate the steady-state temperature distribution inside the body using the finite volume method (HT_no-heat-source.zip)
  • Consider a large plate of thickness L and uniform heat generation. The faces have the temperature 100 and 200 degrees respectively. Assuming that the dimension in the y and z directions are large that temperature gradient is significant in the x-direction only. Distribution of the steady-state temperature distribution in the body using the finite volume method (HT_plate-heat-gen.zip)
  • Matrix multiplication (matrix_mult.exe, matrix_mult.cpp) and using pivot element (matrix_pivot.exe, matrix_pivot.cpp)
  • Heat-exchanger hot and cold utilities, trial phase (he-new.cpp, he-new.exe, he-new-2.cpp, he-new-2.exe)


Click here for the folder containing all these files



References: 
Source to learn about cypher's - click here
2/3rd of average - click here

Comments