開発環境
- OS X El Capitan - Apple (OS)
- Emacs (Text Editor)
- Python 3.5 (プログラミング言語)
Think Python (Allen B. Downey (著)、 O'Reilly Media)のChapter 9.(Case Study Word Play)のExercises 9-5(No. 1972)を取り組んでみる。
Exercises 9-5(No. 1972)
コード(Emacs)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def uses_all(word, letters):
for letter in letters:
if letter not in word:
return False
return True
def p(f, letters):
n = 1
for line in f:
words = line.split()
for word in words:
if uses_all(word, letters):
print('{0}: {1}'.format(n, word))
n += 1
if __name__ == '__main__':
with open('words.txt') as f:
for letters in ['aeiou', 'aeiouy']:
print('-' * 50)
print('letters: {0}'.format(letters))
p(f, letters)
f.seek(0)
入出力結果(Terminal, IPython)
$ ./sample5.py -------------------------------------------------- letters: aeiou 1: aboideau 2: aboideaus 3: aboideaux 4: aboiteau 5: aboiteaus 6: aboiteaux 7: abstemious 8: abstemiously 9: accentuation 10: accentuations 11: accountabilities 12: accountancies 13: accoutering 14: adulteration 15: adulterations 16: adventitious 17: adventitiously 18: adventitiousness 19: adventitiousnesses 20: aerobium 21: aeronautic 22: aeronautical 23: aeronautically 24: aeronautics 25: agouties 26: ambidextrous 27: ambidextrously 28: antibourgeois 29: anticonsumer 30: antievolution 31: antievolutionary 32: antihomosexual 33: antireligious 34: antirevolutionary 35: antisubversion 36: antituberculosis 37: antiunemployment 38: armouries 39: arsenious 40: assiduousness 41: assiduousnesses 42: atrociousness 43: atrociousnesses 44: attenuation 45: attenuations 46: auctioned 47: auctioneer 48: auctioneers 49: auditioned 50: auditories 51: augmentation 52: augmentations 53: aureoling 54: authentication 55: authentications 56: authoritative 57: authoritatively 58: authorities 59: authorize 60: authorized 61: authorizes 62: autobiographer 63: autobiographers 64: autobiographies 65: autocracies 66: autogamies 67: autogenies 68: automobile 69: automobiles 70: automotive 71: autonomies 72: autopsied 73: autopsies 74: autotomies 75: autotypies 76: avoidupoises 77: beautification 78: beautifications 79: belabouring 80: bivouacked 81: boundaries 82: buoyancies 83: businesswoman 84: calamitousness 85: calamitousnesses 86: carnivorousness 87: carnivorousnesses 88: cauliflower 89: cauliflowers 90: cauterization 91: cauterizations 92: cautioned 93: cautiousness 94: cautiousnesses 95: chemotherapeutic 96: chemotherapeutical 97: chivalrousness 98: chivalrousnesses 99: coeducation 100: coeducational 101: coeducations 102: coequating 103: communicable 104: communicate 105: communicated 106: communicates 107: communicative 108: conceptualize 109: conceptualized 110: conceptualizes 111: conceptualizing 112: consequential 113: constabularies 114: continuance 115: continuances 116: contumacies 117: copulative 118: copulatives 119: countenancing 120: counteraccusation 121: counteraccusations 122: counteracting 123: counteraggression 124: counteraggressions 125: counterarguing 126: counterattacking 127: counterbalancing 128: countercampaign 129: countercampaigns 130: counterclaim 131: counterclaims 132: countercomplaint 133: countercomplaints 134: counterdemonstration 135: counterdemonstrations 136: counterguerrila 137: counterinflationary 138: countermanding 139: counterpropagation 140: counterpropagations 141: counterraid 142: counterraids 143: counterrallies 144: counterretaliation 145: counterretaliations 146: counterstrategies 147: demagogueries 148: denunciation 149: denunciations 150: deputation 151: deputations 152: desquamation 153: desquamations 154: devaluation 155: devaluations 156: dialogue 157: dialogued 158: dialogues 159: disadvantageous 160: discontinuance 161: discontinuances 162: discourage 163: discouraged 164: discouragement 165: discouragements 166: discourages 167: documentaries 168: documentation 169: documentations 170: edacious 171: education 172: educational 173: educations 174: efficacious 175: ejaculation 176: ejaculations 177: elucidation 178: elucidations 179: emasculatation 180: emasculatations 181: emulation 182: emulations 183: emulsification 184: emulsifications 185: enamouring 186: encouraging 187: enumeration 188: enumerations 189: enunciation 190: enunciations 191: equation 192: equations 193: equatorial 194: equivocal 195: equivocate 196: equivocated 197: equivocates 198: equivocating 199: equivocation 200: equivocations 201: eulogia 202: eulogiae 203: eulogias 204: euphoria 205: euphorias 206: evacuation 207: evacuations 208: evaluation 209: evaluations 210: evolutionary 211: excommunicate 212: excommunicated 213: excommunicates 214: excommunicating 215: excommunication 216: excommunications 217: exhaustion 218: exhaustions 219: exhumation 220: exhumations 221: expurgation 222: expurgations 223: extenuation 224: extenuations 225: extracommunity 226: extraconstitutional 227: exudation 228: exudations 229: facetious 230: facetiously 231: fastiduousness 232: fastiduousnesses 233: filamentous 234: fluoridate 235: fluoridated 236: fluoridates 237: fountained 238: fumatories 239: functionaries 240: gelatinous 241: genitourinary 242: graciousness 243: graciousnesses 244: gregarious 245: gregariously 246: gregariousness 247: gregariousnesses 248: gubernatorial 249: hallucinogen 250: hallucinogenic 251: hallucinogens 252: harmoniousness 253: harmoniousnesses 254: hippopotamuses 255: housecleaning 256: housecleanings 257: housemaid 258: housemaids 259: housewarming 260: housewarmings 261: hyperanxious 262: hypercautious 263: hyperfastidious 264: ignoramuses 265: importunate 266: incommensurate 267: incommunicable 268: inconsequential 269: inconsequentially 270: inconsumable 271: inoculate 272: inoculated 273: inoculates 274: insecuration 275: insecurations 276: insouciance 277: insouciances 278: instantaneous 279: instantaneously 280: institutionalize 281: instrumentation 282: instrumentations 283: insubordinate 284: insupportable 285: insurmounable 286: intercommunal 287: interinstitutional 288: intermolecular 289: intermountain 290: interpopulation 291: intravenous 292: intravenously 293: jalousie 294: jalousies 295: jealousies 296: lasciviousness 297: lasciviousnesses 298: leukopenia 299: liquefaction 300: liquefactions 301: loquacities 302: magnanimousness 303: magnanimousnesses 304: malfunctioned 305: malnourished 306: mendacious 307: mendaciously 308: menstruation 309: menstruations 310: miaoued 311: microminiature 312: microminiatures 313: microminiaturized 314: miscellaneous 315: miscellaneously 316: miscellaneousness 317: miscellaneousnesses 318: modularities 319: modularized 320: mortuaries 321: mountaineer 322: mountaineered 323: mountaineering 324: mountaineers 325: multidenominational 326: multidimensional 327: multidirectional 328: multimillionaire 329: multimodalities 330: nefarious 331: nefariouses 332: nefariously 333: neurological 334: neurologically 335: neuropathies 336: neurotically 337: neutralization 338: neutralizations 339: nitrosurea 340: noncommunicable 341: noncumulative 342: noneducational 343: nonindustrialized 344: nonintellectual 345: obduracies 346: obituaries 347: occupancies 348: ossuaries 349: ostentatious 350: ostentatiously 351: outbeaming 352: outbleating 353: outcapering 354: outcaviled 355: outcavilled 356: outcheating 357: outdistance 358: outdistanced 359: outdistances 360: outdreaming 361: outeating 362: outfeasting 363: outgained 364: outhearing 365: outlawries 366: outleaping 367: outlearning 368: outpainted 369: outpatient 370: outpatients 371: outraise 372: outraised 373: outraises 374: outreaching 375: outreading 376: outrivaled 377: outrivalled 378: outsailed 379: outspeaking 380: outswearing 381: outwaited 382: outwearied 383: outwearies 384: outwearing 385: outwearying 386: overambitious 387: overanxious 388: overarousing 389: overcautious 390: overeducating 391: overenthusiastic 392: overexhausting 393: overfatigue 394: overfatigued 395: overfatigues 396: overfatiguing 397: overhauling 398: overparticular 399: overqualified 400: overregulating 401: overregulation 402: overregulations 403: oversaturating 404: overstimulate 405: overstimulated 406: overstimulates 407: overstimulating 408: overvaluing 409: pandemonium 410: pandemoniums 411: pasteurization 412: pasteurizations 413: peculatation 414: peculatations 415: perambulation 416: perambulations 417: perpetuation 418: perpetuations 419: perspicacious 420: persuasion 421: persuasions 422: pertinacious 423: perturbation 424: perturbations 425: plutocracies 426: pneumonia 427: popularities 428: popularize 429: popularized 430: popularizes 431: portraiture 432: portraitures 433: postrevolutionary 434: preauthorize 435: preauthorized 436: preauthorizes 437: preauthorizing 438: precarious 439: precariously 440: precariousness 441: precariousnesses 442: precaution 443: precautionary 444: precautions 445: preimmunization 446: preimmunizations 447: preinoculate 448: preinoculated 449: preinoculates 450: preinoculating 451: preinoculation 452: preoccupation 453: preoccupations 454: prepublication 455: prerevolutionary 456: pressurization 457: pressurizations 458: proteinuria 459: purgatories 460: putrefaction 461: putrefactions 462: questionable 463: questionnaire 464: questionnaires 465: questionniare 466: questionniares 467: radionuclide 468: radionuclides 469: rapaciousness 470: rapaciousnesses 471: rearousing 472: recapitulation 473: recapitulations 474: recirculation 475: recirculations 476: recuperation 477: recuperations 478: reevaluation 479: reevaluations 480: reformulating 481: refutation 482: refutations 483: regulation 484: regulations 485: regurgitation 486: regurgitations 487: reinoculate 488: reinoculated 489: reinoculates 490: reinoculating 491: rejuvenation 492: rejuvenations 493: remuneration 494: remunerations 495: renunciation 496: renunciations 497: repopulating 498: repudiation 499: repudiations 500: repudiator 501: repudiators 502: reputation 503: reputations 504: resuscitation 505: resuscitations 506: resuscitator 507: resuscitators 508: revolutionaries 509: revolutionary 510: sacrilegious 511: sacrilegiously 512: sautoire 513: sautoires 514: savourier 515: savouries 516: savouriest 517: scabiouses 518: sequoia 519: sequoias 520: simultaneous 521: simultaneously 522: simultaneousness 523: simultaneousnesses 524: somersaulting 525: spaciousness 526: spaciousnesses 527: speculation 528: speculations 529: stupefaction 530: stupefactions 531: subatmospheric 532: subcategories 533: subequatorial 534: suboceanic 535: subordinate 536: subordinated 537: subordinates 538: subpoenaing 539: sudatories 540: superambitious 541: superpatriot 542: superpatriotic 543: superpatriotism 544: superpatriotisms 545: superpatriots 546: tambourine 547: tambourines 548: tenacious 549: tenaciously 550: thiourea 551: thioureas 552: ulceration 553: ulcerations 554: ultraviolet 555: unaccompanied 556: unauthorized 557: unavoidable 558: uncomplimentary 559: unconscionable 560: unconventional 561: unconventionally 562: uncooperative 563: uncoordinated 564: undemocratic 565: undomesticated 566: unemotional 567: unequivocal 568: unequivocally 569: unforgivable 570: unidirectional 571: unintentional 572: unintentionally 573: unmotivated 574: unnojectionable 575: unnoticeable 576: unobtainable 577: unorganized 578: unpopularities 579: unprofessional 580: unprofitable 581: unquestionable 582: unquestionably 583: unreasoning 584: unsophisticated 585: veracious 586: vexatious 587: vicariousness 588: vicariousnesses 589: villianousness 590: villianousnesses 591: vituperation 592: vituperations 593: vivaciousness 594: vivaciousnesses 595: vocabularies 596: voraciousness 597: voraciousnesses 598: warehousing -------------------------------------------------- letters: aeiouy 1: abstemiously 2: adventitiously 3: aeronautically 4: ambidextrously 5: antievolutionary 6: antirevolutionary 7: antiunemployment 8: authoritatively 9: autotypies 10: buoyancies 11: counterinflationary 12: evolutionary 13: extracommunity 14: facetiously 15: genitourinary 16: gregariously 17: hyperanxious 18: hypercautious 19: hyperfastidious 20: inconsequentially 21: instantaneously 22: intravenously 23: mendaciously 24: miscellaneously 25: nefariously 26: neurologically 27: neurotically 28: ostentatiously 29: outwearying 30: postrevolutionary 31: precariously 32: precautionary 33: prerevolutionary 34: revolutionary 35: sacrilegiously 36: simultaneously 37: tenaciously 38: uncomplimentary 39: unconventionally 40: unequivocally 41: unintentionally 42: unquestionably $
0 コメント:
コメントを投稿