This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (sub-all s olds news) | |
(define (helper val) | |
(define (final-val val old-vals new-vals) | |
(if (null? old-vals) | |
val | |
(if (eq? val (car old-vals)) | |
(car new-vals) | |
(final-val val (cdr old-vals) (cdr new-vals)) | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (substitute s old new) | |
(define (helper val) | |
(define (final-val val old-val new-val) | |
(if (eq? val old-val) | |
new-val | |
val | |
) | |
) | |
(if (list? val) | |
(map helper val) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (is-already-present? val lst) | |
(if(null? lst) | |
#f | |
(if(= val (car lst)) | |
#t | |
(is-already-present? val (cdr lst)) | |
) | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""The ants module implements game logic for Ants Vs. SomeBees.""" | |
# Name: Evening Waterbury | |
# Email: [email protected] | |
import random | |
import sys | |
from ucb import main, interact, trace | |
from collections import OrderedDict | |
import random |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def group_tweets_by_state(tweets): | |
"""Return a dictionary that aggregates tweets by their nearest state center. | |
The keys of the returned dictionary are state names, and the values are | |
lists of tweets that appear closer to that state center than any other. | |
tweets -- a sequence of tweet abstract data types | |
>>> sf = make_tweet("welcome to san francisco", None, 38, -122) | |
>>> ny = make_tweet("welcome to new york", None, 41, -74) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tetris; | |
import java.awt.*; | |
import javax.swing.*; | |
import java.awt.event.KeyEvent; | |
import java.awt.event.KeyListener; | |
import java.io.IOException; | |
import java.util.*; | |
import java.lang.Thread; | |
import javax.sound.sampled.*; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
import java.util.*; | |
import java.awt.Color; | |
import java.util.Random; | |
public class SandLab | |
{ | |
public static void main(String[] args) | |
{ | |
SandLab lab = new SandLab(120, 80); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Vehicle.java | |
public class Vehicle { | |
String color; | |
} | |
//Truck.java | |
public class Truck extends Vehicle { | |
int bedLength; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rational{ | |
private int numerator; | |
private int denominator; | |
int getNumerator() { | |
return numerator; | |
} | |
int getDenominator() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.util.Arrays; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class SplitWord { | |
public static void main(String[] args){ | |
Scanner sc = new Scanner(System.in); | |
System.out.println( | |
"This program will split those characters into array items delimited by the comma.\n" + |
NewerOlder