-
C1.1 Life Cycle Phases
-
C1.2 Development Models
-
C1.3 Specifications, Requirements
I needed to generate some data for a test I was writing for my Intro to Programming class. So I asked GPT (3.5 originally) just to give me a list of fruits and their colors. It provided me with a great list which I started to paste into my code and convert to JSON when I realized, GPT should be able to do that for me. So I asked it to and it did a great job.
Then I wanted to add some more attributes to my fruit data so I asked it this:
Q. Can you please describe how your implementation differs from, and is similar to, a program that generates text with a Markov Chain?
A. Yes, of course!
A Markov Chain is a mathematical system that undergoes transitions from one state to another according to certain probabilistic rules. In the context of text generation, a Markov Chain can be used to model the probability of seeing a certain word (or character) given the previous word (or character). Then, the text generator can use the model to randomly sample a sequence of words (or
| /* | |
| * Regexp to match a single HTML tag. | |
| */ | |
| const tagPattern = /^<(\w+)>$/; | |
| /* | |
| * Get or create a single element. If the query is in the form of a tag, e.g. | |
| * '<p>' it creates an element of that type. Otherwise it queries the document | |
| * using the argument as a selector. | |
| */ |
| // Church numerals -- functions of two arguments, a function and a zero value. | |
| // The nth Church numeral applies an n-fold compostion f to the zero value. | |
| const Zero = (f, z) => z; | |
| const One = (f, z) => f(z); | |
| const Two = (f, z) => f(f(z)); | |
| const Three = (f, z) => f(f(f(z))); | |
| // etc. | |
| /* |
| /* | |
| Write a program to generate this output: | |
| # | |
| $# | |
| *$# | |
| $*$# | |
| *$*$# | |
| $*$*$# |
| #!/bin/bash | |
| # Script to clean up local branches that have been merged to the current branch. | |
| # Normally you'd run this while on main. | |
| set -euo pipefail | |
| current=$(git branch --show-current) | |
| git branch --merged | cut -c 3- | while read -r branch; do |
| #!/usr/bin/env python | |
| from math import cos, pi | |
| def svg(width, height, s, fn): | |
| zero = s(0) | |
| points = " ".join(f"{x},{s(fn(x, width))}" for x in range(width)) |
| #!/usr/bin/env python | |
| "Group people so everyone meets everyone." | |
| import sys | |
| from argparse import ArgumentParser, FileType | |
| from collections import defaultdict | |
| from itertools import combinations | |
| from random import choice |
| #!/usr/bin/env python3 | |
| # Let's pretend we have to implement 32-bit multiplication with just | |
| # addition, subtraction, equality/inequality tests, and bit twiddling | |
| # (shifts and bitwise logical ops). For bonus points detect overflow | |
| # and signal via an exception. | |
| # A friend got asked this on an interview. It is a terrible interview | |
| # question unless possibly you're interviewing someone to be a junior | |
| # chip designer or something. But it nerd sniped me anyway as an |