Skip to content

Instantly share code, notes, and snippets.

# Python 3 script to convert Arabic numerals to Roman numerals.
# which = input("To arabic or roman numerals? ")
which = "arabic" # currently only works for conversion to roman numerals
if which == "arabic": # placeholder
arabic = input("Input your arabic numeral: ") # prompt user
arabicArray = list(arabic) # [1,2,3,4] represents 1000 + 200 + 30 + 4... How do I make this list a list of ints?
romanArray = [] # fill later
for dig in range((len(arabicArray)-1),-1,-1): # iterate backwards
@GrantSchiller
GrantSchiller / Caesar Cipher.py
Last active October 26, 2022 05:41
Includes basic Caesar cipher encode/decode and an assisted brute force decode. (Python 3.3.2)
def init_(): # Initializes the program
startup = input("Encode or decode with key or decode without key? (ed/dwok)\n> ").lower()
if startup == "dwok": # "dwok" means decode without key.
caesar_cipher_hiddenkey_decode()
elif startup == "ed": # "ed" means encode/decode.
caesar_cipher()
else:
print("It looks like you didn't input ed or dwok. Try again please.")
startup_()
initialize Deck class
Deck shuffle method
Has array of all cards
Makes new array of cards and appends random index value of cards in former array into new array
Deck removecard method
Pop a single card from the array of all cards
Deck givecard method
function Card(val,st) {
this.value = val;
this.suit = st;
}
Card.prototype.getValue = function() {
return this.value;
}
Card.prototype.getSuit = function() {
function Node(c,n) {
this.content = c || null;
this.nextNode = n || null;
}
Node.prototype.getContent = function() {
return this.content;
}
Node.prototype.setContent = function(c) {
@GrantSchiller
GrantSchiller / Stack.js
Last active December 24, 2015 07:28
Stack Runner
/*
Last in, first out linked list.
Stack
- top
+ push
+ pop
+ peek
+ getLength
+ isEmpty
*/
<!--Good luck using this-->
<!--Credit to BC (and Colin Roberts for the sliding effect. Thanks Colin.) Made some alterations myself to suit Stacks-->
<!DOCTYPE html>
<html>
<head>
<title>Stack runner</title>
<style>
* {
margin: 0px;
padding: 0px;
function Queue() {
this.length = 0; // I chose this over a for loop in the method getLength because I thought it might be faster. I think the trade off here is that it adds one extra step every dequeue and enqueue rather than spending n steps every method call for getLength.
this.head = null;
this.tail = null;
}
Queue.prototype.enqueue = function(n) {
if(this.length > 0) {
this.tail.setNextNode(n);
this.tail = n
Node.prototype.setNextNode = function(n) {
this.nextNode = n;
}
if true
puts 'This is true'
end
else
puts 'This is false'
end