Skip to content

Instantly share code, notes, and snippets.

@MarkLovesMath
MarkLovesMath / CSC 404 AP6 Problem 1 (Addition).yaml
Created February 15, 2020 17:15
CSC 404 - AP6 - Addition (Solution)
name: CSC 404 AP6 Problem 1 (Addition)
source code: |+
# CSC 404 AP6 - Problem 1
# Add 2 non-negative numbers
# f(n1, n2) = n1 + n2
# Each integer is represented as n + 1 (for example, 4 is 11111)
input: '11111*111' #4+2 should = 6 (7 1's)
blank: ' '
start state: q0
@MarkLovesMath
MarkLovesMath / CSC 404 AP2 Problem 2 (String Reversal).yaml
Created February 16, 2020 23:28
CSC 404 AP6 Problem 2 (String Reversal)
name: 'CSC 404 AP2 Problem 2 (String Reversal) '
source code: |
# CSC 404 AP6 - Problem 2
# Reverse a bit string
# f(w) = w^R
# Each integer is represented as n + 1 (for example, 4 is 11111)
input: '001010'
blank: ' '
start state: q0
@MarkLovesMath
MarkLovesMath / CSC 404 - HW2 - Problem 5 (001).yaml
Last active February 23, 2020 17:14
CSC 404 - HW2 - Problem 5 (001)
name: CSC 404 - HW2 - Problem 5 (001)
source code: |-
# CSC 404 HW2 - Problem 5
# Twice as many zeros!
input: '010100'
#input: '000011010001'
#input: '111000000'
blank: ' '
start state: q0
@MarkLovesMath
MarkLovesMath / CSC 404 - HW2 - Problem 8 (mod 3).yaml
Created February 23, 2020 17:08
CSC 404 - HW2 - Problem 8 (mod 3)
name: CSC 404 - HW2 - Problem 8 (mod 3)
source code: |
# CSC 404 HW2 - Problem 5
# Modulo 3
# f(n) = n mod 3
# Each integer is represented as n + 1 ones (for example, 4 is 11111)
input: '11111111'
blank: ' '
start state: q0
@MarkLovesMath
MarkLovesMath / CSC 404 - HW2 - Problem 7 (Double n).yaml
Created February 23, 2020 17:15
CSC 404 - HW2 - Problem 7 (Double n)
name: CSC 404 - HW2 - Problem 7 (Double n)
source code: |-
# CSC 404 HW2 - Problem 7
# Doubling Function!
# f(n) = 2n
# Each integer is represented as n + 1 ones (for example, 4 is 11111)
input: '1111'
blank: ' '
start state: q0
@MarkLovesMath
MarkLovesMath / CSC 404 - HW2 - Problem 4 (001).yaml
Created February 23, 2020 21:15
CSC 404 - HW2 - Problem 4 (001)
name: CSC 404 - HW2 - Problem 4 (001)
source code: |-
# CSC 404 HW2 - Problem 4
# 0^(2k)1^k
input: '000011'
#input: '0000111' #Fails on 3rd 1 (Stuck at q0)
blank: ' '
start state: q0
table:
@MarkLovesMath
MarkLovesMath / CSC 404 - HW2 - Problem 7c (triple n).yaml
Created February 23, 2020 21:16
CSC 404 - HW2 - Problem 7c (triple n)
name: CSC 404 - HW2 - Problem 7c (triple n)
source code: |-
# CSC 404 HW2 - Problem 7c
# Triple Function!
# f(n) = 3n
# Each integer is represented as n + 1 ones (for example, 4 is 11111)
input: '111'
blank: ' '
start state: q0
@MarkLovesMath
MarkLovesMath / CSC 404 - HW2 - Problem 7 (Double n) - Take Two.yaml
Created February 24, 2020 18:52
CSC 404 - HW2 - Problem 7 (Double n) - Take Two
name: CSC 404 - HW2 - Problem 7 (Double n) - Take Two
source code: |-
# CSC 404 HW2 - Problem 7 (Soln 2)
# Doubling Function!
# f(n) = 2n
# Each integer is represented as n + 1 ones (for example, 4 is 11111)
input: '1111'
blank: ' '
start state: q0
name: Even Number of 0s and 1s (Option 1)
source code: |-
# Even Number of 0s and 1s
# Upon seeing a 0 or 1 we then go and seek its 'match'
input: '001101' # try '010110'
#input: '010110'
#input: '111000'
blank: ' '
start state: seekDigit
name: Even Number of 0s and 1s
source code: |-
# Even Number of 0s and 1s
# Find a 0 when reading left to right. Then frind a 1 when reading right to left. Repeat.
input: '0000111' # try '010110'
#input: '010110'
#input: '111000'
blank: ' '
start state: seek0