Archive

Posts Tagged ‘Project’

Python: Powerful Digit Counts



Python: Powerful Digit Counts
Problem No.63 @ ProjectEuler
Completed on: Completed on Thu, 11 Jul 2019, 17:21

Just to make my post simple, i am quoting from ProjectEuler page

The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power.
How many n-digit positive integers exist which are also an nth power?


Then, we need to find the loop that will solve this, and we did..



The Code:



# P63
# Power digit count
# Solved
# Completed on Thu, 11 Jul 2019, 17:21

c = 0
for x in range (1,50):

for p in range (1,50) :

if (len(str(x**p)) == p ):

c += 1

print(‘\n We have {} n-digit integers exist which are also an nth power.’.format(c))






Follow me on Twitter..



Advertisements

Python: Pentagon Numbers



Python: Pentagon Numbers
Problem No.44 on ProjectEuler
Completed on: Thu, 11 Jul 2019, 18:37

This problem talking about the Pentagonal numbers and gives us a formula. Using that formula for a certain range of numbers, the generated sequence showing that P4 + P7 = 22 + 70 = 92, 92 is the P8, but if we subtracting (P7 – P4) = 70 – 22 = 48, 48 is not in the generated sequence of pentagonal numbers, so 48 is not pentagonal.

The task here is to find the pair of pentagonal Pj,Pk which their sum and difference are Pentagonal D = Pk – Pj is minimised.(we need to get the D).



The Code:




# P44
# Pentagon Numbers
# Solved
#Completed on Thu, 11 Jul 2019, 18:37


def pn(n):

return int(n*(3*n-1)/2)

pn_list=[]

for n in range (1000,3000) : # I start increasing the range step by step.

pn_list.append(pn(n))

we_found_it = False
for x in range (0,len(pn_list)-1) :

px= pn_list[x]

for y in range (x+1,len(pn_list)-1) :

py= pn_list[y]

if (px+py) in pn_list:

if (py-px) in pn_list:

print(‘\n We found one ‘,px,py,’D = ‘,py-px )

we_found_it = True

if we_found_it : break

print(‘Done’)






Follow me on Twitter..



Python is_prime and time consuming

July 11, 2019 2 comments


Python: is_prime and time consuming
Function enhancement

Once i start solving projectEuler problems i notes that i need the prime numbers in most of cases, so I wrote a function called ‘is_prime’ and it works fine. Some time just to get all the primes in a given range takes some seconds, seconds in computer time means waiting a lot. With some other problems that we need to get the prime in large numbers my function looks slow, since I am not deep in math I search the net for a better way to get the primes or to check if a given number is prime or not.

Definition A prime number (or a prime) is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. wikipedia.org.
So as I understand a prime number is not dividable by any other numbers, so my is_prime function is taking a number let’s say n= 13, and start a loop from 2 to n=13 if we fond a number that divide 13 then 13 is not a prime.

Here is the code:

def is_prime1(num):

for t in range (2, num):

if num % t == 0 :

return False

return True

The function is working fine and we can get the prime numbers, but as I mention above, if we have a large number or a wide range, this will take some time. After searching the web, I found some facts regarding the Prime Numbers:



1. The only even prime number is 2. (So any other even numbers are not prime)
2. If the sum of a number digits is a multiple of 3, that number can be divided by 3.
3. No prime number greater than 5 ends in/with 5.


OK, now I can first cut any range to half by not going through even numbers (if even false). Then, I will see if the number end with 5 or not (if end with 5 false),last I will do a summation of the digits in the number if the sum divide by 3 (if yes false), and if the number pass then i will take it in the loop from 5 to n, and if any number divide it we will return false.



Here is the code after the enhancement:

def is_prime2(num):

if num %2==0 : # pass the even numbers.

return False

num_d= str(num) # if last digits is 5, then not prime

t= len(num_d)

if (num_d[t-1]) == 5 :

return False

tot = 0

for each in str(num):

tot = tot + int(each)

if tot % 3 == 0 : # if digits sum divide by 3, then not prime

return False

for t in range (3, num, 2):

if num % t == 0 :

return False

return True

I test both function on my laptop, for different number ranges, and use the time function to see the time delays with each one. Here is the results. If any one know better way to do this please drop it here. Or on My Twitter.





Follow me on Twitter..



Python: Champernowne’s constant



Python: Champernowne’s constant
Problem No.40 @ ProjectEuler
Completed on: Mon, 1 Jul 2019, 18:01

In This task No.40, basically we need to get some digits from a large decimal fraction, then finding the multiplication of those digits.

ProjectEuler assume that the fraction is: 0.123456789101112131415161718192021222324 …. until 1000000, then we should fined the digits in positions 1, and 10, 100, 1000, 10000, 100000 and 1000000. Here is a copy of the problem screen


So to solve this I create a string variable n_list then using for loop i store the numbers from 1 to 1000000 in it as [12345678910111213141516 … 1000000], and simply get the digits I want using the list index, and Finally I calculate the needed multiplication as required. .. And we solve it. ..




Follow me on Twitter..



Python: Permuted Multiples



Python: Permuted Multiples
Problem No.52 @ Projecteuler

This task Completed on Mon, 1 Jul 2019, 06:08, the goal is to find a number X that if we get the X, X*2, X*3, X*4, X*5, X*6 all the numbers are same digits but in a different order.

I use a function called if_x_in_y (n1,n2) will return True if the two numbers has same digits, False if not. Then a while found_one is not True a loop will examine all numbers starting from 2 until we found_one.



The Code:


# Projecteuler.net
# Permuted multiples
# Problem No.52
# Completed on Mon, 1 Jul 2019, 06:08am (GMT+3)

# if x, x*2, x*3, x*4, x*5, x*6 has the same digits.

def if_x_in_y (n1,n2) :

for x in str(n1) :

if x not in str(n2) :

return False

for x in str(n2):

if x not in str(n1):

return False

return True

x_num = 2
found_one= False

while not found_one:

if if_x_in_y(x_num,x_num*2):

if if_x_in_y(x_num,x_num*3):

if if_x_in_y(x_num,x_num*4):

if if_x_in_y(x_num,x_num*5):

if if_x_in_y(x_num,x_num*6):

print(‘\n Yes, we found one ..’)

found_one = True

print(‘ The Number is ‘,x_num)

x_num += 1

print(x_num,x_num*2,x_num*3,x_num*4,x_num*5,x_num*6)






Follow me on Twitter..



Python: Square Digit Chain



Python: Square Digit Chain
ProjectEuler Problem No.92

Here we have a mathematical definition called Happy Number..

A Happy Number is defined by the following process:

Starting with any positive integer, replace the number by the sum of the squares of its digits in base-ten, and repeat the process until the number either:
equals 1 (where it will stay), or
it loops endlessly in a cycle that does not include 1.
(Wikipedia).


In ProjectEuler the task stated in this problem as ” How many starting numbers below ten million will arrive at 89?”

Enhancement: Here we will do something else, we will try to solve the task and post the answer to the projecteuler portal, BUT we are not talking about this here, we will use the concept of this task to generate chains of looped number and I will use it later in another post (project) and trying to represent this chains in a graphic way.

So to do this we need two functions, First one will read a number, get its digits, squaring each digit and get the summation. To keep our eyes on the numbers we need to store it, so we will use list called the_chain.

To check if we have reach a closed chain then we need to ask if the new number (sum of square digit) exists in the chain list or not. If exists we finish and will return the chain for more manipulating.


I will solve this on my way .. 🙂

In this code we will do the following:

1. We will ask the user to enter a number.

2. We will run the function on that number.

3. Outputs:

If we ends with 1 then we have a Happy Number.

If we have closed chain (current number exists in the chain) then we will have tow cases:

If the current number is the same as the start number, then we will call this “Perfect Chain“. Otherwise we will call it “Tail Chain



The Code:


# Square digit chain.
# Pprojecteuler problem No 92

num = 1
the_chain=[]

def get_square_digit_chain(n):

tot=0

the_chain.append(n)

while n != 0:

tot=0

for each in str(n):

tot= tot + int(each)**2

n = tot

if n in the_chain:

return n

else:

the_chain.append(n)

#We ask the user to enter a number.
num =int(input(“Enter a number “))

chain_closed = get_square_digit_chain(num)
if chain_closed == 1:

print(“We have a Happy Number”)

print(the_chain,’This is Open Chain’)
else:

if chain_closed == num:

print(“We have a Perfect Chain”)

print(the_chain,’Closed on’,chain_closed)

else:

print(“We have a Tail Chain”)

print(the_chain,’Closed on’,chain_closed)






Follow me on Twitter..



Python : Triangle Number



Python: Triangle Number
Projecteuler problem No.42

With Problem 42, we have to read a file containing nearly two-thousand common English words and find how many are triangle words?

Difinetion: Triangle Words: If we give each alphabetical in English language a value related to its corresponding location such as A=1, B=2, C=3 and so on, then we convert the word to a value based on a sum of its characters values, we can said that a word is a triangular if its value equal to sequence in a Triangular Number formula.


Triangular Number formula:
Tn =(n/2)*(n+1)

Example.. If we have a word “SKY”, We will find that:
The Value of S=19
The Value of K= 11
The value of Y= 25

The Total is (19+11+25) = 55

(55) is a number in the Triangular Number Sequence n=10
T10=(10/2)*(10+1)
=5*11
=55


Notes In this task, I will not write a code to read the text-file, but i will copy-paste it in a variable called “The_words”.

The words:
The_words=(“A”,”ABILITY”,”ABLE”,”ABOUT”,”ABOVE”,”ABSENCE”,”ABSOLUTELY”,”ACADEMIC”,”ACCEPT”,”ACCESS”, “ACCIDENT”,”ACCOMPANY”,”ACCORDING”,”ACCOUNT”,”ACHIEVE”,”ACHIEVEMENT”,”ACID”,”ACQUIRE”, “ACROSS”,”ACT”,”ACTION”,”ACTIVE”,”ACTIVITY”,”ACTUAL”,”ACTUALLY”,”ADD”,”ADDITION”,”ADDITIONAL”,”ADDRESS”,”ADMINISTRATION”,”ADMIT”,”ADOPT”,”ADULT”,”ADVANCE”,”ADVANTAGE”,”ADVICE”,”ADVISE”,”AFFAIR”, “AFFECT”,”AFFORD”,”AFRAID”,”AFTER”,”AFTERNOON”,”AFTERWARDS”,”AGAIN”,”AGAINST”,”AGE”,”AGENCY”,”AGENT”,”AGO”,”AGREE”,”AGREEMENT”,”AHEAD”,”AID”,”AIM”,”AIR”,”AIRCRAFT”,”ALL”,”ALLOW”,”ALMOST”, “ALONE”,”ALONG”,”ALREADY”,”ALRIGHT”,”ALSO”,”ALTERNATIVE”,”ALTHOUGH”,”ALWAYS”,”AMONG”,”AMONGST”, “AMOUNT”,”AN”,”ANALYSIS”,”ANCIENT”,”AND”,”ANIMAL”,”ANNOUNCE”,”ANNUAL”,”ANOTHER”,”ANSWER”,”ANY”, “ANYBODY”,”ANYONE”,”ANYTHING”,”ANYWAY”,”APART”,”APPARENT”,”APPARENTLY”,”APPEAL”,”APPEAR”,”APPEARANCE”,”APPLICATION”,”APPLY”,”APPOINT”,”APPOINTMENT”,”APPROACH”,”APPROPRIATE”,”APPROVE”,”AREA”,”ARGUE”, “ARGUMENT”,”ARISE”,”ARM”,”ARMY”,”AROUND”,”ARRANGE”,”ARRANGEMENT”,”ARRIVE”,”ART”,”ARTICLE”, “ARTIST”,”AS”,”ASK”,”ASPECT”,”ASSEMBLY”,”ASSESS”,”ASSESSMENT”,”ASSET”,”ASSOCIATE”,”ASSOCIATION”,”ASSUME”,”ASSUMPTION”,”AT”,”ATMOSPHERE”,”ATTACH”,”ATTACK”,”ATTEMPT”,”ATTEND”,”ATTENTION”,”ATTITUDE”, “ATTRACT”,”ATTRACTIVE”,”AUDIENCE”,”AUTHOR”,”AUTHORITY”,”AVAILABLE”,”AVERAGE”,”AVOID”,”AWARD”, “AWARE”,”AWAY”,”AYE”,”BABY”,”BACK”,”BACKGROUND”,”BAD”,”BAG”,”BALANCE”,”BALL”,”BAND”,”BANK”, “BAR”,”BASE”,”BASIC”,”BASIS”,”BATTLE”,”BE”,”BEAR”,”BEAT”,”BEAUTIFUL”,”BECAUSE”,”BECOME”,”BED”,”BEDROOM”,”BEFORE”,”BEGIN”,”BEGINNING”,”BEHAVIOUR”,”BEHIND”,”BELIEF”,”BELIEVE”,”BELONG”,”BELOW”, “BENEATH”,”BENEFIT”,”BESIDE”,”BEST”,”BETTER”,”BETWEEN”,”BEYOND”,”BIG”,”BILL”,”BIND”,”BIRD”, “BIRTH”,”BIT”,”BLACK”,”BLOCK”,”BLOOD”,”BLOODY”,”BLOW”,”BLUE”,”BOARD”,”BOAT”,”BODY”,”BONE”, “BOOK”,”BORDER”,”BOTH”,”BOTTLE”,”BOTTOM”,”BOX”,”BOY”,”BRAIN”,”BRANCH”,”BREAK”,”BREATH”,”BRIDGE”,”BRIEF”,”BRIGHT”,”BRING”,”BROAD”,”BROTHER”,”BUDGET”,”BUILD”,”BUILDING”,”BURN”,”BUS”,”BUSINESS”, “BUSY”,”BUT”,”BUY”,”BY”,”CABINET”,”CALL”,”CAMPAIGN”,”CAN”,”CANDIDATE”,”CAPABLE”,”CAPACITY”,”CAPITAL”,”CAR”,”CARD”,”CARE”,”CAREER”,”CAREFUL”,”CAREFULLY”,”CARRY”,”CASE”,”CASH”,”CAT”,”CATCH”, “CATEGORY”,”CAUSE”,”CELL”,”CENTRAL”,”CENTRE”,”CENTURY”,”CERTAIN”,”CERTAINLY”,”CHAIN”,”CHAIR”,”CHAIRMAN”,”CHALLENGE”,”CHANCE”,”CHANGE”,”CHANNEL”,”CHAPTER”,”CHARACTER”,”CHARACTERISTIC”,”CHARGE”, “CHEAP”,”CHECK”,”CHEMICAL”,”CHIEF”,”CHILD”,”CHOICE”,”CHOOSE”,”CHURCH”,”CIRCLE”,”CIRCUMSTANCE”,”CITIZEN”,”CITY”,”CIVIL”,”CLAIM”,”CLASS”,”CLEAN”,”CLEAR”,”CLEARLY”,”CLIENT”,”CLIMB”,”CLOSE”, “CLOSELY”,”CLOTHES”,”CLUB”,”COAL”,”CODE”,”COFFEE”,”COLD”,”COLLEAGUE”,”COLLECT”,”COLLECTION”,”COLLEGE”,”COLOUR”,”COMBINATION”,”COMBINE”,”COME”,”COMMENT”,”COMMERCIAL”,”COMMISSION”,”COMMIT”, “COMMITMENT”,”COMMITTEE”,”COMMON”,”COMMUNICATION”,”COMMUNITY”,”COMPANY”,”COMPARE”,”COMPARISON”, “COMPETITION”,”COMPLETE”,”COMPLETELY”,”COMPLEX”,”COMPONENT”,”COMPUTER”,”CONCENTRATE”,”CONCENTRATION”,”CONCEPT”,”CONCERN”,”CONCERNED”,”CONCLUDE”,”CONCLUSION”,”CONDITION”,”CONDUCT”,”CONFERENCE”,”CONFIDENCE”,”CONFIRM”,”CONFLICT”,”CONGRESS”,”CONNECT”,”CONNECTION”,”CONSEQUENCE”,”CONSERVATIVE”,”CONSIDER”, “CONSIDERABLE”,”CONSIDERATION”,”CONSIST”,”CONSTANT”,”CONSTRUCTION”,”CONSUMER”,”CONTACT”,”CONTAIN”,”CONTENT”,”CONTEXT”,”CONTINUE”,”CONTRACT”,”CONTRAST”,”CONTRIBUTE”,”CONTRIBUTION”,”CONTROL”, “CONVENTION”,”CONVERSATION”,”COPY”,”CORNER”,”CORPORATE”,”CORRECT”,”COS”,”COST”,”COULD”,”COUNCIL”,”COUNT”,”COUNTRY”,”COUNTY”,”COUPLE”,”COURSE”,”COURT”,”COVER”,”CREATE”,”CREATION”,”CREDIT”, “CRIME”,”CRIMINAL”,”CRISIS”,”CRITERION”,”CRITICAL”,”CRITICISM”,”CROSS”,”CROWD”,”CRY”,”CULTURAL”, “CULTURE”,”CUP”,”CURRENT”,”CURRENTLY”,”CURRICULUM”,”CUSTOMER”,”CUT”,”DAMAGE”,”DANGER”,”DANGEROUS”, “DARK”,”DATA”,”DATE”,”DAUGHTER”,”DAY”,”DEAD”,”DEAL”,”DEATH”,”DEBATE”,”DEBT”,”DECADE”,”DECIDE”, “DECISION”,”DECLARE”,”DEEP”,”DEFENCE”,”DEFENDANT”,”DEFINE”,”DEFINITION”,”DEGREE”,”DELIVER”,”DEMAND”, “DEMOCRATIC”,”DEMONSTRATE”,”DENY”,”DEPARTMENT”,”DEPEND”,”DEPUTY”,”DERIVE”,”DESCRIBE”,”DESCRIPTION”, “DESIGN”,”DESIRE”,”DESK”,”DESPITE”,”DESTROY”,”DETAIL”,”DETAILED”,”DETERMINE”,”DEVELOP”,”DEVELOPMENT”, “DEVICE”,”DIE”,”DIFFERENCE”,”DIFFERENT”,”DIFFICULT”,”DIFFICULTY”,”DINNER”,”DIRECT”,”DIRECTION”, “DIRECTLY”,”DIRECTOR”,”DISAPPEAR”,”DISCIPLINE”,”DISCOVER”,”DISCUSS”,”DISCUSSION”,”DISEASE”, “DISPLAY”,”DISTANCE”,”DISTINCTION”,”DISTRIBUTION”,”DISTRICT”,”DIVIDE”,”DIVISION”,”DO”,”DOCTOR”, “DOCUMENT”,”DOG”,”DOMESTIC”,”DOOR”,”DOUBLE”,”DOUBT”,”DOWN”,”DRAW”,”DRAWING”,”DREAM”,”DRESS”,”DRINK”, “DRIVE”,”DRIVER”,”DROP”,”DRUG”,”DRY”,”DUE”,”DURING”,”DUTY”,”EACH”,”EAR”,”EARLY”,”EARN”,”EARTH”, “EASILY”,”EAST”,”EASY”,”EAT”,”ECONOMIC”,”ECONOMY”,”EDGE”,”EDITOR”,”EDUCATION”,”EDUCATIONAL”,”EFFECT”, “EFFECTIVE”,”EFFECTIVELY”,”EFFORT”,”EGG”,”EITHER”,”ELDERLY”,”ELECTION”,”ELEMENT”,”ELSE”,”ELSEWHERE”, “EMERGE”,”EMPHASIS”,”EMPLOY”,”EMPLOYEE”,”EMPLOYER”,”EMPLOYMENT”,”EMPTY”,”ENABLE”,”ENCOURAGE”,”END”, “ENEMY”,”ENERGY”,”ENGINE”,”ENGINEERING”,”ENJOY”,”ENOUGH”,”ENSURE”,”ENTER”,”ENTERPRISE”,”ENTIRE”, “ENTIRELY”,”ENTITLE”,”ENTRY”,”ENVIRONMENT”,”ENVIRONMENTAL”,”EQUAL”,”EQUALLY”,”EQUIPMENT”,”ERROR”, “ESCAPE”,”ESPECIALLY”,”ESSENTIAL”,”ESTABLISH”,”ESTABLISHMENT”,”ESTATE”,”ESTIMATE”,”EVEN”,”EVENING”, “EVENT”,”EVENTUALLY”,”EVER”,”EVERY”,”EVERYBODY”,”EVERYONE”,”EVERYTHING”,”EVIDENCE”,”EXACTLY”, “EXAMINATION”,”EXAMINE”,”EXAMPLE”,”EXCELLENT”,”EXCEPT”,”EXCHANGE”,”EXECUTIVE”,”EXERCISE”,”EXHIBITION”, “EXIST”,”EXISTENCE”,”EXISTING”,”EXPECT”,”EXPECTATION”,”EXPENDITURE”,”EXPENSE”,”EXPENSIVE”, “EXPERIENCE”,”EXPERIMENT”,”EXPERT”,”EXPLAIN”,”EXPLANATION”,”EXPLORE”,”EXPRESS”,”EXPRESSION”, “EXTEND”,”EXTENT”,”EXTERNAL”,”EXTRA”,”EXTREMELY”,”EYE”,”FACE”,”FACILITY”,”FACT”,”FACTOR”, “FACTORY”,”FAIL”,”FAILURE”,”FAIR”,”FAIRLY”,”FAITH”,”FALL”,”FAMILIAR”,”FAMILY”,”FAMOUS”,”FAR”, “FARM”,”FARMER”,”FASHION”,”FAST”,”FATHER”,”FAVOUR”,”FEAR”,”FEATURE”,”FEE”,”FEEL”,”FEELING”, “FEMALE”,”FEW”,”FIELD”,”FIGHT”,”FIGURE”,”FILE”,”FILL”,”FILM”,”FINAL”,”FINALLY”,”FINANCE”,”FINANCIAL”, “FIND”,”FINDING”,”FINE”,”FINGER”,”FINISH”,”FIRE”,”FIRM”,”FIRST”,”FISH”,”FIT”,”FIX”,”FLAT”, “FLIGHT”,”FLOOR”,”FLOW”,”FLOWER”,”FLY”,”FOCUS”,”FOLLOW”,”FOLLOWING”,”FOOD”,”FOOT”,”FOOTBALL”, “FOR”,”FORCE”,”FOREIGN”,”FOREST”,”FORGET”,”FORM”,”FORMAL”,”FORMER”,”FORWARD”,”FOUNDATION”,”FREE”, “FREEDOM”,”FREQUENTLY”,”FRESH”,”FRIEND”,”FROM”,”FRONT”,”FRUIT”,”FUEL”,”FULL”,”FULLY”,”FUNCTION”,”FUND”,”FUNNY”,”FURTHER”,”FUTURE”,”GAIN”,”GAME”,”GARDEN”,”GAS”,”GATE”,”GATHER”,”GENERAL”,”GENERALLY”,”GENERATE”,”GENERATION”,”GENTLEMAN”,”GET”,”GIRL”,”GIVE”,”GLASS”,”GO”,”GOAL”,”GOD”,”GOLD”,”GOOD”,”GOVERNMENT”,”GRANT”,”GREAT”,”GREEN”,”GREY”,”GROUND”,”GROUP”,”GROW”,”GROWING”,”GROWTH”,”GUEST”,”GUIDE”,”GUN”,”HAIR”,”HALF”,”HALL”,”HAND”,”HANDLE”,”HANG”,”HAPPEN”,”HAPPY”,”HARD”,”HARDLY”,”HATE”,”HAVE”,”HE”,”HEAD”,”HEALTH”,”HEAR”,”HEART”,”HEAT”,”HEAVY”,”HELL”,”HELP”,”HENCE”,”HER”,”HERE”,”HERSELF”,”HIDE”,”HIGH”,”HIGHLY”,”HILL”,”HIM”,”HIMSELF”,”HIS”,”HISTORICAL”,”HISTORY”,”HIT”,”HOLD”,”HOLE”,”HOLIDAY”,”HOME”,”HOPE”,”HORSE”,”HOSPITAL”,”HOT”,”HOTEL”,”HOUR”,”HOUSE”,”HOUSEHOLD”,”HOUSING”,”HOW”,”HOWEVER”,”HUGE”,”HUMAN”,”HURT”,”HUSBAND”,”I”,”IDEA”,”IDENTIFY”,”IF”,”IGNORE”,”ILLUSTRATE”,”IMAGE”,”IMAGINE”,”IMMEDIATE”,”IMMEDIATELY”,”IMPACT”,”IMPLICATION”,”IMPLY”,”IMPORTANCE”,”IMPORTANT”,”IMPOSE”,”IMPOSSIBLE”,”IMPRESSION”,”IMPROVE”,”IMPROVEMENT”,”IN”,”INCIDENT”,”INCLUDE”,”INCLUDING”,”INCOME”,”INCREASE”,”INCREASED”,”INCREASINGLY”,”INDEED”,”INDEPENDENT”,”INDEX”,”INDICATE”,”INDIVIDUAL”,”INDUSTRIAL”,”INDUSTRY”,”INFLUENCE”,”INFORM”,”INFORMATION”,”INITIAL”,”INITIATIVE”,”INJURY”,”INSIDE”,”INSIST”,”INSTANCE”,”INSTEAD”,”INSTITUTE”,”INSTITUTION”,”INSTRUCTION”,”INSTRUMENT”,”INSURANCE”,”INTEND”,”INTENTION”,”INTEREST”,”INTERESTED”,”INTERESTING”,”INTERNAL”,”INTERNATIONAL”,”INTERPRETATION”,”INTERVIEW”,”INTO”,”INTRODUCE”,”INTRODUCTION”,”INVESTIGATE”,”INVESTIGATION”,”INVESTMENT”,”INVITE”,”INVOLVE”,”IRON”,”IS”,”ISLAND”,”ISSUE”,”IT”,”ITEM”,”ITS”,”ITSELF”,”JOB”,”JOIN”,”JOINT”,”JOURNEY”,”JUDGE”,”JUMP”,”JUST”,”JUSTICE”,”KEEP”,”KEY”,”KID”,”KILL”,”KIND”,”KING”,”KITCHEN”,”KNEE”,”KNOW”,”KNOWLEDGE”,”LABOUR”,”LACK”,”LADY”,”LAND”,”LANGUAGE”,”LARGE”,”LARGELY”,”LAST”,”LATE”,”LATER”,”LATTER”,”LAUGH”,”LAUNCH”,”LAW”,”LAWYER”,”LAY”,”LEAD”,”LEADER”,”LEADERSHIP”,”LEADING”,”LEAF”,”LEAGUE”,”LEAN”,”LEARN”,”LEAST”,”LEAVE”,”LEFT”,”LEG”,”LEGAL”,”LEGISLATION”,”LENGTH”,”LESS”,”LET”,”LETTER”,”LEVEL”,”LIABILITY”,”LIBERAL”,”LIBRARY”,”LIE”,”LIFE”,”LIFT”,”LIGHT”,”LIKE”,”LIKELY”,”LIMIT”,”LIMITED”,”LINE”,”LINK”,”LIP”,”LIST”,”LISTEN”,”LITERATURE”,”LITTLE”,”LIVE”,”LIVING”,”LOAN”,”LOCAL”,”LOCATION”,”LONG”,”LOOK”,”LORD”,”LOSE”,”LOSS”,”LOT”,”LOVE”,”LOVELY”,”LOW”,”LUNCH”,”MACHINE”,”MAGAZINE”,”MAIN”,”MAINLY”,”MAINTAIN”,”MAJOR”,”MAJORITY”,”MAKE”,”MALE”,”MAN”,”MANAGE”,”MANAGEMENT”,”MANAGER”,”MANNER”,”MANY”,”MAP”,”MARK”,”MARKET”,”MARRIAGE”,”MARRIED”,”MARRY”,”MASS”,”MASTER”,”MATCH”,”MATERIAL”,”MATTER”,”MAY”,”MAYBE”,”ME”,”MEAL”,”MEAN”,”MEANING”,”MEANS”,”MEANWHILE”,”MEASURE”,”MECHANISM”,”MEDIA”,”MEDICAL”,”MEET”,”MEETING”,”MEMBER”,”MEMBERSHIP”,”MEMORY”,”MENTAL”,”MENTION”,”MERELY”,”MESSAGE”,”METAL”,”METHOD”,”MIDDLE”,”MIGHT”,”MILE”,”MILITARY”,”MILK”,”MIND”,”MINE”,”MINISTER”,”MINISTRY”,”MINUTE”,”MISS”,”MISTAKE”,”MODEL”,”MODERN”,”MODULE”,”MOMENT”,”MONEY”,”MONTH”,”MORE”,”MORNING”,”MOST”,”MOTHER”,”MOTION”,”MOTOR”,”MOUNTAIN”,”MOUTH”,”MOVE”,”MOVEMENT”,”MUCH”,”MURDER”,”MUSEUM”,”MUSIC”,”MUST”,”MY”,”MYSELF”,”NAME”,”NARROW”,”NATION”,”NATIONAL”,”NATURAL”,”NATURE”,”NEAR”,”NEARLY”,”NECESSARILY”,”NECESSARY”,”NECK”,”NEED”,”NEGOTIATION”,”NEIGHBOUR”,”NEITHER”,”NETWORK”,”NEVER”,”NEVERTHELESS”,”NEW”,”NEWS”,”NEWSPAPER”,”NEXT”,”NICE”,”NIGHT”,”NO”,”NOBODY”,”NOD”,”NOISE”,”NONE”,”NOR”,”NORMAL”,”NORMALLY”,”NORTH”,”NORTHERN”,”NOSE”,”NOT”,”NOTE”,”NOTHING”,”NOTICE”,”NOTION”,”NOW”,”NUCLEAR”,”NUMBER”,”NURSE”,”OBJECT”,”OBJECTIVE”,”OBSERVATION”,”OBSERVE”,”OBTAIN”,”OBVIOUS”,”OBVIOUSLY”,”OCCASION”,”OCCUR”,”ODD”,”OF”,”OFF”,”OFFENCE”,”OFFER”,”OFFICE”,”OFFICER”,”OFFICIAL”,”OFTEN”,”OIL”,”OKAY”,”OLD”,”ON”,”ONCE”,”ONE”,”ONLY”,”ONTO”,”OPEN”,”OPERATE”,”OPERATION”,”OPINION”,”OPPORTUNITY”,”OPPOSITION”,”OPTION”,”OR”,”ORDER”,”ORDINARY”,”ORGANISATION”,”ORGANISE”,”ORGANIZATION”,”ORIGIN”,”ORIGINAL”,”OTHER”,”OTHERWISE”,”OUGHT”,”OUR”,”OURSELVES”,”OUT”,”OUTCOME”,”OUTPUT”,”OUTSIDE”,”OVER”,”OVERALL”,”OWN”,”OWNER”,”PACKAGE”,”PAGE”,”PAIN”,”PAINT”,”PAINTING”,”PAIR”,”PANEL”,”PAPER”,”PARENT”,”PARK”,”PARLIAMENT”,”PART”,”PARTICULAR”,”PARTICULARLY”,”PARTLY”,”PARTNER”,”PARTY”,”PASS”,”PASSAGE”,”PAST”,”PATH”,”PATIENT”,”PATTERN”,”PAY”,”PAYMENT”,”PEACE”,”PENSION”,”PEOPLE”,”PER”,”PERCENT”,”PERFECT”,”PERFORM”,”PERFORMANCE”,”PERHAPS”,”PERIOD”,”PERMANENT”,”PERSON”,”PERSONAL”,”PERSUADE”,”PHASE”,”PHONE”,”PHOTOGRAPH”,”PHYSICAL”,”PICK”,”PICTURE”,”PIECE”,”PLACE”,”PLAN”,”PLANNING”,”PLANT”,”PLASTIC”,”PLATE”,”PLAY”,”PLAYER”,”PLEASE”,”PLEASURE”,”PLENTY”,”PLUS”,”POCKET”,”POINT”,”POLICE”,”POLICY”,”POLITICAL”,”POLITICS”,”POOL”,”POOR”,”POPULAR”,”POPULATION”,”POSITION”,”POSITIVE”,”POSSIBILITY”,”POSSIBLE”,”POSSIBLY”,”POST”,”POTENTIAL”,”POUND”,”POWER”,”POWERFUL”,”PRACTICAL”,”PRACTICE”,”PREFER”,”PREPARE”,”PRESENCE”,”PRESENT”,”PRESIDENT”,”PRESS”,”PRESSURE”,”PRETTY”,”PREVENT”,”PREVIOUS”,”PREVIOUSLY”,”PRICE”,”PRIMARY”,”PRIME”,”PRINCIPLE”,”PRIORITY”,”PRISON”,”PRISONER”,”PRIVATE”,”PROBABLY”,”PROBLEM”,”PROCEDURE”,”PROCESS”,”PRODUCE”,”PRODUCT”,”PRODUCTION”,”PROFESSIONAL”,”PROFIT”,”PROGRAM”,”PROGRAMME”,”PROGRESS”,”PROJECT”,”PROMISE”,”PROMOTE”,”PROPER”,”PROPERLY”,”PROPERTY”,”PROPORTION”,”PROPOSE”,”PROPOSAL”,”PROSPECT”,”PROTECT”,”PROTECTION”,”PROVE”,”PROVIDE”,”PROVIDED”,”PROVISION”,”PUB”,”PUBLIC”,”PUBLICATION”,”PUBLISH”,”PULL”,”PUPIL”,”PURPOSE”,”PUSH”,”PUT”,”QUALITY”,”QUARTER”,”QUESTION”,”QUICK”,”QUICKLY”,”QUIET”,”QUITE”,”RACE”,”RADIO”,”RAILWAY”,”RAIN”,”RAISE”,”RANGE”,”RAPIDLY”,”RARE”,”RATE”,”RATHER”,”REACH”,”REACTION”,”READ”,”READER”,”READING”,”READY”,”REAL”,”REALISE”,”REALITY”,”REALIZE”,”REALLY”,”REASON”,”REASONABLE”,”RECALL”,”RECEIVE”,”RECENT”,”RECENTLY”,”RECOGNISE”,”RECOGNITION”,”RECOGNIZE”,”RECOMMEND”,”RECORD”,”RECOVER”,”RED”,”REDUCE”,”REDUCTION”,”REFER”,”REFERENCE”,”REFLECT”,”REFORM”,”REFUSE”,”REGARD”,”REGION”,”REGIONAL”,”REGULAR”,”REGULATION”,”REJECT”,”RELATE”,”RELATION”,”RELATIONSHIP”,”RELATIVE”,”RELATIVELY”,”RELEASE”,”RELEVANT”,”RELIEF”,”RELIGION”,”RELIGIOUS”,”RELY”,”REMAIN”,”REMEMBER”,”REMIND”,”REMOVE”,”REPEAT”,”REPLACE”,”REPLY”,”REPORT”,”REPRESENT”,”REPRESENTATION”,”REPRESENTATIVE”,”REQUEST”,”REQUIRE”,”REQUIREMENT”,”RESEARCH”,”RESOURCE”,”RESPECT”,”RESPOND”,”RESPONSE”,”RESPONSIBILITY”,”RESPONSIBLE”,”REST”,”RESTAURANT”,”RESULT”,”RETAIN”,”RETURN”,”REVEAL”,”REVENUE”,”REVIEW”,”REVOLUTION”,”RICH”,”RIDE”,”RIGHT”,”RING”,”RISE”,”RISK”,”RIVER”,”ROAD”,”ROCK”,”ROLE”,”ROLL”,”ROOF”,”ROOM”,”ROUND”,”ROUTE”,”ROW”,”ROYAL”,”RULE”,”RUN”,”RURAL”,”SAFE”,”SAFETY”,”SALE”,”SAME”,”SAMPLE”,”SATISFY”,”SAVE”,”SAY”,”SCALE”,”SCENE”,”SCHEME”,”SCHOOL”,”SCIENCE”,”SCIENTIFIC”,”SCIENTIST”,”SCORE”,”SCREEN”,”SEA”,”SEARCH”,”SEASON”,”SEAT”,”SECOND”,”SECONDARY”,”SECRETARY”,”SECTION”,”SECTOR”,”SECURE”,”SECURITY”,”SEE”,”SEEK”,”SEEM”,”SELECT”,”SELECTION”,”SELL”,”SEND”,”SENIOR”,”SENSE”,”SENTENCE”,”SEPARATE”,”SEQUENCE”,”SERIES”,”SERIOUS”,”SERIOUSLY”,”SERVANT”,”SERVE”,”SERVICE”,”SESSION”,”SET”,”SETTLE”,”SETTLEMENT”,”SEVERAL”,”SEVERE”,”SEX”,”SEXUAL”,”SHAKE”,”SHALL”,”SHAPE”,”SHARE”,”SHE”,”SHEET”,”SHIP”,”SHOE”,”SHOOT”,”SHOP”,”SHORT”,”SHOT”,”SHOULD”,”SHOULDER”,”SHOUT”,”SHOW”,”SHUT”,”SIDE”,”SIGHT”,”SIGN”,”SIGNAL”,”SIGNIFICANCE”,”SIGNIFICANT”,”SILENCE”,”SIMILAR”,”SIMPLE”,”SIMPLY”,”SINCE”,”SING”,”SINGLE”,”SIR”,”SISTER”,”SIT”,”SITE”,”SITUATION”,”SIZE”,”SKILL”,”SKIN”,”SKY”,”SLEEP”,”SLIGHTLY”,”SLIP”,”SLOW”,”SLOWLY”,”SMALL”,”SMILE”,”SO”,”SOCIAL”,”SOCIETY”,”SOFT”,”SOFTWARE”,”SOIL”,”SOLDIER”,”SOLICITOR”,”SOLUTION”,”SOME”,”SOMEBODY”,”SOMEONE”,”SOMETHING”,”SOMETIMES”,”SOMEWHAT”,”SOMEWHERE”,”SON”,”SONG”,”SOON”,”SORRY”,”SORT”,”SOUND”,”SOURCE”,”SOUTH”,”SOUTHERN”,”SPACE”,”SPEAK”,”SPEAKER”,”SPECIAL”,”SPECIES”,”SPECIFIC”,”SPEECH”,”SPEED”,”SPEND”,”SPIRIT”,”SPORT”,”SPOT”,”SPREAD”,”SPRING”,”STAFF”,”STAGE”,”STAND”,”STANDARD”,”STAR”,”START”,”STATE”,”STATEMENT”,”STATION”,”STATUS”,”STAY”,”STEAL”,”STEP”,”STICK”,”STILL”,”STOCK”,”STONE”,”STOP”,”STORE”,”STORY”,”STRAIGHT”,”STRANGE”,”STRATEGY”,”STREET”,”STRENGTH”,”STRIKE”,”STRONG”,”STRONGLY”,”STRUCTURE”,”STUDENT”,”STUDIO”,”STUDY”,”STUFF”,”STYLE”,”SUBJECT”,”SUBSTANTIAL”,”SUCCEED”,”SUCCESS”,”SUCCESSFUL”,”SUCH”,”SUDDENLY”,”SUFFER”,”SUFFICIENT”,”SUGGEST”,”SUGGESTION”,”SUITABLE”,”SUM”,”SUMMER”,”SUN”,”SUPPLY”,”SUPPORT”,”SUPPOSE”,”SURE”,”SURELY”,”SURFACE”,”SURPRISE”,”SURROUND”,”SURVEY”,”SURVIVE”,”SWITCH”,”SYSTEM”,”TABLE”,”TAKE”,”TALK”,”TALL”,”TAPE”,”TARGET”,”TASK”,”TAX”,”TEA”,”TEACH”,”TEACHER”,”TEACHING”,”TEAM”,”TEAR”,”TECHNICAL”,”TECHNIQUE”,”TECHNOLOGY”,”TELEPHONE”,”TELEVISION”,”TELL”,”TEMPERATURE”,”TEND”,”TERM”,”TERMS”,”TERRIBLE”,”TEST”,”TEXT”,”THAN”,”THANK”,”THANKS”,”THAT”,”THE”,”THEATRE”,”THEIR”,”THEM”,”THEME”,”THEMSELVES”,”THEN”,”THEORY”,”THERE”,”THEREFORE”,”THESE”,”THEY”,”THIN”,”THING”,”THINK”,”THIS”,”THOSE”,”THOUGH”,”THOUGHT”,”THREAT”,”THREATEN”,”THROUGH”,”THROUGHOUT”,”THROW”,”THUS”,”TICKET”,”TIME”,”TINY”,”TITLE”,”TO”,”TODAY”,”TOGETHER”,”TOMORROW”,”TONE”,”TONIGHT”,”TOO”,”TOOL”,”TOOTH”,”TOP”,”TOTAL”,”TOTALLY”,”TOUCH”,”TOUR”,”TOWARDS”,”TOWN”,”TRACK”,”TRADE”,”TRADITION”,”TRADITIONAL”,”TRAFFIC”,”TRAIN”,”TRAINING”,”TRANSFER”,”TRANSPORT”,”TRAVEL”,”TREAT”,”TREATMENT”,”TREATY”,”TREE”,”TREND”,”TRIAL”,”TRIP”,”TROOP”,”TROUBLE”,”TRUE”,”TRUST”,”TRUTH”,”TRY”,”TURN”,”TWICE”,”TYPE”,”TYPICAL”,”UNABLE”,”UNDER”,”UNDERSTAND”,”UNDERSTANDING”,”UNDERTAKE”,”UNEMPLOYMENT”,”UNFORTUNATELY”,”UNION”,”UNIT”,”UNITED”,”UNIVERSITY”,”UNLESS”,”UNLIKELY”,”UNTIL”,”UP”,”UPON”,”UPPER”,”URBAN”,”US”,”USE”,”USED”,”USEFUL”,”USER”,”USUAL”,”USUALLY”,”VALUE”,”VARIATION”,”VARIETY”,”VARIOUS”,”VARY”,”VAST”,”VEHICLE”,”VERSION”,”VERY”,”VIA”,”VICTIM”,”VICTORY”,”VIDEO”,”VIEW”,”VILLAGE”,”VIOLENCE”,”VISION”,”VISIT”,”VISITOR”,”VITAL”,”VOICE”,”VOLUME”,”VOTE”,”WAGE”,”WAIT”,”WALK”,”WALL”,”WANT”,”WAR”,”WARM”,”WARN”,”WASH”,”WATCH”,”WATER”,”WAVE”,”WAY”,”WE”,”WEAK”,”WEAPON”,”WEAR”,”WEATHER”,”WEEK”,”WEEKEND”,”WEIGHT”,”WELCOME”,”WELFARE”,”WELL”,”WEST”,”WESTERN”,”WHAT”,”WHATEVER”,”WHEN”,”WHERE”,”WHEREAS”,”WHETHER”,”WHICH”,”WHILE”,”WHILST”,”WHITE”,”WHO”,”WHOLE”,”WHOM”,”WHOSE”,”WHY”,”WIDE”,”WIDELY”,”WIFE”,”WILD”,”WILL”,”WIN”,”WIND”,”WINDOW”,”WINE”,”WING”,”WINNER”,”WINTER”,”WISH”,”WITH”,”WITHDRAW”,”WITHIN”,”WITHOUT”,”WOMAN”,”WONDER”,”WONDERFUL”,”WOOD”,”WORD”,”WORK”,”WORKER”,”WORKING”,”WORKS”,”WORLD”,”WORRY”,”WORTH”,”WOULD”,”WRITE”,”WRITER”,”WRITING”,”WRONG”,”YARD”,”YEAH”,”YEAR”,”YES”,”YESTERDAY”,”YET”,”YOU”,”YOUNG”,”YOUR”,”YOURSELF”,”YOUTH”)



alpha_value={“A”:1,”B”:2,”C”:3,”D”:4,”E”:5,”F”:6,”G”:7,”H”:8,”I”:9,”J”:10,”K”:11,”L”:12,
“M”:13,”N”:14,”O”:15,”P”:16,”Q”:17,”R”:18,”S”:19,”T”:20,”U”:21,”V”:22,”W”:23,”X”:24,”Y”:25,”Z”:26}

The Code:


# Function to get the word value
def get_word_value (the_word):

tot=0

for each in the_word:

tot = tot + alpha_value [each]

return tot

def triangle_numbers (the_value):

count_n = 1

while count_n <= the_value :

if ((count_n / 2) * (count_n + 1)) == the_value :

return True

break

else:

count_n = count_n + 1

return False

# Here we call each function and get the total_count of Triangle words
total_count=0

for each in The_words:

check_word =(each)

word_value = get_name_value (check_word)

if triangle_numbers (word_value) :

print (each,word_value,’True’)

total_count = total_count +1

print(‘Total Triangle Words=’,total_count)








Follow me on Twitter..