Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts

8/23/2016

METROID NES CLASSIC

Metroid NES Classic (GBA)

Password:
M7-t-- ----w0
2R-LmH m000cN

E. Tanks: 6
Energy: 30
Rockets: 171
Wave Beam
Map: Tourian

Password:
M7-t-- ----w0
2R-o2n q000bc

E. Tanks: 6
Energy: 30
Rockets: 228
Wave Beam
Map: Tourian

If it's not q in this last password it can be l or g

I didn't know how to preserve higher energy in password (game).

5/13/2016

UpPER anD LowEr CaSe

http://pastebin.com/2mHEYxRa

Simple Round Bracket Parsing

For round brackets:

 def RBP(expression):
    flag = 0
    for char in expression:
        if char == "(":
            flag -=1
        elif char == ")":
            if flag < 0:
                flag +=1
            else:
                return False
      
    if flag == 0:
        return True
    return False

5/07/2016

Greatest Common Divisor function with multiple arguments in python

import math 
import fractions
def gcdm(*args):
    UaS = sorted(list(set(list(args))))
    if len(UaS) == 1:
        return list(UaS)[0]
    if len(UaS) == 2:
        return fractions.gcd(UaS[0],UaS[1])
    if len(UaS) >= 3:
        pair = fractions.gcd(UaS[0],UaS[1])
        print(pair)
        for i in range(2,len(UaS)):
            pair = fractions.gcd(pair,UaS[i])
        return pair
    return 0
 
print(gcdm(10,20,30,40,50)) == 10

You can do it with fractions or math module which both have gcd function.

5/03/2016

Basic validating of the email address in python


I saw some regex strings for validing email address that I didn't fully understand so I tried to make it without regex. If I was to make regex for validating email it would look something like this:
re.compile("\w+@\w+[.][A-Za-z]{2,}", re.I | re.A)

Ah, well this is code I was working on:

https://pastebin.com/yiXM9p5a


 
If you need to test out some python code and you don't have python installed on computer but you have internet connection (that's fast enough) you can test your code here.

Links:
https://docs.python.org/3/howto/regex.html?highlight=regular%20expression - HOWTO: Regular Expression (Python)
https://repl.it/ - Online Python and more other languagues.
http://pastebin.com/vRPfSFyN (Until June 9th 2017)
http://pastebin.com/0BKrwwhT