aboutsummaryrefslogtreecommitdiff
path: root/challenge-007
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2019-05-10 04:28:10 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2019-05-10 04:28:10 +0100
commit6ba028e36157363d14776eb3e35b71b044c3007b (patch)
treedba8e013a808db73b188a7ae23bc4a1d34175b0f /challenge-007
parentb6dfe831cbda4c869683fe3c5ca9ae33576c8c6f (diff)
downloadperlweeklychallenge-club-6ba028e36157363d14776eb3e35b71b044c3007b.tar.gz
perlweeklychallenge-club-6ba028e36157363d14776eb3e35b71b044c3007b.tar.bz2
perlweeklychallenge-club-6ba028e36157363d14776eb3e35b71b044c3007b.zip
- Added solutions by Maxim Nechaev.
Diffstat (limited to 'challenge-007')
-rwxr-xr-xchallenge-007/maxim-nechaev/perl5/ch-1.pl9
-rwxr-xr-xchallenge-007/maxim-nechaev/perl5/ch-2.pl31
-rwxr-xr-xchallenge-007/maxim-nechaev/perl5/words.txt11359
3 files changed, 11399 insertions, 0 deletions
diff --git a/challenge-007/maxim-nechaev/perl5/ch-1.pl b/challenge-007/maxim-nechaev/perl5/ch-1.pl
new file mode 100755
index 0000000000..9dd8f1d049
--- /dev/null
+++ b/challenge-007/maxim-nechaev/perl5/ch-1.pl
@@ -0,0 +1,9 @@
+#!/usr/bin/perl -w
+use strict;
+use List::Util qw/sum/;
+
+my @nivens = grep {
+ $_ and not $_ % sum split //;
+} 0..50;
+
+print join("\n", @nivens), "\n";
diff --git a/challenge-007/maxim-nechaev/perl5/ch-2.pl b/challenge-007/maxim-nechaev/perl5/ch-2.pl
new file mode 100755
index 0000000000..e230d75317
--- /dev/null
+++ b/challenge-007/maxim-nechaev/perl5/ch-2.pl
@@ -0,0 +1,31 @@
+#!/usr/bin/perl -w
+use strict;
+use Graph::Undirected;
+use Algorithm::Combinatorics qw/combinations/;
+
+sub find_shortest_ladder
+{
+ my ($word1, $word2, $words) = @_;
+
+ my $g = Graph::Undirected->new;
+ map { $g->add_vertex($_) } @$words;
+
+ my $len = length($words->[0]) - 1;
+ my $iter = combinations($words, 2);
+ while( my $pair = $iter->next ) {
+ my $diffs = 0;
+ foreach my $i (0..$len) {
+ $diffs++ if substr($pair->[0], $i, 1) ne substr($pair->[1], $i, 1);
+ last if $diffs == 2;
+ }
+ $g->add_edge( @$pair ) if $diffs == 1;
+ }
+ return $g->SP_Dijkstra($word1, $word2);
+}
+
+
+$ARGV[0] || die "use: $0 filename_dict";
+my @words = <>;
+@words = map { chomp; $_ } @words;
+my @ladder = find_shortest_ladder('water', 'bread', \@words);
+print join("\n", @ladder), "\n";
diff --git a/challenge-007/maxim-nechaev/perl5/words.txt b/challenge-007/maxim-nechaev/perl5/words.txt
new file mode 100755
index 0000000000..6a3aac463e
--- /dev/null
+++ b/challenge-007/maxim-nechaev/perl5/words.txt
@@ -0,0 +1,11359 @@
+aahed
+aalii
+aargh
+abaca
+abaci
+aback
+abacs
+abaft
+abaka
+aband
+abase
+abash
+abask
+abate
+abaya
+abbas
+abbey
+abbot
+abbés
+abeam
+abear
+abele
+abets
+abhor
+abide
+abies
+abled
+abler
+ables
+ablet
+ablow
+abmho
+abode
+abohm
+aboil
+aboma
+aboon
+abord
+abore
+abort
+about
+above
+abram
+abray
+abrim
+abrin
+abris
+absey
+absit
+abuna
+abune
+abuse
+abuts
+abuzz
+abyes
+abysm
+abyss
+acari
+accoy
+accra
+acerb
+acers
+aceta
+ached
+aches
+achoo
+acids
+acidy
+acing
+acini
+ackee
+acmes
+acmic
+acned
+acnes
+acock
+acold
+acorn
+acred
+acres
+acrid
+acron
+acted
+actin
+acton
+actor
+acute
+acyls
+adage
+adapt
+adays
+addax
+added
+adder
+addio
+addle
+adeem
+adept
+adieu
+adits
+adiós
+adman
+admen
+admit
+admix
+adobe
+adobo
+adopt
+adore
+adorn
+adown
+adoze
+adrad
+adred
+adsum
+adult
+adunc
+adust
+advew
+adyta
+adzed
+adzes
+aecia
+aedes
+aegis
+aeons
+aerie
+aesir
+afara
+afars
+afear
+affix
+afire
+aflaj
+afoot
+afore
+afoul
+afrit
+afros
+after
+again
+agama
+agami
+agamy
+agape
+agars
+agast
+agate
+agave
+agaze
+agene
+agent
+agers
+agger
+aggie
+aggri
+aggro
+aggry
+aghas
+agila
+agile
+aging
+agios
+agism
+agist
+agita
+aglee
+aglet
+agley
+agloo
+aglow
+aglus
+agmas
+agoge
+agone
+agons
+agony
+agood
+agora
+agree
+agria
+agrin
+agued
+agues
+aguti
+ahead
+aheap
+ahems
+ahhed
+ahigh
+ahind
+ahing
+ahint
+ahold
+ahoys
+ahull
+aided
+aider
+aides
+aidos
+ailed
+aimed
+aimer
+ainas
+aired
+airer
+airns
+airth
+airts
+aisle
+aitch
+aitus
+aiver
+aizle
+ajiva
+ajuga
+ajwan
+akees
+akela
+akene
+aking
+akkas
+alaap
+alack
+alamo
+aland
+alane
+alang
+alans
+alant
+alapa
+alarm
+alary
+alate
+alays
+albas
+albee
+album
+alcid
+aldea
+alder
+aldol
+alecs
+alefs
+aleft
+aleph
+alert
+alfas
+algae
+algal
+algas
+algid
+algin
+algor
+algum
+alias
+alibi
+alien
+alifs
+align
+alike
+aline
+alist
+alive
+aliya
+alkie
+alkyd
+alkyl
+allay
+allel
+alley
+allis
+allod
+allot
+allow
+alloy
+allyl
+allée
+almah
+almas
+almeh
+almes
+almud
+almug
+alods
+aloed
+aloes
+aloft
+aloha
+aloin
+alone
+along
+aloof
+aloud
+alowe
+alpha
+altar
+alter
+altho
+altos
+alula
+alums
+alure
+alway
+amahs
+amain
+amass
+amate
+amaze
+amban
+amber
+ambit
+amble
+ambos
+ambry
+ameba
+ameer
+amend
+amene
+amens
+ament
+amias
+amice
+amici
+amide
+amido
+amids
+amies
+amiga
+amigo
+amine
+amino
+amins
+amirs
+amiss
+amity
+amlas
+amman
+ammon
+ammos
+amnia
+amnic
+amnio
+amoks
+amole
+among
+amort
+amour
+amove
+amped
+ample
+amply
+ampul
+amrit
+amuck
+amuse
+amyls
+anana
+anans
+ancho
+ancle
+ancon
+anear
+anele
+anend
+anent
+angas
+angel
+anger
+angle
+anglo
+angry
+angst
+anigh
+anile
+anils
+anima
+anime
+animi
+anion
+anise
+anker
+ankhs
+ankle
+ankus
+anlas
+annal
+annas
+annat
+annex
+annoy
+annul
+anoas
+anode
+anole
+anomy
+anons
+ansae
+antae
+antar
+antas
+anted
+antes
+antic
+antis
+antra
+antre
+antsy
+anvil
+anyon
+anyus
+aorta
+apace
+apage
+apaid
+apart
+apayd
+apays
+apeak
+apeek
+apers
+apert
+apery
+aphid
+aphis
+apian
+aping
+apiol
+apios
+apish
+apism
+apnea
+apode
+apods
+apoop
+aport
+appal
+appay
+appel
+apple
+apply
+appro
+appui
+appuy
+apron
+après
+apses
+apsis
+apter
+aptly
+aquae
+aquas
+araba
+araks
+arame
+arars
+arbas
+arbor
+arced
+arcus
+ardeb
+ardor
+ardri
+aread
+areae
+areal
+arear
+areas
+areca
+aredd
+arede
+arefy
+arena
+arepa
+arere
+arets
+arett
+argal
+argan
+argil
+argle
+argol
+argon
+argot
+argue
+argus
+arhat
+arias
+ariel
+arils
+ariot
+arise
+arish
+arled
+arles
+armed
+armer
+armet
+armil
+armor
+arnut
+aroba
+aroid
+aroma
+arose
+arpen
+arrah
+arras
+array
+arris
+arrow
+arrêt
+arsed
+arsis
+arson
+artal
+artel
+artic
+artsy
+arums
+arval
+arvos
+aryls
+arête
+asana
+ascot
+ascus
+asdic
+ashed
+ashen
+ashes
+ashet
+aside
+askar
+asked
+asker
+askew
+askoi
+askos
+aspen
+asper
+aspic
+aspis
+assai
+assay
+assed
+asses
+asset
+assot
+aster
+astir
+asura
+asway
+aswim
+asyla
+ataps
+atars
+ataxy
+atilt
+atimy
+atlas
+atman
+atmas
+atocs
+atoke
+atoks
+atoll
+atoms
+atomy
+atone
+atony
+atopy
+atria
+atrip
+attap
+attar
+attic
+audad
+audio
+audit
+auger
+aught
+augur
+aulas
+aulic
+auloi
+aulos
+aumil
+aunes
+aunts
+aunty
+aurae
+aural
+aurar
+auras
+aurei
+aures
+auric
+auris
+aurum
+autos
+auxin
+avail
+avale
+avant
+avast
+avens
+avers
+avert
+avgas
+avian
+avine
+avion
+aviso
+avize
+avoid
+avows
+await
+awake
+award
+aware
+awarn
+awash
+awave
+aways
+awdls
+aweek
+aweel
+aweto
+awful
+awing
+awned
+awner
+awoke
+awols
+awork
+axels
+axial
+axile
+axils
+axing
+axiom
+axion
+axite
+axled
+axles
+axman
+axmen
+axoid
+axone
+axons
+ayahs
+ayelp
+ayins
+ayont
+ayres
+ayrie
+azans
+azide
+azido
+azine
+azlon
+azoic
+azole
+azons
+azote
+azoth
+azure
+azury
+azygy
+azyme
+azyms
+aînée
+aïoli
+baaed
+baals
+babas
+babel
+babes
+babka
+babul
+bacca
+bacco
+baccy
+bachs
+backs
+bacon
+baddy
+badge
+badly
+baffs
+baffy
+bagel
+baggy
+bahts
+bahut
+bails
+bairn
+baith
+baits
+baiza
+baize
+bajan
+bajee
+bajra
+bajri
+bajus
+baked
+baken
+baker
+bakes
+bakra
+balas
+balds
+baldy
+baled
+baler
+bales
+balks
+balky
+balls
+bally
+balms
+balmy
+baloo
+balsa
+balti
+balus
+banal
+banco
+bancs
+banda
+bands
+bandy
+baned
+banes
+bangs
+bania
+banjo
+banks
+banns
+bants
+banty
+bapus
+barbe
+barbs
+barca
+barde
+bardo
+bards
+bardy
+bared
+barer
+bares
+barfs
+barfy
+barge
+baric
+barks
+barky
+barms
+barmy
+barns
+barny
+baron
+barra
+barre
+barye
+basal
+basan
+based
+baser
+bases
+basho
+basic
+basil
+basin
+basis
+basks
+bason
+basse
+bassi
+basso
+bassy
+basta
+baste
+basto
+basts
+batch
+bated
+bates
+bathe
+baths
+batik
+baton
+batta
+batts
+battu
+batty
+bauds
+baurs
+bavin
+bawds
+bawdy
+bawls
+bawns
+bawrs
+bawty
+bayed
+bayle
+bayou
+bazar
+bazoo
+beach
+beads
+beady
+beaks
+beaky
+beams
+beamy
+beano
+beans
+beany
+beard
+bears
+beast
+beath
+beats
+beaus
+beaut
+beaux
+bebop
+becap
+becks
+bedad
+bedel
+bedew
+bedim
+bedye
+beech
+beedi
+beefs
+beefy
+beeps
+beers
+beery
+beets
+befit
+befog
+begad
+began
+begar
+begat
+begem
+beget
+begin
+begot
+begum
+begun
+beige
+beigy
+being
+bejel
+bekah
+belah
+belay
+belch
+belee
+belga
+belie
+belle
+bells
+belly
+below
+belts
+bemas
+bemix
+bench
+bends
+bendy
+benes
+benet
+benis
+benne
+benni
+benny
+bensh
+bento
+bents
+benty
+beray
+beres
+beret
+bergs
+berks
+berme
+berms
+berob
+berry
+berth
+beryl
+besat
+besee
+beses
+beset
+besit
+besom
+besot
+bests
+betas
+betel
+betes
+beths
+betid
+betta
+betty
+bevel
+bever
+bevor
+bevue
+bevvy
+bewet
+bewig
+bezel
+bezes
+bezil
+bhaji
+bhang
+bhels
+bhoot
+bhuts
+biali
+bialy
+bibbs
+bible
+biccy
+bicep
+bices
+biddy
+bided
+bider
+bides
+bidet
+bidis
+bidon
+bield
+biers
+biffs
+biffy
+bifid
+bigae
+biggs
+biggy
+bigha
+bight
+bigly
+bigos
+bigot
+bijou
+biked
+biker
+bikes
+bikie
+bilbo
+bilby
+biles
+bilge
+bilgy
+bilks
+bills
+billy
+bimah
+bimas
+bimbo
+binal
+bindi
+binds
+bines
+binge
+bingo
+bings
+bingy
+binit
+binks
+bints
+biogs
+biome
+biont
+biota
+biped
+bipod
+birch
+birds
+birks
+birle
+birls
+biros
+birrs
+birse
+birsy
+birth
+bises
+bisks
+bison
+bitch
+biter
+bites
+bitok
+bitos
+bitsy
+bitte
+bitts
+bitty
+bivvy
+bizes
+blabs
+black
+blade
+blads
+blaes
+blaff
+blags
+blahs
+blain
+blame
+blams
+bland
+blank
+blare
+blash
+blast
+blasé
+blate
+blats
+blatt
+blawn
+blaws
+blays
+blaze
+bleak
+blear
+bleat
+blebs
+bleed
+bleep
+blees
+blend
+blent
+bless
+blest
+blets
+bleys
+blimp
+blimy
+blind
+blini
+blink
+blins
+blips
+bliss
+blite
+blitz
+bloat
+blobs
+block
+blocs
+blogs
+bloke
+blond
+blood
+bloom
+bloop
+blore
+blots
+blown
+blows
+blowy
+blubs
+blude
+blued
+bluer
+blues
+bluet
+bluey
+bluff
+blume
+blunt
+blurb
+blurs
+blurt
+blush
+blype
+boaks
+board
+boars
+boart
+boast
+boats
+bobac
+bobak
+bobby
+bocca
+bocce
+bocci
+boche
+bocks
+boded
+bodes
+bodge
+bodle
+boffo
+boffs
+bogan
+bogey
+boggy
+bogie
+bogle
+bogue
+bogus
+bohea
+bohos
+boils
+boing
+boink
+boite
+boked
+bokes
+bokos
+bolar
+bolas
+bolds
+boles
+bolix
+bolls
+bolos
+bolts
+bolus
+bomas
+bombe
+bombo
+bombs
+bonce
+bonds
+boned
+boner
+bones
+boney
+bongo
+bongs
+bonks
+bonne
+bonny
+bonus
+bonza
+bonze
+boobs
+booby
+boody
+booed
+boogy
+boohs
+books
+booky
+booms
+boomy
+boong
+boons
+boors
+boost
+booth
+boots
+booty
+booze
+boozy
+borak
+boral
+boras
+borax
+borde
+bored
+boree
+borel
+borer
+bores
+borgo
+boric
+borks
+borne
+boron
+borts
+borty
+bortz
+bosks
+bosky
+bosom
+boson
+bossy
+bosun
+botas
+botch
+botel
+bothy
+botos
+botte
+botts
+botty
+bouge
+bough
+bouks
+boule
+boult
+bound
+bourn
+bouse
+bousy
+bouts
+bovid
+bowed
+bowel
+bower
+bowet
+bowls
+bowse
+boxed
+boxen
+boxer
+boxes
+boyar
+boyau
+boygs
+boyla
+boyos
+bozos
+brace
+brach
+brack
+bract
+brads
+braes
+brags
+braid
+brail
+brain
+brake
+braky
+brame
+brand
+brank
+brans
+brant
+brash
+brass
+brats
+brava
+brave
+bravi
+bravo
+brawl
+brawn
+braws
+braxy
+brays
+braza
+braze
+bread
+break
+bream
+brede
+breed
+brees
+breis
+brens
+brent
+brere
+breve
+brews
+briar
+bribe
+brick
+bride
+brief
+brier
+bries
+brigs
+brill
+brims
+brine
+bring
+brink
+brins
+briny
+brios
+brisk
+brisé
+brith
+brits
+britt
+broad
+broch
+brock
+brogh
+brogs
+broil
+broke
+brome
+bromo
+bronc
+brood
+brook
+brool
+broom
+broos
+brose
+brosy
+broth
+brown
+brows
+brugh
+bruin
+bruit
+brume
+brung
+brunt
+brush
+brusk
+brust
+brute
+brûlé
+buats
+buaya
+buaze
+bubal
+bubba
+bubby
+bubus
+buchu
+bucko
+bucks
+bucku
+buddy
+budge
+budos
+bueno
+buffa
+buffe
+buffi
+buffo
+buffs
+buffy
+buggy
+bugle
+buhls
+buhrs
+build
+built
+bulbs
+bulge
+bulgy
+bulks
+bulky
+bulla
+bulls
+bully
+bulse
+bumbo
+bumfs
+bumph
+bumps
+bumpy
+bunas
+bunce
+bunch
+bunco
+bunds
+bundt
+bundu
+bundy
+bungs
+bungy
+bunia
+bunje
+bunjy
+bunko
+bunks
+bunns
+bunny
+bunts
+bunty
+bunya
+buoys
+buppy
+buran
+buras
+burbs
+burds
+buret
+burgh
+burgs
+burin
+burka
+burke
+burls
+burly
+burns
+burnt
+buroo
+burps
+burqa
+burro
+burrs
+burry
+bursa
+burse
+burst
+busby
+bused
+buses
+bushy
+busks
+busky
+bussu
+busts
+busty
+butch
+buteo
+butes
+butle
+butoh
+butos
+butsu
+butte
+butts
+butty
+butut
+butyl
+buxom
+buyer
+buzzy
+bwana
+bwazi
+byked
+bykes
+bylaw
+byres
+byrls
+byssi
+bytes
+byway
+béton
+cabal
+cabas
+cabby
+caber
+cabin
+cable
+cabob
+caboc
+cabré
+cacao
+cacas
+cache
+cacti
+caddy
+cadee
+cades
+cadet
+cadge
+cadgy
+cadie
+cadis
+cadre
+caeca
+caese
+caffs
+cafés
+caged
+cager
+cages
+cagey
+cagot
+cahow
+caids
+cains
+caird
+cairn
+cajon
+cajun
+caked
+cakes
+cakey
+cakra
+calfs
+calid
+calif
+calix
+calks
+calla
+calls
+calms
+calmy
+calos
+calpa
+calve
+calyx
+caman
+camas
+camel
+cameo
+cames
+camis
+camos
+campi
+campo
+camps
+campy
+camus
+canal
+candy
+caned
+caneh
+caner
+canes
+cangs
+canid
+canna
+canns
+canny
+canoe
+canon
+canso
+canst
+canto
+cants
+canty
+capas
+caped
+caper
+capes
+caphs
+capiz
+caple
+capon
+capos
+capot
+capul
+caput
+carap
+carat
+carbo
+carbs
+carby
+cardi
+cards
+cardy
+cared
+carer
+cares
+caret
+carex
+cargo
+carks
+carle
+carls
+carns
+carny
+carob
+carol
+carom
+carpi
+carps
+carrs
+carry
+carse
+carta
+carte
+carts
+carve
+carvy
+casas
+casco
+cased
+cases
+casks
+casky
+caste
+casts
+casus
+catch
+cater
+cates
+catty
+cauda
+cauld
+caulk
+cauls
+causa
+cause
+caved
+cavel
+caver
+caves
+cavie
+cavil
+cawed
+caxon
+cease
+cebid
+cecal
+cecum
+cedar
+ceded
+ceder
+cedes
+cedis
+cegep
+ceiba
+ceili
+ceils
+celeb
+cella
+celli
+cello
+cells
+celom
+celts
+cense
+cento
+cents
+centu
+ceorl
+cepes
+cerci
+cered
+ceres
+cerge
+ceria
+ceric
+ceros
+certs
+cesar
+cesse
+cesta
+cesti
+cetes
+cetyl
+chace
+chaco
+chads
+chafe
+chaff
+chaft
+chain
+chair
+chais
+chalk
+chals
+champ
+chams
+chang
+chank
+chant
+chaos
+chape
+chaps
+chapt
+chara
+chard
+chare
+chark
+charm
+charr
+chars
+chart
+chary
+chase
+chasm
+chats
+chaws
+chaya
+chays
+cheap
+cheat
+check
+cheek
+cheep
+cheer
+chefs
+cheka
+chela
+chemo
+chert
+chess
+chest
+cheth
+chevy
+chews
+chewy
+chiao
+chias
+chica
+chich
+chick
+chico
+chics
+chide
+chief
+chiel
+chiks
+child
+chile
+chili
+chill
+chimb
+chime
+chimo
+chimp
+china
+chine
+chink
+chino
+chins
+chips
+chirk
+chirm
+chiro
+chirp
+chirr
+chirt
+chits
+chive
+chivs
+chivy
+chizz
+chock
+choco
+chocs
+choir
+choke
+choko
+choky
+chola
+choli
+cholo
+chomp
+choof
+chook
+choom
+chops
+chord
+chore
+chose
+chota
+chott
+chout
+choux
+chows
+chubs
+chuck
+chufa
+chuff
+chugs
+chump
+chums
+chunk
+churl
+churn
+churr
+chuse
+chute
+chuts
+chyle
+chyme
+ciaos
+cibol
+cider
+cigar
+cilia
+cills
+cimar
+cimex
+cinch
+cinct
+cines
+cions
+cippi
+circa
+circs
+cirls
+cirri
+cirés
+cisco
+cists
+cital
+cited
+citer
+cites
+cives
+civet
+civic
+civie
+civil
+civvy
+clach
+clack
+clade
+clads
+claes
+clags
+claim
+clame
+clamp
+clams
+clang
+clank
+clans
+claps
+clapt
+claro
+clart
+clary
+clash
+clasp
+class
+clast
+clave
+clavi
+claws
+clays
+clean
+clear
+cleat
+cleck
+cleek
+clefs
+cleft
+clegs
+clems
+clepe
+clept
+clerk
+cleve
+clews
+click
+clied
+clies
+cliff
+clift
+climb
+clime
+cline
+cling
+clink
+clint
+clips
+clipt
+clits
+cloak
+cloam
+clock
+clods
+cloff
+clogs
+cloke<