ZZucker could you explain to me where or how the variables like %d are getting there information from I have never used that type of variable before.
predator78 22 Junior Poster
Thanks for pointing out the set module I just did some research on it and its great. Seems strange to me though that sort was acting the way it was, although I notice by looking at your code I need to work on my grammer as I put it in another post. I'm workin on it!!! Anyways I think I'll modify the program to use set instead of sort for now, but I wanna find out why sort not working correctly, so I know how to use it in the future. Oh and thanks for the hint on appending the lists to Gribouillis.
predator78 22 Junior Poster
Yeah I did remove the appends from the loop and that output I posted is just showing that the lists seem to be giving a double output on item 3 reggie thus screwing the indexing up tward the bottom of the code, but it shouldn't be the way its coded. Line 13 in the output should never happen, and I think that is why the rest of it don't work right either. If anyone can tell me why it is happening or come up with some type of coding to stop it from doing that would be very helpful.
predator78 22 Junior Poster
O.K. got that and seems reasonable enough, but still getting this output from my p variable first call from before goes into the lists secound after the output of the lists.
0
0
larson,
1
1
digital1,
2
2
apache,
3
3
reggie,
3
reggie,
4
4
joanna,
5
5
arthur,
6
6
saturn,
7
7
ncc1701,
8
8
9
9
angela
As you can see when it gets to reggie for some reason there is one extra ouput which throws the whole thing out of whack!!! It really shouldn't do that but still is.
predator78 22 Junior Poster
Hey guys I finally got my word unscrambler working the other day, now I fire it up with same code same everything and for some reason getting double output from a list that shouldn't be. So if someone could either look this over and find a problem or maybe do a test run on their computer and let me know if something is currupt somehow on my system that would be great to. I just can't tell if its the code or my computer or the interprater that is messed up. I'll attach some sample files to use to run it. Thanks again.
Here is the code.
#decode scrambled word from a word list in 30 sec or less.
wordlist = []
possible = []
matches = []
thelist = []
myvar = -1
c = -1
p = -1
wordlistfile = open('C:\\Documents and Settings\\William\\Desktop\\wordlist\\wordlist.txt', 'r')
possiblefile = open('C:\\Documents and Settings\\William\\Desktop\\possible.txt', 'r')
#add file contents to lists.
while p < 9:
i = -1
p = p + 1
print p
for line in wordlistfile:
wordlist.append(line.strip())
for line in possiblefile:
possible.append(line.strip())
#match length of words to narrow possible matches
for line in wordlist:
i = i + 1
if len(wordlist[i]) == len(possible[p]):
matches.append(wordlist[i])
#narrow further by checking for instances of charecters
word = possible[p]
x = len(matches)
while c < x:
c = c + 1
for letter in word:
if c == x:
break
if not letter in matches[c]:
del matches[c]
x = x - 1
#start …
raolns
1itdalig
caeaph
eeirgg
nanajo
ahtrru
sunatr
cc0171n
rfisedn
aangle
The attachment preview is chopped off after the first 10 KB. Please download the entire file.
html:)
121212
131313
123123
654321
8675309
666666
696969
888888
1234567
21122112
12345678
asdfjkl;
hal9000
bond007
ncc1701d
ncc1701e
ncc1701
thx1138
a12345
abcd1234
1234qwer
1a2b3c
1q2w3e
test123
1p2o3i
puppy123
kitten12
qwerty12
john316
apollo13
ne1469
amanda1
mazda1
angela1
alpha1
sarah1
nirvana1
bubba1
scuba1
rambo1
charlie1
david1
digital1
dragon1
honda1
shadow1
eagle1
freak1
james1
1sanjose
apple1
master1
happy1
martin1
jason1
larry1
number1
robert1
soccer1
direct1
chester1
welcome1
french1
hockey1
chevy1
scooter1
chris1
lucky1
teddy1
phoenix1
hello1
julie1
kevin1
pookie1
viper1
jenny1
jesus1
kelly1
money1
mouse1
sting1
justin1
molly1
sunny1
front242
jordan23
2welcome
h2opolo
bird33
4runner
babylon5
star69
ib6ub9
america7
seven7
number9
porsche9
barbara
database
banana
bananas
canada
jamaica
amanda
valhalla
samantha
yamaha
natasha
alaska
tamara
zapata
avatar
basketba
baseball
basebal
bastard
nebraska
banane
abigail
sabrina
batman
cocacola
cascade
cardinal
claudia
packard
cannonda
apache
america
canela
camera
caesar
warcraft
catalog
chapman
zachary
alicia
patricia
carolina
nicarao
captain
nautica
pascal
rascal
camaro
nascar
deadhead
adidas
alexande
airhead
alexandr
andrea
gandalf
grandma
happyday
indiana
paladin
miranda
adrian
dakota
dallas
mayday
pandora
sandra
xanadu
angela
margaret
stargate
savage
gateway
athena
ariane
pearljam
maryjane
oatmeal
pamela
pantera
vanessa
graymail
iguana
jaguar
galaxy
gasman
hannah
hawaii
mariah
jonathan
marshal
martha
nathan
italia
aikman
saskia
vanilla
mailman
animal
animals
impala
attila
marina
mariposa
nirvana
arizona
joanna
january
lakota
avalon
alyssa
yomama
montana
mantra
tazman
tarzan
starwars
bobcat
badboy
barbie
babies
basketb
rabbit
bamboo
rebecca
abcdef
abcdefg
blackie
excalibu
campbell
tacobell
bigmac
jsbach
columbia
buddha
badger
butthead
bradley
brenda
bernard
ladybug
diablo
blizzard
brandi
bandit
brandon
brandy
beagle
isabelle
elizabet
beanie
beatles
webmaste
beaner
beaver
fireball
beautifu
gabriell
gabriel
poohbear
bertha
benjamin
bailey
beavis
basket
blaster
albert
blazer
barney
strawber
braves
buffalo
football
softball
footbal
foobar
bigman
gambit
global
malibu
library
brasil
brazil
rainbow
obiwan
kombat
snowball
marlboro
snowbal
playboy
absolut
wombat
canced
icecream
chance
celica
cracker
cancer
access
pacific
chicago
chocolat
arctic
clancy
cactus
dickhead
maddock
medical
claude
sundance
dancer
crawford
richard
wildcat
picard
colorado
conrad
corrado
changeme
chelsea
peaches
research
teachers
teacher
creative
cleaner
france
challeng
michael
charlie
archie
hacker
chanel
rachel
charles
patches
jackie
janice
jessica
maverick
metallic
caroline
special
claire
iceman
maurice
maveric
veronica
carrie
cassie
active
slacker
packer
packers
marcel
coltrane
carole
lacrosse
scarlet
scarlett
castle
carmen
pacers
racerx
stacey
catfish
californ
francois
francis
falcon
graphic
logical
garlic
camping
racing
cougars
cougar
chiquita
christia
nicholas
champion
cynthia
charity
charlott
champs
caitlin
victoria
tricia
patrick
calvin
monica
macintos
action
picasso
jackson
malcolm
coolman
classroo
carlos
crystal
compaq
tomcat
marcus
cannon
corona
cyrano
topcat
tractor
laddie
undead
edward
maddog
diamond
donald
woodland
greenday
danielle
dreamer
reader
garfield
alfred
reading
gerald
garden
shithead
daniel
ireland
raider
raiders
daytek
leonard
dreams
anderson
darren
sanders
andrew
retard
tuesday
asdfghjk
asdfgh
dragonfl
florida
friday
asdfjkl
digital
godzilla
douglas
dragon
harold
rhonda
zaphod
howard
shadows
shadow
thursday
indian
island
lindsay
lizard
madison
pyramid
darwin
tardis
wizard
majordom
jordan
dollars
orlando
portland
ronald
rodman
raymond
monday
sunday
password
passwd
jeanette
sweetpea
jaeger
general
eagles
heather
kathleen
hawkeye
elephant
sheena
theresa
theatre
whatever
whateve
amelie
melanie
elaine
valerie
jeanne
yankees
walleye
please
seattle
weasel
awesome
netware
teresa
grateful
frankie
fireman
ferrari
farmer
safety
maggie
georgia
aggies
imagine
galileo
goalie
enigma
mirage
wrangler
angels
german
orange
oranges
ranger
garnet
voyager
garrett
target
health
katherin
sheila
stephani
sapphire
asshole
harley
stealth
whales
ashley
hammer
herman
theman
hamster
matthew
panther
hearts
harvey
jasmine
mikael
mailer
melissa
valentin
lorraine
alpine
aliens
tequila
reality
laurie
alexis
sammie
maxime
marine
vampire
insane
painter
petunia
praise
pirate
sierra
asterix
xavier
jasper
lakers
walker
kramer
market
tanker
wanker
parker
startrek
skater
maxwell
stella
montreal
temporal
sampler
marley
samuel
napoleon
espanol
snapple
planet
lauren
stanley
apples
players
player
raquel
slayer
travel
walter
lestat
superman
masters
master
tanner
suzanne
newpass
peanut
warren
tiffany
wolfgang
flamingo
farming
fugazi
franklin
family
fountain
wolfman
smashing
virginia
sailing
training
stingray
giants
guitar
magnum
morgan
mustang
gymnast
august
mishka
harrison
spanish
shanti
joshua
kathryn
shalom
hansolo
phantom
thomas
shannon
hanson
anthony
sharon
hatton
author
arthur
nikita
williams
william
raistlin
olivia
julian
jasmin
allison
marilyn
alison
polaris
sailor
quality
sylvia
ironman
mountain
tinman
marino
martin
marvin
matrix
nissan
passion
station
tristan
austin
utopia
warriors
warrior
artist
travis
krystal
spanky
sparky
apollo
salmon
psalms
larson
royals
taylor
norman
snowman
sampson
samson
mozart
watson
saturn
tattoo
toyota
sparrow
parrot
passwor
qwaszx
stuart
taurus
bubbles
debbie
bluebird
bigbird
pebbles
robbie
hobbit
jimbob
booboo
december
quebec
robotech
republic
october
public
zxcvbnm
broncos
cowboys
scooby
cowboy
firebird
bigred
bridges
dogbert
thunderb
birdie
blondie
dilbert
doobie
blonde
rosebud
bigdog
bulldog
sunbird
remember
septembe
homebrew
herbert
biteme
bernie
reebok
rebels
byteme
brewster
webster
boogie
junebug
goblue
goober
shelby
theboss
kimberly
zombie
timber
bonnie
benoit
business
nesbitt
bootsie
bluesky
brooke
volleyb
bullet
blowme
trouble
butler
boomer
benson
booster
trebor
buster
bigfoot
blowfish
bright
bowling
biology
gibson
bullshit
robinhoo
bookit
wilbur
bonjour
symbol
boston
browns
buttons
button
brutus
cccccc
electric
science
chicken
cricket
celtics
cyclone
connect
concept
soccer
success
church
chucky
scotch
cloclo
cuddles
depeche
mercedes
frederic
deutsch
duckie
wicked
cinder
director
orchid
dominic
doctor
cheese
coffee
fletcher
gretchen
college
michelle
michele
speech
chester
celine
eclipse
pierce
service
colleen
telecom
welcome
spencer
center
except
secret
chiefs
fletch
fuckme
fucker
michell
mitchell
michel
chipper
hockey
cheryl
techno
porsche
hector
cherry
justice
pickle
mickey
snicker
snickers
cookie
cookies
nicole
police
clipper
mexico
connie
vincent
prince
princess
picture
pisces
security
cruise
rocket
puckett
tucker
clover
computer
compute
mercury
newcourt
courtney
cooper
scooter
coyote
copper
fuckoff
scruffy
fiction
fuckyou
gocougs
christin
christop
chrissy
christ
christy
school
psycho
politics
knicks
lincoln
unicorn
scorpion
corwin
sonics
scorpio
victor
victory
curtis
trucks
control
compton
moocow
cosmos
popcorn
xcountry
country
scotty
deedee
dundee
freddy
dodger
dodgers
defense
freedom
fender
legend
deliver
denise
kennedy
ledzep
denver
speedo
speedy
dexter
friend
friends
doggie
digger
goldie
redwing
design
doogie
dougie
golden
hendrix
thunder
inside
kinder
redskin
dookie
lindsey
dennis
trident
sendit
sidney
detroit
spider
strider
donkey
reynolds
elwood
redrum
wonder
notused
student
sydney
windsurf
oxford
midnight
dwight
hotdog
indigo
kingdom
snoopdog
gordon
phurivdli
judith
dolphin
dolphins
hotrod
dorothy
midori
skidoo
domino
nimrod
wisdom
windows
dustin
stupid
drizzt
london
studly
voodoo
peewee
reefer
eugene
sweetie
kleenex
skeeter
penelope
steelers
steele
eeyore
weezer
jeffrey
jennifer
jenifer
ferret
reggie
george
wheeling
genesis
sergei
energy
hershey
kenneth
shelley
helpme
wheels
promethe
hermes
stephen
einstein
jessie
nellie
leslie
letmein
zeppelin
etoile
nemesis
internet
pierre
jewels
jeremy
jensen
jester
kelsey
loveme
people
explorer
wrestle
letter
wesley
velvet
western
newuser
steven
popeye
europe
pepper
express
tester
stever
testtest
sweets
sweety
tweety
griffey
golfer
fisher
spitfire
flipper
xfiles
fozzie
sunflowe
flowers
flower
flyers
forest
surfer
future
ginger
tigger
google
nugget
gregory
theking
gopher
gemini
gilles
piglet
penguin
guinness
singer
testing
genius
tigers
gretzky
gunner
nguyen
grover
shirley
memphis
sunshine
phoenix
whitney
zenith
hootie
sophie
joseph
huskers
shelly
mother
thumper
hornets
hornet
hunter
shooter
topher
horses
zephyr
sherry
millie
willie
olivier
minnie
winnie
trixie
jupiter
killme
killer
mookie
kermit
kristen
tinker
kittens
kitten
pookie
skipper
miller
soleil
elliot
little
merlin
simple
smiles
smiley
online
wolverin
liverpoo
iloveyou
oliver
louise
violet
silver
sylvie
mortimer
swimmer
emmitt
monique
pentium
mittens
niners
intern
winner
tennis
senior
sniper
sunrise
winter
tootsie
puppies
ripper
sprite
monkey
smokey
network
newyork
volley
yellow
russell
lennon
nelson
looney
loveyou
protel
wolves
purple
russel
turtle
memory
summer
monster
vermont
trumpet
system
newton
yvonne
runner
preston
entrop
predator78 22 Junior Poster
OK just figured it out, the while loop was running one to many times thus the last time throwing it out of index. Here is my revised code to handle it.
#decode scrambled word from a word list in 30 sec or less.
wordlist = []
possible = []
matches = []
wordlist = []
i = -1
c = -1
p = 0
wordlistfile = open('C:\\Documents and Settings\\William\\Desktop\\wordlist\\wordlist.txt', 'r')
possiblefile = open('C:\\Documents and Settings\\William\\Desktop\\possible.txt', 'r')
#add file contents to lists.
for line in wordlistfile:
wordlist.append(line.strip())
for line in possiblefile:
possible.append(line.strip())
#match length of words to narrow possible matches
for line in wordlist:
i = i + 1
if len(wordlist[i]) == len(possible[p]):
matches.append(wordlist[i])
#narrow further by checking for instances of charecters
word = possible[p]
x = len(matches)
while c < x:
c = c + 1
for letter in word:
if c == x:
break
if not letter in matches[c]:
del matches[c]
x = x - 1
predator78 22 Junior Poster
Not sure if this helps or not either but when I print out c or x after the del statement they merge at around the value of 40 and that seems to be when c goes out of the range of the index.
predator78 22 Junior Poster
OK I modified the if statement, but when I tried the matches.remove its trying to remove the letter instead of the list item. If I use use del matches its taking that item out of the list thus making the list smaller, but you are right the length stays the same in the while statement, which I thought it would update it every time it runs the while loop. Is there a way to modify the code so that the index can be updated every time through the loop?
predator78 22 Junior Poster
Hey guys, sorry I thought I had enough of the code to make it understandable what was goin on. Here is the rest of the code. I'm trying to run through the list to check if the two words have the same charecters in them. If they don't I want it to delete that entry from the list. Thanks a bunch.
#decode scrambled word from a word list in 30 sec or less.
wordlist = []
possible = []
matches = []
wordlist = []
i = -1
c = -1
p = 0
wordlistfile = open('C:\\Documents and Settings\\William\\Desktop\\wordlist\\wordlist.txt', 'r')
possiblefile = open('C:\\Documents and Settings\\William\\Desktop\\possible.txt', 'r')
#add file contents to lists.
for line in wordlistfile:
wordlist.append(line.strip())
for line in possiblefile:
possible.append(line.strip())
#match length of words to narrow possible matches
for line in wordlist:
i = i + 1
if len(wordlist[i]) == len(possible[p]):
matches.append(wordlist[i])
#narrow further by checking for instances of charecters
word = possible[p]
x = len(matches)
while c < x:
c = c + 1
print len(matches)
print c
for letter in word:
if letter in matches[c]:
nothing = 0
else:
del matches[c]
predator78 22 Junior Poster
Hey all, still working on my lil program. But now that I'm getting into loops I'm pretty confused on this one. Needless to say I think this is the first while loop I have used since I started python about a week ago. What I'm trying to do at this point is narrow the possibilities down by checking the list for an instance of charecters in the scrambled word. Well I thought this would run through the list and check each item, but the problem is the index seems to be going out of range, I thought because as it is deleting items there is no update to the variable. So I tried putting something like c = c - 1 after deleting but I think this made it worse after printing the index number after and getting negative results. I assume it has something to do with the for loop its wrapped inside, but not sure. Anyway this is the code any help or suggestions would be awsome, thanks btw for all the help so far.
word = possible[p]
x = len(matches)
while c < x:
c = c + 1
print len(matches)
print c
for letter in word:
if letter in matches[c]:
nothing = 0
else:
del matches[c]
predator78 22 Junior Poster
I see thanks, that is one of the few items in the library that I can actually understand, lol. I'm not very good with the terminology so it always sounds so cryptic in the definitions.;)
predator78 22 Junior Poster
Thanks works like a charm. What exactly does strip() do though? Just wondering.
predator78 22 Junior Poster
Hey guys,
I been working on a small project I found on another forum. It's supposed to decode scrambled word from a word list in 30 sec or less. Well I'm pretty noobish so my method might not be all that great, but I'm giving it a go and learning quite a bit along the way. Anyways I figured out how to get the information from the files and put it into lists, but the problem I'm facing now is that the copied lists carry over the \n with them, which I need to get rid of. Any ideas or suggestions would be awsome thanks.
here is the code:
#decode scrambled word from a word list in 30 sec or less.
wordlist = []
possible = []
matches = []
wordlist = []
i = -1
p = 0
wordlistfile = open('C:\\Documents and Settings\\William\\Desktop\\wordlist\\wordlist.txt', 'r')
possiblefile = open('C:\\Documents and Settings\\William\\Desktop\\possible.txt', 'r')
#add file contents to lists.
for line in wordlistfile:
wordlist.append(line)
for line in possiblefile:
possible.append(line)
for line in wordlist:
i = i + 1
if len(wordlist[i]) == len(possible[p]):
matches.append(wordlist[i])
print matches
wordlistfile.close()
possiblefile.close()
predator78 22 Junior Poster
Hahaha thanx a bunch. Looks like I need to work on my grammer quite a bit. :)
predator78 22 Junior Poster
Ok well I made those changes in the code that were kinda screwy, but now the client side hangs instead of printing the message at the end of it. Any ideas?
here is the new code
for server
from socket import *
HOST ='localhost'
PORT =21567
BUFSIZ =1024
ADDR =(HOST, PORT)
serversock = socket(AF_INET, SOCK_STREAM)
serversock.bind(ADDR)
serversock.listen(2)
while 1:
print'waiting for connection...'
clientsock, addr = serversock.accept()
print'Connection made from: ', addr
while 1:
data =clientsock.recv(BUFSIZ)
if not data:
break
clientsock.sendall('echoed' + data)
clientsock.close()
serversock.close()
and for client
from socket import *
HOST ='localhost'
PORT =21567
BUFSIZ =1024
ADDR =(HOST, PORT)
tcpCliSock = socket(AF_INET, SOCK_STREAM)
tcpCliSock.connect(ADDR)
while 1:
data =raw_input('> ')
if not data:
break
tcpCliSock.send(data)
data = tcpCliSock.recv(1024)
if not data:
break
print data
tcpCliSock.close()
predator78 22 Junior Poster
Hello all,
I'm new to the forum and also to python :D. Anyway I have been enjoying it quite a bit and wanted to start into something a bit more technical. So I though sockets would be a good start. I found a great sight , but the first script I found there seems to have some errors.
Could someone plz look this over and fix it for me? And also its been along time since I tackled programming but isn't there like a system pause or something I can stop scripts at a certain point with. If so can someone help refresh my memory. Thanx alot and diggin this sight.:)
code for server
from socket import *
HOST ='localhost'
PORT =21567
BUFSIZ =1024
ADDR =(HOST, PORT)
serversock = socket(AF_INET, SOCK_STREAM)
serversock.bind(ADDR)
serversock.listen(2)
while 1:
print'waiting for connection...'
clientsock, addr = serversock.accept()
print'Connection made from: ', addr
while 1:
data =clientsock.recv(BUFSIZ)
if not data:
break
clientsock.send('echoed', data)
clientsock.close()
serversock.close()
code for client
from socket import *
HOST ='localhost'
PORT =21567
BUFSIZ =1024
ADDR =(HOST, PORT)
tcpCliSock = socket(AF_INET, SOCK_STREAM)
tcpCliSock.connect(ADDR)
while 1:
data =raw_input('> ')
if not data:
break
tcpCliSock.send(data)
data = tcpCliSock.rec(1024)
if not data:
break
print data
tcpCliSock.close()