Notes

  • An Undecidable problem is a problem where the answer is clear such as yes or no. However, not every input is able to correctly answer all the inputs.
  • An unsolvable problem is a problem where the solution is not real. There will never be a solution to the algorithm.
  • A collatz is the idea of wheter or not every number every made, repeating the two simple arithmetic operations will eventually transform every positive integer into 1
  • Hailstone numbers in a collatz sequence thatnis generated until it equals one.
  • An iteration is the process of repeating in code until a condition is met.

Hacks

Hacks 1

num = []
count = 0
def collatz(i):
    global count
    global num
    while i > 1:
        if (i % 2):
            # i is odd
            i = 3*i + 1
            count +=1
            num.append(i)

        else:
            # i is even
            i = i//2
            count +=1
            num.append(i)
    else:
        print(count)
        print(num)
 
 
i = int(input('Enter i: '))
collatz(i)
16
[22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]

Hacks 2

  • The first block is inefficiant because it doesn't use greater than or equal signs. Overall it makes me use 10x more if statments and is very annoying. The second block of code uses greater than or equal signs and is much more efficiant.
score = int(input("What score did you get out of 100?"))

if score == 100:
    print("Got got an A")
if score == 99:
    print("Got got an A")
if score == 98:
    print("Got got an A")
if score == 97:
    print("Got got an A")
if score == 96:
    print("Got got an A")
if score == 95:
    print("Got got an A")
if score == 94:
    print("Got got an A")
if score == 93:
    print("Got got an A") 
if score == 92:
    print("Got got an A")
if score == 91:
    print("Got got an A")   
if score == 90:
    print("Got got an A")   
if score == 89:
    print("Got got an B")   
if score == 88:
    print("Got got an B")  
if score == 87:
    print("Got got an B")  
if score == 86:
    print("Got got an B")  
if score == 85:
    print("Got got an B")  
if score == 84:
    print("Got got an B")  
if score == 83:
    print("Got got an B")  
if score == 82:
    print("Got got an B")  
if score == 81:
    print("Got got an B")  
if score == 80:
    print("Got got an B")  
if score == 79:
    print("Got got an C")
if score == 78:
    print("Got got an C")
if score == 77:
    print("Got got an C")
if score == 76:
    print("Got got an C")
if score == 75:
    print("Got got an C")
if score == 74:
    print("Got got an C")
if score == 73:
    print("Got got an C")
if score == 72:
    print("Got got an C")
if score == 71:
    print("Got got an C")
if score == 69:
    print("Got got an D")
if score == 68:
    print("Got got an D")
if score == 67:
    print("Got got an D")
if score == 66:
    print("Got got an D")
if score == 65:
    print("Got got an D")
if score == 64:
    print("Got got an D")
if score == 63:
    print("Got got an D")
if score == 62:
    print("Got got an D")
if score == 61:
    print("Got got an D")
if score == 60:
    print("Got got an D")
if score <= 59:
    print("Got got an F")
Got got an F
score = int(input("What score did you get out of 100?"))

if 90 <= score <= 100:
    print("Got got an A")
if 80 <= score <= 89:
    print("Got got an B")
if 70 <= score <= 79:
    print("Got got an C")
if 60 <= score <= 69:
    print("Got got an D")
if score <= 59:
    print("Got got an F")
Got got an D

Hacks 3

  • Algorithm efficiency is how short or simple a code can be for a certain function. You want to be able to make your code in the easiest way possible. This is called lazy coding.

Hacks 4

tasks = ["Wake up", "Go to school", "Go to Practice",  "Eat", "Go to sleep"]
 
def complete_tasks(tasks):
    for task in tasks: 
        if task == "Wake up":
            print("Currently waking up")
        elif task == "Go to school":
            print("Currently going to school")
        elif task == "Go to Practice":
            print("Currently going to practice")
        elif task == "Eat":
            print("Currently eating")
        elif task == "Go to sleep":
            print("Currently sleeping")
        
complete_tasks(tasks)
Currently waking up
Currently going to school
Currently going to practice
Currently eating
Currently sleeping

Vocab:

  • An Undecidable problem is a problem where the answer is clear such as yes or no. However, not every input is able to correctly answer all the inputs.
  • An unsolvable problem is a problem where the solution is not real. There will never be a solution to the algorithm.
  • A collatz is the idea of wheter or not every number every made, repeating the two simple arithmetic operations will eventually transform every positive integer into 1
  • Hailstone numbers in a collatz sequence thatnis generated until it equals one.
  • An iteration is the process of repeating in code until a condition is met.
num = []
count = 0
def collatz(i):
    global count
    global num
    while i > 1:
        if (i % 2):
            # i is odd
            i = 3*i + 1
            count +=1
            num.append(i)

        else:
            # i is even
            i = i//2
            count +=1
            num.append(i)
    else:
        print(count)
        print(num)
 
 
i = int(input('Enter i: '))
collatz(i)
5
[16, 8, 4, 2, 1]
i = 1
while i <= 10:
  print(i ** 2)
  i += 1
1
4
9
16
25
36
49
64
81
100