Skip to content

Instantly share code, notes, and snippets.

View kazemicode's full-sized avatar
🐦

Sara Kazemi kazemicode

🐦
View GitHub Profile
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def rotateRight(self, head: ListNode, k: int) -> ListNode:
if not head or not head.next or k == 0:
return head
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
-- *************************************************************
-- This script creates the Food Flight Schema
-- for CST 438 Final Project
-- *************************************************************
-- ********************************************
-- CREATE THE FOODFLIGHT DATABASE
-- *******************************************
-- create the database
paragraph {
#################################################################################
## Make a Thanksgiving Card! #
#
###############################################################################
# drawCard: the card canvas is a scene with 3 pumpkins with cutouts for faces
###############################################################################
def drawCard(canvas):
# Three pics below should be of faces to draw on cutouts
pic1 = getPic()
def lineDrawingLambda(pic, DIFFERENCE):
# For each pixel in the picture,
# compare the luminance of that pixel to the luminance of the pixels to
# both the pixels below it and to the right.
for x in range(0, getWidth(pic) - 1):
for y in range(0, getHeight(pic) - 1):
px = getPixel(pic, x, y) #pixel to change
right = getPixel(pic, x+1, y) #pixel to right
def lineDrawing(pic):
DIFFERENCE = 10
# Take a color picture and convert it to black and white
betterBnW(pic)
# For each pixel in the picture,
# compare the luminance of that pixel to the luminance of the pixels to
# both the pixels below it and to the right.
for x in range(0, getWidth(pic) - 1):
for y in range(0, getHeight(pic) - 1):
# If there is a large enough difference in the luminance between
# Mirror an image horizontally, bottom to top
def mirrorBottomToTop(picture):
for x in range(0, getWidth(picture)):
for y in range(getHeight(picture)/2 , getHeight(picture)):
color = getColor(getPixel(picture, x, y))
setColor(getPixel(picture, x, getHeight(picture) - y - 1), color)
show(picture)
return(picture)
############################################
# Implement chromakey
############################################
# Parameters: pic is a greenscreen image, back is
# the background image.
def chromaKey(pic, back):
for x in range (0, getWidth(pic)):
for y in range(0, getHeight(pic)):
pic_p = getPixel(pic, x, y)
back_p = getPixel(back, x, y)
############################################
# Posterize a picture
############################################
def artify(pic):
for p in getPixels(pic):
r = getRed(p)
g = getGreen(p)
b = getBlue(p)
#Red adjustment