Skip to content

Instantly share code, notes, and snippets.

View Cam1337's full-sized avatar

Cameron Wrigley Cam1337

  • Amazon Web Services
  • Seattle, WA
View GitHub Profile
@Cam1337
Cam1337 / pp16.py
Created May 27, 2016 22:11
vAuto Programming Problem 1.6
__author__ = 'Cameron Wrigley'
# output: http://codepad.org/2rqaIoH1
# program description
"""
PP 1.6: In the programming language of your choice, write a method that modifies a string using the following rules:
1. Each word in the input string is replaced with the following: the first letter of the word, the count of distinct letters between the first and last letter, and the last letter of the word. For
example, "Automotive parts" would be replaced by "A6e p3s".
2. A "word" is defined as a sequence of alphabetic characters, delimited by any non-alphabetic characters.
__author__ = 'Cameron Wrigley'
# link with output: http://codepad.org/2rqaIoH1
# program description
"""
PP 1.6: In the programming language of your choice, write a method that modifies a string using the following rules:
1. Each word in the input string is replaced with the following: the first letter of the word, the count of distinct letters between the first and last letter, and the last letter of the word. For
example, "Automotive parts" would be replaced by "A6e p3s".
2. A "word" is defined as a sequence of alphabetic characters, delimited by any non-alphabetic characters.
from time import strftime as strf
from commands import getoutput as gout
from os import listdir, path
def timedate(x):
"""
strftime simplified
"""
x="".join(x.lower().split()[0])
if x=="date":return strf("%m/%d/%y")
Modules=["opcmds","web","spanish","rules","py","cmds","ccmds"]
Vars=["line","CMD","TotalString","Nick","Location","ALen","args","s","rn","PM","iSend","PMSend"]
def ForwardVars(self):
for i in Modules:
for y in Vars:
exec("%s.%s=self.%s"%(i,y,y))
Currently, I have this:
import mymod1
import mymod2
cam="cam"
foo="foo"
mymod1.cam,mymod1.foo=cam,foo
mymod2.cam,mymod2.foo=cam,foo
I want it to be like this
import sys
import time
import random
import math
cam="cam"
foo="foo"
def GetImports():
import sys
import time
import random
import math
cam="cam"
foo="foo"
def GetImports():
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
The young man lay sprawling on the road, his car is a pile of ashes
we were driving on that winding road when the ambulance passed us
a sharp gasp coming from my mom and my dads eyes turned down
we could seen the wreckage ahead, and the young body on the ground
the foot leaves the gas pedal and our car coasts to a halt
as we gaze at the tow truck, and the driver who’s at fault
he is sitting in the road and his eyes are full of grief
15:06 [freenode] (*) Ttech [~ttech@botters/staff/ttech]
15:06 [freenode] (*) ircname : Thomas Techinus
15:06 [freenode] (*) channels : @#botters +##symetrikproductions
15:06 [freenode] (*) server : verne.freenode.net [Newark, NJ, US]
15:06 [freenode] (*) : is using a secure connection
15:06 [freenode] (*) idle : 0 days 0 hours 0 mins 9 secs [signon: Thu May 6 22:08:30 2010]
15:06 [freenode] (*) account : Ttech
15:06 [freenode] (*) End of WHOIS
15:06 [freenode] -ctcp:Ttech- VERSION
15:06 [freenode] CTCP VERSION reply from Ttech: xchat 2.8.6 Linux 2.6.25-ARCH [i686/3.04GHz]