repo_name
stringclasses
1 value
pr_number
int64
4.12k
11.2k
pr_title
stringlengths
9
107
pr_description
stringlengths
107
5.48k
author
stringlengths
4
18
date_created
unknown
date_merged
unknown
previous_commit
stringlengths
40
40
pr_commit
stringlengths
40
40
query
stringlengths
118
5.52k
before_content
stringlengths
0
7.93M
after_content
stringlengths
0
7.93M
label
int64
-1
1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH","JENNIFER","MARIA","SUSAN","MARGARET","DOROTHY","LISA","NANCY","KAREN","BETTY","HELEN","SANDRA","DONNA","CAROL","RUTH","SHARON","MICHELLE","LAURA","SARAH","KIMBERLY","DEBORAH","JESSICA","SHIRLEY","CYNTHIA","ANGELA","MELISSA","BRENDA","AMY","ANNA","REBECCA","VIRGINIA","KATHLEEN","PAMELA","MARTHA","DEBRA","AMANDA","STEPHANIE","CAROLYN","CHRISTINE","MARIE","JANET","CATHERINE","FRANCES","ANN","JOYCE","DIANE","ALICE","JULIE","HEATHER","TERESA","DORIS","GLORIA","EVELYN","JEAN","CHERYL","MILDRED","KATHERINE","JOAN","ASHLEY","JUDITH","ROSE","JANICE","KELLY","NICOLE","JUDY","CHRISTINA","KATHY","THERESA","BEVERLY","DENISE","TAMMY","IRENE","JANE","LORI","RACHEL","MARILYN","ANDREA","KATHRYN","LOUISE","SARA","ANNE","JACQUELINE","WANDA","BONNIE","JULIA","RUBY","LOIS","TINA","PHYLLIS","NORMA","PAULA","DIANA","ANNIE","LILLIAN","EMILY","ROBIN","PEGGY","CRYSTAL","GLADYS","RITA","DAWN","CONNIE","FLORENCE","TRACY","EDNA","TIFFANY","CARMEN","ROSA","CINDY","GRACE","WENDY","VICTORIA","EDITH","KIM","SHERRY","SYLVIA","JOSEPHINE","THELMA","SHANNON","SHEILA","ETHEL","ELLEN","ELAINE","MARJORIE","CARRIE","CHARLOTTE","MONICA","ESTHER","PAULINE","EMMA","JUANITA","ANITA","RHONDA","HAZEL","AMBER","EVA","DEBBIE","APRIL","LESLIE","CLARA","LUCILLE","JAMIE","JOANNE","ELEANOR","VALERIE","DANIELLE","MEGAN","ALICIA","SUZANNE","MICHELE","GAIL","BERTHA","DARLENE","VERONICA","JILL","ERIN","GERALDINE","LAUREN","CATHY","JOANN","LORRAINE","LYNN","SALLY","REGINA","ERICA","BEATRICE","DOLORES","BERNICE","AUDREY","YVONNE","ANNETTE","JUNE","SAMANTHA","MARION","DANA","STACY","ANA","RENEE","IDA","VIVIAN","ROBERTA","HOLLY","BRITTANY","MELANIE","LORETTA","YOLANDA","JEANETTE","LAURIE","KATIE","KRISTEN","VANESSA","ALMA","SUE","ELSIE","BETH","JEANNE","VICKI","CARLA","TARA","ROSEMARY","EILEEN","TERRI","GERTRUDE","LUCY","TONYA","ELLA","STACEY","WILMA","GINA","KRISTIN","JESSIE","NATALIE","AGNES","VERA","WILLIE","CHARLENE","BESSIE","DELORES","MELINDA","PEARL","ARLENE","MAUREEN","COLLEEN","ALLISON","TAMARA","JOY","GEORGIA","CONSTANCE","LILLIE","CLAUDIA","JACKIE","MARCIA","TANYA","NELLIE","MINNIE","MARLENE","HEIDI","GLENDA","LYDIA","VIOLA","COURTNEY","MARIAN","STELLA","CAROLINE","DORA","JO","VICKIE","MATTIE","TERRY","MAXINE","IRMA","MABEL","MARSHA","MYRTLE","LENA","CHRISTY","DEANNA","PATSY","HILDA","GWENDOLYN","JENNIE","NORA","MARGIE","NINA","CASSANDRA","LEAH","PENNY","KAY","PRISCILLA","NAOMI","CAROLE","BRANDY","OLGA","BILLIE","DIANNE","TRACEY","LEONA","JENNY","FELICIA","SONIA","MIRIAM","VELMA","BECKY","BOBBIE","VIOLET","KRISTINA","TONI","MISTY","MAE","SHELLY","DAISY","RAMONA","SHERRI","ERIKA","KATRINA","CLAIRE","LINDSEY","LINDSAY","GENEVA","GUADALUPE","BELINDA","MARGARITA","SHERYL","CORA","FAYE","ADA","NATASHA","SABRINA","ISABEL","MARGUERITE","HATTIE","HARRIET","MOLLY","CECILIA","KRISTI","BRANDI","BLANCHE","SANDY","ROSIE","JOANNA","IRIS","EUNICE","ANGIE","INEZ","LYNDA","MADELINE","AMELIA","ALBERTA","GENEVIEVE","MONIQUE","JODI","JANIE","MAGGIE","KAYLA","SONYA","JAN","LEE","KRISTINE","CANDACE","FANNIE","MARYANN","OPAL","ALISON","YVETTE","MELODY","LUZ","SUSIE","OLIVIA","FLORA","SHELLEY","KRISTY","MAMIE","LULA","LOLA","VERNA","BEULAH","ANTOINETTE","CANDICE","JUANA","JEANNETTE","PAM","KELLI","HANNAH","WHITNEY","BRIDGET","KARLA","CELIA","LATOYA","PATTY","SHELIA","GAYLE","DELLA","VICKY","LYNNE","SHERI","MARIANNE","KARA","JACQUELYN","ERMA","BLANCA","MYRA","LETICIA","PAT","KRISTA","ROXANNE","ANGELICA","JOHNNIE","ROBYN","FRANCIS","ADRIENNE","ROSALIE","ALEXANDRA","BROOKE","BETHANY","SADIE","BERNADETTE","TRACI","JODY","KENDRA","JASMINE","NICHOLE","RACHAEL","CHELSEA","MABLE","ERNESTINE","MURIEL","MARCELLA","ELENA","KRYSTAL","ANGELINA","NADINE","KARI","ESTELLE","DIANNA","PAULETTE","LORA","MONA","DOREEN","ROSEMARIE","ANGEL","DESIREE","ANTONIA","HOPE","GINGER","JANIS","BETSY","CHRISTIE","FREDA","MERCEDES","MEREDITH","LYNETTE","TERI","CRISTINA","EULA","LEIGH","MEGHAN","SOPHIA","ELOISE","ROCHELLE","GRETCHEN","CECELIA","RAQUEL","HENRIETTA","ALYSSA","JANA","KELLEY","GWEN","KERRY","JENNA","TRICIA","LAVERNE","OLIVE","ALEXIS","TASHA","SILVIA","ELVIRA","CASEY","DELIA","SOPHIE","KATE","PATTI","LORENA","KELLIE","SONJA","LILA","LANA","DARLA","MAY","MINDY","ESSIE","MANDY","LORENE","ELSA","JOSEFINA","JEANNIE","MIRANDA","DIXIE","LUCIA","MARTA","FAITH","LELA","JOHANNA","SHARI","CAMILLE","TAMI","SHAWNA","ELISA","EBONY","MELBA","ORA","NETTIE","TABITHA","OLLIE","JAIME","WINIFRED","KRISTIE","MARINA","ALISHA","AIMEE","RENA","MYRNA","MARLA","TAMMIE","LATASHA","BONITA","PATRICE","RONDA","SHERRIE","ADDIE","FRANCINE","DELORIS","STACIE","ADRIANA","CHERI","SHELBY","ABIGAIL","CELESTE","JEWEL","CARA","ADELE","REBEKAH","LUCINDA","DORTHY","CHRIS","EFFIE","TRINA","REBA","SHAWN","SALLIE","AURORA","LENORA","ETTA","LOTTIE","KERRI","TRISHA","NIKKI","ESTELLA","FRANCISCA","JOSIE","TRACIE","MARISSA","KARIN","BRITTNEY","JANELLE","LOURDES","LAUREL","HELENE","FERN","ELVA","CORINNE","KELSEY","INA","BETTIE","ELISABETH","AIDA","CAITLIN","INGRID","IVA","EUGENIA","CHRISTA","GOLDIE","CASSIE","MAUDE","JENIFER","THERESE","FRANKIE","DENA","LORNA","JANETTE","LATONYA","CANDY","MORGAN","CONSUELO","TAMIKA","ROSETTA","DEBORA","CHERIE","POLLY","DINA","JEWELL","FAY","JILLIAN","DOROTHEA","NELL","TRUDY","ESPERANZA","PATRICA","KIMBERLEY","SHANNA","HELENA","CAROLINA","CLEO","STEFANIE","ROSARIO","OLA","JANINE","MOLLIE","LUPE","ALISA","LOU","MARIBEL","SUSANNE","BETTE","SUSANA","ELISE","CECILE","ISABELLE","LESLEY","JOCELYN","PAIGE","JONI","RACHELLE","LEOLA","DAPHNE","ALTA","ESTER","PETRA","GRACIELA","IMOGENE","JOLENE","KEISHA","LACEY","GLENNA","GABRIELA","KERI","URSULA","LIZZIE","KIRSTEN","SHANA","ADELINE","MAYRA","JAYNE","JACLYN","GRACIE","SONDRA","CARMELA","MARISA","ROSALIND","CHARITY","TONIA","BEATRIZ","MARISOL","CLARICE","JEANINE","SHEENA","ANGELINE","FRIEDA","LILY","ROBBIE","SHAUNA","MILLIE","CLAUDETTE","CATHLEEN","ANGELIA","GABRIELLE","AUTUMN","KATHARINE","SUMMER","JODIE","STACI","LEA","CHRISTI","JIMMIE","JUSTINE","ELMA","LUELLA","MARGRET","DOMINIQUE","SOCORRO","RENE","MARTINA","MARGO","MAVIS","CALLIE","BOBBI","MARITZA","LUCILE","LEANNE","JEANNINE","DEANA","AILEEN","LORIE","LADONNA","WILLA","MANUELA","GALE","SELMA","DOLLY","SYBIL","ABBY","LARA","DALE","IVY","DEE","WINNIE","MARCY","LUISA","JERI","MAGDALENA","OFELIA","MEAGAN","AUDRA","MATILDA","LEILA","CORNELIA","BIANCA","SIMONE","BETTYE","RANDI","VIRGIE","LATISHA","BARBRA","GEORGINA","ELIZA","LEANN","BRIDGETTE","RHODA","HALEY","ADELA","NOLA","BERNADINE","FLOSSIE","ILA","GRETA","RUTHIE","NELDA","MINERVA","LILLY","TERRIE","LETHA","HILARY","ESTELA","VALARIE","BRIANNA","ROSALYN","EARLINE","CATALINA","AVA","MIA","CLARISSA","LIDIA","CORRINE","ALEXANDRIA","CONCEPCION","TIA","SHARRON","RAE","DONA","ERICKA","JAMI","ELNORA","CHANDRA","LENORE","NEVA","MARYLOU","MELISA","TABATHA","SERENA","AVIS","ALLIE","SOFIA","JEANIE","ODESSA","NANNIE","HARRIETT","LORAINE","PENELOPE","MILAGROS","EMILIA","BENITA","ALLYSON","ASHLEE","TANIA","TOMMIE","ESMERALDA","KARINA","EVE","PEARLIE","ZELMA","MALINDA","NOREEN","TAMEKA","SAUNDRA","HILLARY","AMIE","ALTHEA","ROSALINDA","JORDAN","LILIA","ALANA","GAY","CLARE","ALEJANDRA","ELINOR","MICHAEL","LORRIE","JERRI","DARCY","EARNESTINE","CARMELLA","TAYLOR","NOEMI","MARCIE","LIZA","ANNABELLE","LOUISA","EARLENE","MALLORY","CARLENE","NITA","SELENA","TANISHA","KATY","JULIANNE","JOHN","LAKISHA","EDWINA","MARICELA","MARGERY","KENYA","DOLLIE","ROXIE","ROSLYN","KATHRINE","NANETTE","CHARMAINE","LAVONNE","ILENE","KRIS","TAMMI","SUZETTE","CORINE","KAYE","JERRY","MERLE","CHRYSTAL","LINA","DEANNE","LILIAN","JULIANA","ALINE","LUANN","KASEY","MARYANNE","EVANGELINE","COLETTE","MELVA","LAWANDA","YESENIA","NADIA","MADGE","KATHIE","EDDIE","OPHELIA","VALERIA","NONA","MITZI","MARI","GEORGETTE","CLAUDINE","FRAN","ALISSA","ROSEANN","LAKEISHA","SUSANNA","REVA","DEIDRE","CHASITY","SHEREE","CARLY","JAMES","ELVIA","ALYCE","DEIRDRE","GENA","BRIANA","ARACELI","KATELYN","ROSANNE","WENDI","TESSA","BERTA","MARVA","IMELDA","MARIETTA","MARCI","LEONOR","ARLINE","SASHA","MADELYN","JANNA","JULIETTE","DEENA","AURELIA","JOSEFA","AUGUSTA","LILIANA","YOUNG","CHRISTIAN","LESSIE","AMALIA","SAVANNAH","ANASTASIA","VILMA","NATALIA","ROSELLA","LYNNETTE","CORINA","ALFREDA","LEANNA","CAREY","AMPARO","COLEEN","TAMRA","AISHA","WILDA","KARYN","CHERRY","QUEEN","MAURA","MAI","EVANGELINA","ROSANNA","HALLIE","ERNA","ENID","MARIANA","LACY","JULIET","JACKLYN","FREIDA","MADELEINE","MARA","HESTER","CATHRYN","LELIA","CASANDRA","BRIDGETT","ANGELITA","JANNIE","DIONNE","ANNMARIE","KATINA","BERYL","PHOEBE","MILLICENT","KATHERYN","DIANN","CARISSA","MARYELLEN","LIZ","LAURI","HELGA","GILDA","ADRIAN","RHEA","MARQUITA","HOLLIE","TISHA","TAMERA","ANGELIQUE","FRANCESCA","BRITNEY","KAITLIN","LOLITA","FLORINE","ROWENA","REYNA","TWILA","FANNY","JANELL","INES","CONCETTA","BERTIE","ALBA","BRIGITTE","ALYSON","VONDA","PANSY","ELBA","NOELLE","LETITIA","KITTY","DEANN","BRANDIE","LOUELLA","LETA","FELECIA","SHARLENE","LESA","BEVERLEY","ROBERT","ISABELLA","HERMINIA","TERRA","CELINA","TORI","OCTAVIA","JADE","DENICE","GERMAINE","SIERRA","MICHELL","CORTNEY","NELLY","DORETHA","SYDNEY","DEIDRA","MONIKA","LASHONDA","JUDI","CHELSEY","ANTIONETTE","MARGOT","BOBBY","ADELAIDE","NAN","LEEANN","ELISHA","DESSIE","LIBBY","KATHI","GAYLA","LATANYA","MINA","MELLISA","KIMBERLEE","JASMIN","RENAE","ZELDA","ELDA","MA","JUSTINA","GUSSIE","EMILIE","CAMILLA","ABBIE","ROCIO","KAITLYN","JESSE","EDYTHE","ASHLEIGH","SELINA","LAKESHA","GERI","ALLENE","PAMALA","MICHAELA","DAYNA","CARYN","ROSALIA","SUN","JACQULINE","REBECA","MARYBETH","KRYSTLE","IOLA","DOTTIE","BENNIE","BELLE","AUBREY","GRISELDA","ERNESTINA","ELIDA","ADRIANNE","DEMETRIA","DELMA","CHONG","JAQUELINE","DESTINY","ARLEEN","VIRGINA","RETHA","FATIMA","TILLIE","ELEANORE","CARI","TREVA","BIRDIE","WILHELMINA","ROSALEE","MAURINE","LATRICE","YONG","JENA","TARYN","ELIA","DEBBY","MAUDIE","JEANNA","DELILAH","CATRINA","SHONDA","HORTENCIA","THEODORA","TERESITA","ROBBIN","DANETTE","MARYJANE","FREDDIE","DELPHINE","BRIANNE","NILDA","DANNA","CINDI","BESS","IONA","HANNA","ARIEL","WINONA","VIDA","ROSITA","MARIANNA","WILLIAM","RACHEAL","GUILLERMINA","ELOISA","CELESTINE","CAREN","MALISSA","LONA","CHANTEL","SHELLIE","MARISELA","LEORA","AGATHA","SOLEDAD","MIGDALIA","IVETTE","CHRISTEN","ATHENA","JANEL","CHLOE","VEDA","PATTIE","TESSIE","TERA","MARILYNN","LUCRETIA","KARRIE","DINAH","DANIELA","ALECIA","ADELINA","VERNICE","SHIELA","PORTIA","MERRY","LASHAWN","DEVON","DARA","TAWANA","OMA","VERDA","CHRISTIN","ALENE","ZELLA","SANDI","RAFAELA","MAYA","KIRA","CANDIDA","ALVINA","SUZAN","SHAYLA","LYN","LETTIE","ALVA","SAMATHA","ORALIA","MATILDE","MADONNA","LARISSA","VESTA","RENITA","INDIA","DELOIS","SHANDA","PHILLIS","LORRI","ERLINDA","CRUZ","CATHRINE","BARB","ZOE","ISABELL","IONE","GISELA","CHARLIE","VALENCIA","ROXANNA","MAYME","KISHA","ELLIE","MELLISSA","DORRIS","DALIA","BELLA","ANNETTA","ZOILA","RETA","REINA","LAURETTA","KYLIE","CHRISTAL","PILAR","CHARLA","ELISSA","TIFFANI","TANA","PAULINA","LEOTA","BREANNA","JAYME","CARMEL","VERNELL","TOMASA","MANDI","DOMINGA","SANTA","MELODIE","LURA","ALEXA","TAMELA","RYAN","MIRNA","KERRIE","VENUS","NOEL","FELICITA","CRISTY","CARMELITA","BERNIECE","ANNEMARIE","TIARA","ROSEANNE","MISSY","CORI","ROXANA","PRICILLA","KRISTAL","JUNG","ELYSE","HAYDEE","ALETHA","BETTINA","MARGE","GILLIAN","FILOMENA","CHARLES","ZENAIDA","HARRIETTE","CARIDAD","VADA","UNA","ARETHA","PEARLINE","MARJORY","MARCELA","FLOR","EVETTE","ELOUISE","ALINA","TRINIDAD","DAVID","DAMARIS","CATHARINE","CARROLL","BELVA","NAKIA","MARLENA","LUANNE","LORINE","KARON","DORENE","DANITA","BRENNA","TATIANA","SAMMIE","LOUANN","LOREN","JULIANNA","ANDRIA","PHILOMENA","LUCILA","LEONORA","DOVIE","ROMONA","MIMI","JACQUELIN","GAYE","TONJA","MISTI","JOE","GENE","CHASTITY","STACIA","ROXANN","MICAELA","NIKITA","MEI","VELDA","MARLYS","JOHNNA","AURA","LAVERN","IVONNE","HAYLEY","NICKI","MAJORIE","HERLINDA","GEORGE","ALPHA","YADIRA","PERLA","GREGORIA","DANIEL","ANTONETTE","SHELLI","MOZELLE","MARIAH","JOELLE","CORDELIA","JOSETTE","CHIQUITA","TRISTA","LOUIS","LAQUITA","GEORGIANA","CANDI","SHANON","LONNIE","HILDEGARD","CECIL","VALENTINA","STEPHANY","MAGDA","KAROL","GERRY","GABRIELLA","TIANA","ROMA","RICHELLE","RAY","PRINCESS","OLETA","JACQUE","IDELLA","ALAINA","SUZANNA","JOVITA","BLAIR","TOSHA","RAVEN","NEREIDA","MARLYN","KYLA","JOSEPH","DELFINA","TENA","STEPHENIE","SABINA","NATHALIE","MARCELLE","GERTIE","DARLEEN","THEA","SHARONDA","SHANTEL","BELEN","VENESSA","ROSALINA","ONA","GENOVEVA","COREY","CLEMENTINE","ROSALBA","RENATE","RENATA","MI","IVORY","GEORGIANNA","FLOY","DORCAS","ARIANA","TYRA","THEDA","MARIAM","JULI","JESICA","DONNIE","VIKKI","VERLA","ROSELYN","MELVINA","JANNETTE","GINNY","DEBRAH","CORRIE","ASIA","VIOLETA","MYRTIS","LATRICIA","COLLETTE","CHARLEEN","ANISSA","VIVIANA","TWYLA","PRECIOUS","NEDRA","LATONIA","LAN","HELLEN","FABIOLA","ANNAMARIE","ADELL","SHARYN","CHANTAL","NIKI","MAUD","LIZETTE","LINDY","KIA","KESHA","JEANA","DANELLE","CHARLINE","CHANEL","CARROL","VALORIE","LIA","DORTHA","CRISTAL","SUNNY","LEONE","LEILANI","GERRI","DEBI","ANDRA","KESHIA","IMA","EULALIA","EASTER","DULCE","NATIVIDAD","LINNIE","KAMI","GEORGIE","CATINA","BROOK","ALDA","WINNIFRED","SHARLA","RUTHANN","MEAGHAN","MAGDALENE","LISSETTE","ADELAIDA","VENITA","TRENA","SHIRLENE","SHAMEKA","ELIZEBETH","DIAN","SHANTA","MICKEY","LATOSHA","CARLOTTA","WINDY","SOON","ROSINA","MARIANN","LEISA","JONNIE","DAWNA","CATHIE","BILLY","ASTRID","SIDNEY","LAUREEN","JANEEN","HOLLI","FAWN","VICKEY","TERESSA","SHANTE","RUBYE","MARCELINA","CHANDA","CARY","TERESE","SCARLETT","MARTY","MARNIE","LULU","LISETTE","JENIFFER","ELENOR","DORINDA","DONITA","CARMAN","BERNITA","ALTAGRACIA","ALETA","ADRIANNA","ZORAIDA","RONNIE","NICOLA","LYNDSEY","KENDALL","JANINA","CHRISSY","AMI","STARLA","PHYLIS","PHUONG","KYRA","CHARISSE","BLANCH","SANJUANITA","RONA","NANCI","MARILEE","MARANDA","CORY","BRIGETTE","SANJUANA","MARITA","KASSANDRA","JOYCELYN","IRA","FELIPA","CHELSIE","BONNY","MIREYA","LORENZA","KYONG","ILEANA","CANDELARIA","TONY","TOBY","SHERIE","OK","MARK","LUCIE","LEATRICE","LAKESHIA","GERDA","EDIE","BAMBI","MARYLIN","LAVON","HORTENSE","GARNET","EVIE","TRESSA","SHAYNA","LAVINA","KYUNG","JEANETTA","SHERRILL","SHARA","PHYLISS","MITTIE","ANABEL","ALESIA","THUY","TAWANDA","RICHARD","JOANIE","TIFFANIE","LASHANDA","KARISSA","ENRIQUETA","DARIA","DANIELLA","CORINNA","ALANNA","ABBEY","ROXANE","ROSEANNA","MAGNOLIA","LIDA","KYLE","JOELLEN","ERA","CORAL","CARLEEN","TRESA","PEGGIE","NOVELLA","NILA","MAYBELLE","JENELLE","CARINA","NOVA","MELINA","MARQUERITE","MARGARETTE","JOSEPHINA","EVONNE","DEVIN","CINTHIA","ALBINA","TOYA","TAWNYA","SHERITA","SANTOS","MYRIAM","LIZABETH","LISE","KEELY","JENNI","GISELLE","CHERYLE","ARDITH","ARDIS","ALESHA","ADRIANE","SHAINA","LINNEA","KAROLYN","HONG","FLORIDA","FELISHA","DORI","DARCI","ARTIE","ARMIDA","ZOLA","XIOMARA","VERGIE","SHAMIKA","NENA","NANNETTE","MAXIE","LOVIE","JEANE","JAIMIE","INGE","FARRAH","ELAINA","CAITLYN","STARR","FELICITAS","CHERLY","CARYL","YOLONDA","YASMIN","TEENA","PRUDENCE","PENNIE","NYDIA","MACKENZIE","ORPHA","MARVEL","LIZBETH","LAURETTE","JERRIE","HERMELINDA","CAROLEE","TIERRA","MIRIAN","META","MELONY","KORI","JENNETTE","JAMILA","ENA","ANH","YOSHIKO","SUSANNAH","SALINA","RHIANNON","JOLEEN","CRISTINE","ASHTON","ARACELY","TOMEKA","SHALONDA","MARTI","LACIE","KALA","JADA","ILSE","HAILEY","BRITTANI","ZONA","SYBLE","SHERRYL","RANDY","NIDIA","MARLO","KANDICE","KANDI","DEB","DEAN","AMERICA","ALYCIA","TOMMY","RONNA","NORENE","MERCY","JOSE","INGEBORG","GIOVANNA","GEMMA","CHRISTEL","AUDRY","ZORA","VITA","VAN","TRISH","STEPHAINE","SHIRLEE","SHANIKA","MELONIE","MAZIE","JAZMIN","INGA","HOA","HETTIE","GERALYN","FONDA","ESTRELLA","ADELLA","SU","SARITA","RINA","MILISSA","MARIBETH","GOLDA","EVON","ETHELYN","ENEDINA","CHERISE","CHANA","VELVA","TAWANNA","SADE","MIRTA","LI","KARIE","JACINTA","ELNA","DAVINA","CIERRA","ASHLIE","ALBERTHA","TANESHA","STEPHANI","NELLE","MINDI","LU","LORINDA","LARUE","FLORENE","DEMETRA","DEDRA","CIARA","CHANTELLE","ASHLY","SUZY","ROSALVA","NOELIA","LYDA","LEATHA","KRYSTYNA","KRISTAN","KARRI","DARLINE","DARCIE","CINDA","CHEYENNE","CHERRIE","AWILDA","ALMEDA","ROLANDA","LANETTE","JERILYN","GISELE","EVALYN","CYNDI","CLETA","CARIN","ZINA","ZENA","VELIA","TANIKA","PAUL","CHARISSA","THOMAS","TALIA","MARGARETE","LAVONDA","KAYLEE","KATHLENE","JONNA","IRENA","ILONA","IDALIA","CANDIS","CANDANCE","BRANDEE","ANITRA","ALIDA","SIGRID","NICOLETTE","MARYJO","LINETTE","HEDWIG","CHRISTIANA","CASSIDY","ALEXIA","TRESSIE","MODESTA","LUPITA","LITA","GLADIS","EVELIA","DAVIDA","CHERRI","CECILY","ASHELY","ANNABEL","AGUSTINA","WANITA","SHIRLY","ROSAURA","HULDA","EUN","BAILEY","YETTA","VERONA","THOMASINA","SIBYL","SHANNAN","MECHELLE","LUE","LEANDRA","LANI","KYLEE","KANDY","JOLYNN","FERNE","EBONI","CORENE","ALYSIA","ZULA","NADA","MOIRA","LYNDSAY","LORRETTA","JUAN","JAMMIE","HORTENSIA","GAYNELL","CAMERON","ADRIA","VINA","VICENTA","TANGELA","STEPHINE","NORINE","NELLA","LIANA","LESLEE","KIMBERELY","ILIANA","GLORY","FELICA","EMOGENE","ELFRIEDE","EDEN","EARTHA","CARMA","BEA","OCIE","MARRY","LENNIE","KIARA","JACALYN","CARLOTA","ARIELLE","YU","STAR","OTILIA","KIRSTIN","KACEY","JOHNETTA","JOEY","JOETTA","JERALDINE","JAUNITA","ELANA","DORTHEA","CAMI","AMADA","ADELIA","VERNITA","TAMAR","SIOBHAN","RENEA","RASHIDA","OUIDA","ODELL","NILSA","MERYL","KRISTYN","JULIETA","DANICA","BREANNE","AUREA","ANGLEA","SHERRON","ODETTE","MALIA","LORELEI","LIN","LEESA","KENNA","KATHLYN","FIONA","CHARLETTE","SUZIE","SHANTELL","SABRA","RACQUEL","MYONG","MIRA","MARTINE","LUCIENNE","LAVADA","JULIANN","JOHNIE","ELVERA","DELPHIA","CLAIR","CHRISTIANE","CHAROLETTE","CARRI","AUGUSTINE","ASHA","ANGELLA","PAOLA","NINFA","LEDA","LAI","EDA","SUNSHINE","STEFANI","SHANELL","PALMA","MACHELLE","LISSA","KECIA","KATHRYNE","KARLENE","JULISSA","JETTIE","JENNIFFER","HUI","CORRINA","CHRISTOPHER","CAROLANN","ALENA","TESS","ROSARIA","MYRTICE","MARYLEE","LIANE","KENYATTA","JUDIE","JANEY","IN","ELMIRA","ELDORA","DENNA","CRISTI","CATHI","ZAIDA","VONNIE","VIVA","VERNIE","ROSALINE","MARIELA","LUCIANA","LESLI","KARAN","FELICE","DENEEN","ADINA","WYNONA","TARSHA","SHERON","SHASTA","SHANITA","SHANI","SHANDRA","RANDA","PINKIE","PARIS","NELIDA","MARILOU","LYLA","LAURENE","LACI","JOI","JANENE","DOROTHA","DANIELE","DANI","CAROLYNN","CARLYN","BERENICE","AYESHA","ANNELIESE","ALETHEA","THERSA","TAMIKO","RUFINA","OLIVA","MOZELL","MARYLYN","MADISON","KRISTIAN","KATHYRN","KASANDRA","KANDACE","JANAE","GABRIEL","DOMENICA","DEBBRA","DANNIELLE","CHUN","BUFFY","BARBIE","ARCELIA","AJA","ZENOBIA","SHAREN","SHAREE","PATRICK","PAGE","MY","LAVINIA","KUM","KACIE","JACKELINE","HUONG","FELISA","EMELIA","ELEANORA","CYTHIA","CRISTIN","CLYDE","CLARIBEL","CARON","ANASTACIA","ZULMA","ZANDRA","YOKO","TENISHA","SUSANN","SHERILYN","SHAY","SHAWANDA","SABINE","ROMANA","MATHILDA","LINSEY","KEIKO","JOANA","ISELA","GRETTA","GEORGETTA","EUGENIE","DUSTY","DESIRAE","DELORA","CORAZON","ANTONINA","ANIKA","WILLENE","TRACEE","TAMATHA","REGAN","NICHELLE","MICKIE","MAEGAN","LUANA","LANITA","KELSIE","EDELMIRA","BREE","AFTON","TEODORA","TAMIE","SHENA","MEG","LINH","KELI","KACI","DANYELLE","BRITT","ARLETTE","ALBERTINE","ADELLE","TIFFINY","STORMY","SIMONA","NUMBERS","NICOLASA","NICHOL","NIA","NAKISHA","MEE","MAIRA","LOREEN","KIZZY","JOHNNY","JAY","FALLON","CHRISTENE","BOBBYE","ANTHONY","YING","VINCENZA","TANJA","RUBIE","RONI","QUEENIE","MARGARETT","KIMBERLI","IRMGARD","IDELL","HILMA","EVELINA","ESTA","EMILEE","DENNISE","DANIA","CARL","CARIE","ANTONIO","WAI","SANG","RISA","RIKKI","PARTICIA","MUI","MASAKO","MARIO","LUVENIA","LOREE","LONI","LIEN","KEVIN","GIGI","FLORENCIA","DORIAN","DENITA","DALLAS","CHI","BILLYE","ALEXANDER","TOMIKA","SHARITA","RANA","NIKOLE","NEOMA","MARGARITE","MADALYN","LUCINA","LAILA","KALI","JENETTE","GABRIELE","EVELYNE","ELENORA","CLEMENTINA","ALEJANDRINA","ZULEMA","VIOLETTE","VANNESSA","THRESA","RETTA","PIA","PATIENCE","NOELLA","NICKIE","JONELL","DELTA","CHUNG","CHAYA","CAMELIA","BETHEL","ANYA","ANDREW","THANH","SUZANN","SPRING","SHU","MILA","LILLA","LAVERNA","KEESHA","KATTIE","GIA","GEORGENE","EVELINE","ESTELL","ELIZBETH","VIVIENNE","VALLIE","TRUDIE","STEPHANE","MICHEL","MAGALY","MADIE","KENYETTA","KARREN","JANETTA","HERMINE","HARMONY","DRUCILLA","DEBBI","CELESTINA","CANDIE","BRITNI","BECKIE","AMINA","ZITA","YUN","YOLANDE","VIVIEN","VERNETTA","TRUDI","SOMMER","PEARLE","PATRINA","OSSIE","NICOLLE","LOYCE","LETTY","LARISA","KATHARINA","JOSELYN","JONELLE","JENELL","IESHA","HEIDE","FLORINDA","FLORENTINA","FLO","ELODIA","DORINE","BRUNILDA","BRIGID","ASHLI","ARDELLA","TWANA","THU","TARAH","SUNG","SHEA","SHAVON","SHANE","SERINA","RAYNA","RAMONITA","NGA","MARGURITE","LUCRECIA","KOURTNEY","KATI","JESUS","JESENIA","DIAMOND","CRISTA","AYANA","ALICA","ALIA","VINNIE","SUELLEN","ROMELIA","RACHELL","PIPER","OLYMPIA","MICHIKO","KATHALEEN","JOLIE","JESSI","JANESSA","HANA","HA","ELEASE","CARLETTA","BRITANY","SHONA","SALOME","ROSAMOND","REGENA","RAINA","NGOC","NELIA","LOUVENIA","LESIA","LATRINA","LATICIA","LARHONDA","JINA","JACKI","HOLLIS","HOLLEY","EMMY","DEEANN","CORETTA","ARNETTA","VELVET","THALIA","SHANICE","NETA","MIKKI","MICKI","LONNA","LEANA","LASHUNDA","KILEY","JOYE","JACQULYN","IGNACIA","HYUN","HIROKO","HENRY","HENRIETTE","ELAYNE","DELINDA","DARNELL","DAHLIA","COREEN","CONSUELA","CONCHITA","CELINE","BABETTE","AYANNA","ANETTE","ALBERTINA","SKYE","SHAWNEE","SHANEKA","QUIANA","PAMELIA","MIN","MERRI","MERLENE","MARGIT","KIESHA","KIERA","KAYLENE","JODEE","JENISE","ERLENE","EMMIE","ELSE","DARYL","DALILA","DAISEY","CODY","CASIE","BELIA","BABARA","VERSIE","VANESA","SHELBA","SHAWNDA","SAM","NORMAN","NIKIA","NAOMA","MARNA","MARGERET","MADALINE","LAWANA","KINDRA","JUTTA","JAZMINE","JANETT","HANNELORE","GLENDORA","GERTRUD","GARNETT","FREEDA","FREDERICA","FLORANCE","FLAVIA","DENNIS","CARLINE","BEVERLEE","ANJANETTE","VALDA","TRINITY","TAMALA","STEVIE","SHONNA","SHA","SARINA","ONEIDA","MICAH","MERILYN","MARLEEN","LURLINE","LENNA","KATHERIN","JIN","JENI","HAE","GRACIA","GLADY","FARAH","ERIC","ENOLA","EMA","DOMINQUE","DEVONA","DELANA","CECILA","CAPRICE","ALYSHA","ALI","ALETHIA","VENA","THERESIA","TAWNY","SONG","SHAKIRA","SAMARA","SACHIKO","RACHELE","PAMELLA","NICKY","MARNI","MARIEL","MAREN","MALISA","LIGIA","LERA","LATORIA","LARAE","KIMBER","KATHERN","KAREY","JENNEFER","JANETH","HALINA","FREDIA","DELISA","DEBROAH","CIERA","CHIN","ANGELIKA","ANDREE","ALTHA","YEN","VIVAN","TERRESA","TANNA","SUK","SUDIE","SOO","SIGNE","SALENA","RONNI","REBBECCA","MYRTIE","MCKENZIE","MALIKA","MAIDA","LOAN","LEONARDA","KAYLEIGH","FRANCE","ETHYL","ELLYN","DAYLE","CAMMIE","BRITTNI","BIRGIT","AVELINA","ASUNCION","ARIANNA","AKIKO","VENICE","TYESHA","TONIE","TIESHA","TAKISHA","STEFFANIE","SINDY","SANTANA","MEGHANN","MANDA","MACIE","LADY","KELLYE","KELLEE","JOSLYN","JASON","INGER","INDIRA","GLINDA","GLENNIS","FERNANDA","FAUSTINA","ENEIDA","ELICIA","DOT","DIGNA","DELL","ARLETTA","ANDRE","WILLIA","TAMMARA","TABETHA","SHERRELL","SARI","REFUGIO","REBBECA","PAULETTA","NIEVES","NATOSHA","NAKITA","MAMMIE","KENISHA","KAZUKO","KASSIE","GARY","EARLEAN","DAPHINE","CORLISS","CLOTILDE","CAROLYNE","BERNETTA","AUGUSTINA","AUDREA","ANNIS","ANNABELL","YAN","TENNILLE","TAMICA","SELENE","SEAN","ROSANA","REGENIA","QIANA","MARKITA","MACY","LEEANNE","LAURINE","KYM","JESSENIA","JANITA","GEORGINE","GENIE","EMIKO","ELVIE","DEANDRA","DAGMAR","CORIE","COLLEN","CHERISH","ROMAINE","PORSHA","PEARLENE","MICHELINE","MERNA","MARGORIE","MARGARETTA","LORE","KENNETH","JENINE","HERMINA","FREDERICKA","ELKE","DRUSILLA","DORATHY","DIONE","DESIRE","CELENA","BRIGIDA","ANGELES","ALLEGRA","THEO","TAMEKIA","SYNTHIA","STEPHEN","SOOK","SLYVIA","ROSANN","REATHA","RAYE","MARQUETTA","MARGART","LING","LAYLA","KYMBERLY","KIANA","KAYLEEN","KATLYN","KARMEN","JOELLA","IRINA","EMELDA","ELENI","DETRA","CLEMMIE","CHERYLL","CHANTELL","CATHEY","ARNITA","ARLA","ANGLE","ANGELIC","ALYSE","ZOFIA","THOMASINE","TENNIE","SON","SHERLY","SHERLEY","SHARYL","REMEDIOS","PETRINA","NICKOLE","MYUNG","MYRLE","MOZELLA","LOUANNE","LISHA","LATIA","LANE","KRYSTA","JULIENNE","JOEL","JEANENE","JACQUALINE","ISAURA","GWENDA","EARLEEN","DONALD","CLEOPATRA","CARLIE","AUDIE","ANTONIETTA","ALISE","ALEX","VERDELL","VAL","TYLER","TOMOKO","THAO","TALISHA","STEVEN","SO","SHEMIKA","SHAUN","SCARLET","SAVANNA","SANTINA","ROSIA","RAEANN","ODILIA","NANA","MINNA","MAGAN","LYNELLE","LE","KARMA","JOEANN","IVANA","INELL","ILANA","HYE","HONEY","HEE","GUDRUN","FRANK","DREAMA","CRISSY","CHANTE","CARMELINA","ARVILLA","ARTHUR","ANNAMAE","ALVERA","ALEIDA","AARON","YEE","YANIRA","VANDA","TIANNA","TAM","STEFANIA","SHIRA","PERRY","NICOL","NANCIE","MONSERRATE","MINH","MELYNDA","MELANY","MATTHEW","LOVELLA","LAURE","KIRBY","KACY","JACQUELYNN","HYON","GERTHA","FRANCISCO","ELIANA","CHRISTENA","CHRISTEEN","CHARISE","CATERINA","CARLEY","CANDYCE","ARLENA","AMMIE","YANG","WILLETTE","VANITA","TUYET","TINY","SYREETA","SILVA","SCOTT","RONALD","PENNEY","NYLA","MICHAL","MAURICE","MARYAM","MARYA","MAGEN","LUDIE","LOMA","LIVIA","LANELL","KIMBERLIE","JULEE","DONETTA","DIEDRA","DENISHA","DEANE","DAWNE","CLARINE","CHERRYL","BRONWYN","BRANDON","ALLA","VALERY","TONDA","SUEANN","SORAYA","SHOSHANA","SHELA","SHARLEEN","SHANELLE","NERISSA","MICHEAL","MERIDITH","MELLIE","MAYE","MAPLE","MAGARET","LUIS","LILI","LEONILA","LEONIE","LEEANNA","LAVONIA","LAVERA","KRISTEL","KATHEY","KATHE","JUSTIN","JULIAN","JIMMY","JANN","ILDA","HILDRED","HILDEGARDE","GENIA","FUMIKO","EVELIN","ERMELINDA","ELLY","DUNG","DOLORIS","DIONNA","DANAE","BERNEICE","ANNICE","ALIX","VERENA","VERDIE","TRISTAN","SHAWNNA","SHAWANA","SHAUNNA","ROZELLA","RANDEE","RANAE","MILAGRO","LYNELL","LUISE","LOUIE","LOIDA","LISBETH","KARLEEN","JUNITA","JONA","ISIS","HYACINTH","HEDY","GWENN","ETHELENE","ERLINE","EDWARD","DONYA","DOMONIQUE","DELICIA","DANNETTE","CICELY","BRANDA","BLYTHE","BETHANN","ASHLYN","ANNALEE","ALLINE","YUKO","VELLA","TRANG","TOWANDA","TESHA","SHERLYN","NARCISA","MIGUELINA","MERI","MAYBELL","MARLANA","MARGUERITA","MADLYN","LUNA","LORY","LORIANN","LIBERTY","LEONORE","LEIGHANN","LAURICE","LATESHA","LARONDA","KATRICE","KASIE","KARL","KALEY","JADWIGA","GLENNIE","GEARLDINE","FRANCINA","EPIFANIA","DYAN","DORIE","DIEDRE","DENESE","DEMETRICE","DELENA","DARBY","CRISTIE","CLEORA","CATARINA","CARISA","BERNIE","BARBERA","ALMETA","TRULA","TEREASA","SOLANGE","SHEILAH","SHAVONNE","SANORA","ROCHELL","MATHILDE","MARGARETA","MAIA","LYNSEY","LAWANNA","LAUNA","KENA","KEENA","KATIA","JAMEY","GLYNDA","GAYLENE","ELVINA","ELANOR","DANUTA","DANIKA","CRISTEN","CORDIE","COLETTA","CLARITA","CARMON","BRYNN","AZUCENA","AUNDREA","ANGELE","YI","WALTER","VERLIE","VERLENE","TAMESHA","SILVANA","SEBRINA","SAMIRA","REDA","RAYLENE","PENNI","PANDORA","NORAH","NOMA","MIREILLE","MELISSIA","MARYALICE","LARAINE","KIMBERY","KARYL","KARINE","KAM","JOLANDA","JOHANA","JESUSA","JALEESA","JAE","JACQUELYNE","IRISH","ILUMINADA","HILARIA","HANH","GENNIE","FRANCIE","FLORETTA","EXIE","EDDA","DREMA","DELPHA","BEV","BARBAR","ASSUNTA","ARDELL","ANNALISA","ALISIA","YUKIKO","YOLANDO","WONDA","WEI","WALTRAUD","VETA","TEQUILA","TEMEKA","TAMEIKA","SHIRLEEN","SHENITA","PIEDAD","OZELLA","MIRTHA","MARILU","KIMIKO","JULIANE","JENICE","JEN","JANAY","JACQUILINE","HILDE","FE","FAE","EVAN","EUGENE","ELOIS","ECHO","DEVORAH","CHAU","BRINDA","BETSEY","ARMINDA","ARACELIS","APRYL","ANNETT","ALISHIA","VEOLA","USHA","TOSHIKO","THEOLA","TASHIA","TALITHA","SHERY","RUDY","RENETTA","REIKO","RASHEEDA","OMEGA","OBDULIA","MIKA","MELAINE","MEGGAN","MARTIN","MARLEN","MARGET","MARCELINE","MANA","MAGDALEN","LIBRADA","LEZLIE","LEXIE","LATASHIA","LASANDRA","KELLE","ISIDRA","ISA","INOCENCIA","GWYN","FRANCOISE","ERMINIA","ERINN","DIMPLE","DEVORA","CRISELDA","ARMANDA","ARIE","ARIANE","ANGELO","ANGELENA","ALLEN","ALIZA","ADRIENE","ADALINE","XOCHITL","TWANNA","TRAN","TOMIKO","TAMISHA","TAISHA","SUSY","SIU","RUTHA","ROXY","RHONA","RAYMOND","OTHA","NORIKO","NATASHIA","MERRIE","MELVIN","MARINDA","MARIKO","MARGERT","LORIS","LIZZETTE","LEISHA","KAILA","KA","JOANNIE","JERRICA","JENE","JANNET","JANEE","JACINDA","HERTA","ELENORE","DORETTA","DELAINE","DANIELL","CLAUDIE","CHINA","BRITTA","APOLONIA","AMBERLY","ALEASE","YURI","YUK","WEN","WANETA","UTE","TOMI","SHARRI","SANDIE","ROSELLE","REYNALDA","RAGUEL","PHYLICIA","PATRIA","OLIMPIA","ODELIA","MITZIE","MITCHELL","MISS","MINDA","MIGNON","MICA","MENDY","MARIVEL","MAILE","LYNETTA","LAVETTE","LAURYN","LATRISHA","LAKIESHA","KIERSTEN","KARY","JOSPHINE","JOLYN","JETTA","JANISE","JACQUIE","IVELISSE","GLYNIS","GIANNA","GAYNELLE","EMERALD","DEMETRIUS","DANYELL","DANILLE","DACIA","CORALEE","CHER","CEOLA","BRETT","BELL","ARIANNE","ALESHIA","YUNG","WILLIEMAE","TROY","TRINH","THORA","TAI","SVETLANA","SHERIKA","SHEMEKA","SHAUNDA","ROSELINE","RICKI","MELDA","MALLIE","LAVONNA","LATINA","LARRY","LAQUANDA","LALA","LACHELLE","KLARA","KANDIS","JOHNA","JEANMARIE","JAYE","HANG","GRAYCE","GERTUDE","EMERITA","EBONIE","CLORINDA","CHING","CHERY","CAROLA","BREANN","BLOSSOM","BERNARDINE","BECKI","ARLETHA","ARGELIA","ARA","ALITA","YULANDA","YON","YESSENIA","TOBI","TASIA","SYLVIE","SHIRL","SHIRELY","SHERIDAN","SHELLA","SHANTELLE","SACHA","ROYCE","REBECKA","REAGAN","PROVIDENCIA","PAULENE","MISHA","MIKI","MARLINE","MARICA","LORITA","LATOYIA","LASONYA","KERSTIN","KENDA","KEITHA","KATHRIN","JAYMIE","JACK","GRICELDA","GINETTE","ERYN","ELINA","ELFRIEDA","DANYEL","CHEREE","CHANELLE","BARRIE","AVERY","AURORE","ANNAMARIA","ALLEEN","AILENE","AIDE","YASMINE","VASHTI","VALENTINE","TREASA","TORY","TIFFANEY","SHERYLL","SHARIE","SHANAE","SAU","RAISA","PA","NEDA","MITSUKO","MIRELLA","MILDA","MARYANNA","MARAGRET","MABELLE","LUETTA","LORINA","LETISHA","LATARSHA","LANELLE","LAJUANA","KRISSY","KARLY","KARENA","JON","JESSIKA","JERICA","JEANELLE","JANUARY","JALISA","JACELYN","IZOLA","IVEY","GREGORY","EUNA","ETHA","DREW","DOMITILA","DOMINICA","DAINA","CREOLA","CARLI","CAMIE","BUNNY","BRITTNY","ASHANTI","ANISHA","ALEEN","ADAH","YASUKO","WINTER","VIKI","VALRIE","TONA","TINISHA","THI","TERISA","TATUM","TANEKA","SIMONNE","SHALANDA","SERITA","RESSIE","REFUGIA","PAZ","OLENE","NA","MERRILL","MARGHERITA","MANDIE","MAN","MAIRE","LYNDIA","LUCI","LORRIANE","LORETA","LEONIA","LAVONA","LASHAWNDA","LAKIA","KYOKO","KRYSTINA","KRYSTEN","KENIA","KELSI","JUDE","JEANICE","ISOBEL","GEORGIANN","GENNY","FELICIDAD","EILENE","DEON","DELOISE","DEEDEE","DANNIE","CONCEPTION","CLORA","CHERILYN","CHANG","CALANDRA","BERRY","ARMANDINA","ANISA","ULA","TIMOTHY","TIERA","THERESSA","STEPHANIA","SIMA","SHYLA","SHONTA","SHERA","SHAQUITA","SHALA","SAMMY","ROSSANA","NOHEMI","NERY","MORIAH","MELITA","MELIDA","MELANI","MARYLYNN","MARISHA","MARIETTE","MALORIE","MADELENE","LUDIVINA","LORIA","LORETTE","LORALEE","LIANNE","LEON","LAVENIA","LAURINDA","LASHON","KIT","KIMI","KEILA","KATELYNN","KAI","JONE","JOANE","JI","JAYNA","JANELLA","JA","HUE","HERTHA","FRANCENE","ELINORE","DESPINA","DELSIE","DEEDRA","CLEMENCIA","CARRY","CAROLIN","CARLOS","BULAH","BRITTANIE","BOK","BLONDELL","BIBI","BEAULAH","BEATA","ANNITA","AGRIPINA","VIRGEN","VALENE","UN","TWANDA","TOMMYE","TOI","TARRA","TARI","TAMMERA","SHAKIA","SADYE","RUTHANNE","ROCHEL","RIVKA","PURA","NENITA","NATISHA","MING","MERRILEE","MELODEE","MARVIS","LUCILLA","LEENA","LAVETA","LARITA","LANIE","KEREN","ILEEN","GEORGEANN","GENNA","GENESIS","FRIDA","EWA","EUFEMIA","EMELY","ELA","EDYTH","DEONNA","DEADRA","DARLENA","CHANELL","CHAN","CATHERN","CASSONDRA","CASSAUNDRA","BERNARDA","BERNA","ARLINDA","ANAMARIA","ALBERT","WESLEY","VERTIE","VALERI","TORRI","TATYANA","STASIA","SHERISE","SHERILL","SEASON","SCOTTIE","SANDA","RUTHE","ROSY","ROBERTO","ROBBI","RANEE","QUYEN","PEARLY","PALMIRA","ONITA","NISHA","NIESHA","NIDA","NEVADA","NAM","MERLYN","MAYOLA","MARYLOUISE","MARYLAND","MARX","MARTH","MARGENE","MADELAINE","LONDA","LEONTINE","LEOMA","LEIA","LAWRENCE","LAURALEE","LANORA","LAKITA","KIYOKO","KETURAH","KATELIN","KAREEN","JONIE","JOHNETTE","JENEE","JEANETT","IZETTA","HIEDI","HEIKE","HASSIE","HAROLD","GIUSEPPINA","GEORGANN","FIDELA","FERNANDE","ELWANDA","ELLAMAE","ELIZ","DUSTI","DOTTY","CYNDY","CORALIE","CELESTA","ARGENTINA","ALVERTA","XENIA","WAVA","VANETTA","TORRIE","TASHINA","TANDY","TAMBRA","TAMA","STEPANIE","SHILA","SHAUNTA","SHARAN","SHANIQUA","SHAE","SETSUKO","SERAFINA","SANDEE","ROSAMARIA","PRISCILA","OLINDA","NADENE","MUOI","MICHELINA","MERCEDEZ","MARYROSE","MARIN","MARCENE","MAO","MAGALI","MAFALDA","LOGAN","LINN","LANNIE","KAYCE","KAROLINE","KAMILAH","KAMALA","JUSTA","JOLINE","JENNINE","JACQUETTA","IRAIDA","GERALD","GEORGEANNA","FRANCHESCA","FAIRY","EMELINE","ELANE","EHTEL","EARLIE","DULCIE","DALENE","CRIS","CLASSIE","CHERE","CHARIS","CAROYLN","CARMINA","CARITA","BRIAN","BETHANIE","AYAKO","ARICA","AN","ALYSA","ALESSANDRA","AKILAH","ADRIEN","ZETTA","YOULANDA","YELENA","YAHAIRA","XUAN","WENDOLYN","VICTOR","TIJUANA","TERRELL","TERINA","TERESIA","SUZI","SUNDAY","SHERELL","SHAVONDA","SHAUNTE","SHARDA","SHAKITA","SENA","RYANN","RUBI","RIVA","REGINIA","REA","RACHAL","PARTHENIA","PAMULA","MONNIE","MONET","MICHAELE","MELIA","MARINE","MALKA","MAISHA","LISANDRA","LEO","LEKISHA","LEAN","LAURENCE","LAKENDRA","KRYSTIN","KORTNEY","KIZZIE","KITTIE","KERA","KENDAL","KEMBERLY","KANISHA","JULENE","JULE","JOSHUA","JOHANNE","JEFFREY","JAMEE","HAN","HALLEY","GIDGET","GALINA","FREDRICKA","FLETA","FATIMAH","EUSEBIA","ELZA","ELEONORE","DORTHEY","DORIA","DONELLA","DINORAH","DELORSE","CLARETHA","CHRISTINIA","CHARLYN","BONG","BELKIS","AZZIE","ANDERA","AIKO","ADENA","YER","YAJAIRA","WAN","VANIA","ULRIKE","TOSHIA","TIFANY","STEFANY","SHIZUE","SHENIKA","SHAWANNA","SHAROLYN","SHARILYN","SHAQUANA","SHANTAY","SEE","ROZANNE","ROSELEE","RICKIE","REMONA","REANNA","RAELENE","QUINN","PHUNG","PETRONILA","NATACHA","NANCEY","MYRL","MIYOKO","MIESHA","MERIDETH","MARVELLA","MARQUITTA","MARHTA","MARCHELLE","LIZETH","LIBBIE","LAHOMA","LADAWN","KINA","KATHELEEN","KATHARYN","KARISA","KALEIGH","JUNIE","JULIEANN","JOHNSIE","JANEAN","JAIMEE","JACKQUELINE","HISAKO","HERMA","HELAINE","GWYNETH","GLENN","GITA","EUSTOLIA","EMELINA","ELIN","EDRIS","DONNETTE","DONNETTA","DIERDRE","DENAE","DARCEL","CLAUDE","CLARISA","CINDERELLA","CHIA","CHARLESETTA","CHARITA","CELSA","CASSY","CASSI","CARLEE","BRUNA","BRITTANEY","BRANDE","BILLI","BAO","ANTONETTA","ANGLA","ANGELYN","ANALISA","ALANE","WENONA","WENDIE","VERONIQUE","VANNESA","TOBIE","TEMPIE","SUMIKO","SULEMA","SPARKLE","SOMER","SHEBA","SHAYNE","SHARICE","SHANEL","SHALON","SAGE","ROY","ROSIO","ROSELIA","RENAY","REMA","REENA","PORSCHE","PING","PEG","OZIE","ORETHA","ORALEE","ODA","NU","NGAN","NAKESHA","MILLY","MARYBELLE","MARLIN","MARIS","MARGRETT","MARAGARET","MANIE","LURLENE","LILLIA","LIESELOTTE","LAVELLE","LASHAUNDA","LAKEESHA","KEITH","KAYCEE","KALYN","JOYA","JOETTE","JENAE","JANIECE","ILLA","GRISEL","GLAYDS","GENEVIE","GALA","FREDDA","FRED","ELMER","ELEONOR","DEBERA","DEANDREA","DAN","CORRINNE","CORDIA","CONTESSA","COLENE","CLEOTILDE","CHARLOTT","CHANTAY","CECILLE","BEATRIS","AZALEE","ARLEAN","ARDATH","ANJELICA","ANJA","ALFREDIA","ALEISHA","ADAM","ZADA","YUONNE","XIAO","WILLODEAN","WHITLEY","VENNIE","VANNA","TYISHA","TOVA","TORIE","TONISHA","TILDA","TIEN","TEMPLE","SIRENA","SHERRIL","SHANTI","SHAN","SENAIDA","SAMELLA","ROBBYN","RENDA","REITA","PHEBE","PAULITA","NOBUKO","NGUYET","NEOMI","MOON","MIKAELA","MELANIA","MAXIMINA","MARG","MAISIE","LYNNA","LILLI","LAYNE","LASHAUN","LAKENYA","LAEL","KIRSTIE","KATHLINE","KASHA","KARLYN","KARIMA","JOVAN","JOSEFINE","JENNELL","JACQUI","JACKELYN","HYO","HIEN","GRAZYNA","FLORRIE","FLORIA","ELEONORA","DWANA","DORLA","DONG","DELMY","DEJA","DEDE","DANN","CRYSTA","CLELIA","CLARIS","CLARENCE","CHIEKO","CHERLYN","CHERELLE","CHARMAIN","CHARA","CAMMY","BEE","ARNETTE","ARDELLE","ANNIKA","AMIEE","AMEE","ALLENA","YVONE","YUKI","YOSHIE","YEVETTE","YAEL","WILLETTA","VONCILE","VENETTA","TULA","TONETTE","TIMIKA","TEMIKA","TELMA","TEISHA","TAREN","TA","STACEE","SHIN","SHAWNTA","SATURNINA","RICARDA","POK","PASTY","ONIE","NUBIA","MORA","MIKE","MARIELLE","MARIELLA","MARIANELA","MARDELL","MANY","LUANNA","LOISE","LISABETH","LINDSY","LILLIANA","LILLIAM","LELAH","LEIGHA","LEANORA","LANG","KRISTEEN","KHALILAH","KEELEY","KANDRA","JUNKO","JOAQUINA","JERLENE","JANI","JAMIKA","JAME","HSIU","HERMILA","GOLDEN","GENEVIVE","EVIA","EUGENA","EMMALINE","ELFREDA","ELENE","DONETTE","DELCIE","DEEANNA","DARCEY","CUC","CLARINDA","CIRA","CHAE","CELINDA","CATHERYN","CATHERIN","CASIMIRA","CARMELIA","CAMELLIA","BREANA","BOBETTE","BERNARDINA","BEBE","BASILIA","ARLYNE","AMAL","ALAYNA","ZONIA","ZENIA","YURIKO","YAEKO","WYNELL","WILLOW","WILLENA","VERNIA","TU","TRAVIS","TORA","TERRILYN","TERICA","TENESHA","TAWNA","TAJUANA","TAINA","STEPHNIE","SONA","SOL","SINA","SHONDRA","SHIZUKO","SHERLENE","SHERICE","SHARIKA","ROSSIE","ROSENA","RORY","RIMA","RIA","RHEBA","RENNA","PETER","NATALYA","NANCEE","MELODI","MEDA","MAXIMA","MATHA","MARKETTA","MARICRUZ","MARCELENE","MALVINA","LUBA","LOUETTA","LEIDA","LECIA","LAURAN","LASHAWNA","LAINE","KHADIJAH","KATERINE","KASI","KALLIE","JULIETTA","JESUSITA","JESTINE","JESSIA","JEREMY","JEFFIE","JANYCE","ISADORA","GEORGIANNE","FIDELIA","EVITA","EURA","EULAH","ESTEFANA","ELSY","ELIZABET","ELADIA","DODIE","DION","DIA","DENISSE","DELORAS","DELILA","DAYSI","DAKOTA","CURTIS","CRYSTLE","CONCHA","COLBY","CLARETTA","CHU","CHRISTIA","CHARLSIE","CHARLENA","CARYLON","BETTYANN","ASLEY","ASHLEA","AMIRA","AI","AGUEDA","AGNUS","YUETTE","VINITA","VICTORINA","TYNISHA","TREENA","TOCCARA","TISH","THOMASENA","TEGAN","SOILA","SHILOH","SHENNA","SHARMAINE","SHANTAE","SHANDI","SEPTEMBER","SARAN","SARAI","SANA","SAMUEL","SALLEY","ROSETTE","ROLANDE","REGINE","OTELIA","OSCAR","OLEVIA","NICHOLLE","NECOLE","NAIDA","MYRTA","MYESHA","MITSUE","MINTA","MERTIE","MARGY","MAHALIA","MADALENE","LOVE","LOURA","LOREAN","LEWIS","LESHA","LEONIDA","LENITA","LAVONE","LASHELL","LASHANDRA","LAMONICA","KIMBRA","KATHERINA","KARRY","KANESHA","JULIO","JONG","JENEVA","JAQUELYN","HWA","GILMA","GHISLAINE","GERTRUDIS","FRANSISCA","FERMINA","ETTIE","ETSUKO","ELLIS","ELLAN","ELIDIA","EDRA","DORETHEA","DOREATHA","DENYSE","DENNY","DEETTA","DAINE","CYRSTAL","CORRIN","CAYLA","CARLITA","CAMILA","BURMA","BULA","BUENA","BLAKE","BARABARA","AVRIL","AUSTIN","ALAINE","ZANA","WILHEMINA","WANETTA","VIRGIL","VI","VERONIKA","VERNON","VERLINE","VASILIKI","TONITA","TISA","TEOFILA","TAYNA","TAUNYA","TANDRA","TAKAKO","SUNNI","SUANNE","SIXTA","SHARELL","SEEMA","RUSSELL","ROSENDA","ROBENA","RAYMONDE","PEI","PAMILA","OZELL","NEIDA","NEELY","MISTIE","MICHA","MERISSA","MAURITA","MARYLN","MARYETTA","MARSHALL","MARCELL","MALENA","MAKEDA","MADDIE","LOVETTA","LOURIE","LORRINE","LORILEE","LESTER","LAURENA","LASHAY","LARRAINE","LAREE","LACRESHA","KRISTLE","KRISHNA","KEVA","KEIRA","KAROLE","JOIE","JINNY","JEANNETTA","JAMA","HEIDY","GILBERTE","GEMA","FAVIOLA","EVELYNN","ENDA","ELLI","ELLENA","DIVINA","DAGNY","COLLENE","CODI","CINDIE","CHASSIDY","CHASIDY","CATRICE","CATHERINA","CASSEY","CAROLL","CARLENA","CANDRA","CALISTA","BRYANNA","BRITTENY","BEULA","BARI","AUDRIE","AUDRIA","ARDELIA","ANNELLE","ANGILA","ALONA","ALLYN","DOUGLAS","ROGER","JONATHAN","RALPH","NICHOLAS","BENJAMIN","BRUCE","HARRY","WAYNE","STEVE","HOWARD","ERNEST","PHILLIP","TODD","CRAIG","ALAN","PHILIP","EARL","DANNY","BRYAN","STANLEY","LEONARD","NATHAN","MANUEL","RODNEY","MARVIN","VINCENT","JEFFERY","JEFF","CHAD","JACOB","ALFRED","BRADLEY","HERBERT","FREDERICK","EDWIN","DON","RICKY","RANDALL","BARRY","BERNARD","LEROY","MARCUS","THEODORE","CLIFFORD","MIGUEL","JIM","TOM","CALVIN","BILL","LLOYD","DEREK","WARREN","DARRELL","JEROME","FLOYD","ALVIN","TIM","GORDON","GREG","JORGE","DUSTIN","PEDRO","DERRICK","ZACHARY","HERMAN","GLEN","HECTOR","RICARDO","RICK","BRENT","RAMON","GILBERT","MARC","REGINALD","RUBEN","NATHANIEL","RAFAEL","EDGAR","MILTON","RAUL","BEN","CHESTER","DUANE","FRANKLIN","BRAD","RON","ROLAND","ARNOLD","HARVEY","JARED","ERIK","DARRYL","NEIL","JAVIER","FERNANDO","CLINTON","TED","MATHEW","TYRONE","DARREN","LANCE","KURT","ALLAN","NELSON","GUY","CLAYTON","HUGH","MAX","DWAYNE","DWIGHT","ARMANDO","FELIX","EVERETT","IAN","WALLACE","KEN","BOB","ALFREDO","ALBERTO","DAVE","IVAN","BYRON","ISAAC","MORRIS","CLIFTON","WILLARD","ROSS","ANDY","SALVADOR","KIRK","SERGIO","SETH","KENT","TERRANCE","EDUARDO","TERRENCE","ENRIQUE","WADE","STUART","FREDRICK","ARTURO","ALEJANDRO","NICK","LUTHER","WENDELL","JEREMIAH","JULIUS","OTIS","TREVOR","OLIVER","LUKE","HOMER","GERARD","DOUG","KENNY","HUBERT","LYLE","MATT","ALFONSO","ORLANDO","REX","CARLTON","ERNESTO","NEAL","PABLO","LORENZO","OMAR","WILBUR","GRANT","HORACE","RODERICK","ABRAHAM","WILLIS","RICKEY","ANDRES","CESAR","JOHNATHAN","MALCOLM","RUDOLPH","DAMON","KELVIN","PRESTON","ALTON","ARCHIE","MARCO","WM","PETE","RANDOLPH","GARRY","GEOFFREY","JONATHON","FELIPE","GERARDO","ED","DOMINIC","DELBERT","COLIN","GUILLERMO","EARNEST","LUCAS","BENNY","SPENCER","RODOLFO","MYRON","EDMUND","GARRETT","SALVATORE","CEDRIC","LOWELL","GREGG","SHERMAN","WILSON","SYLVESTER","ROOSEVELT","ISRAEL","JERMAINE","FORREST","WILBERT","LELAND","SIMON","CLARK","IRVING","BRYANT","OWEN","RUFUS","WOODROW","KRISTOPHER","MACK","LEVI","MARCOS","GUSTAVO","JAKE","LIONEL","GILBERTO","CLINT","NICOLAS","ISMAEL","ORVILLE","ERVIN","DEWEY","AL","WILFRED","JOSH","HUGO","IGNACIO","CALEB","TOMAS","SHELDON","ERICK","STEWART","DOYLE","DARREL","ROGELIO","TERENCE","SANTIAGO","ALONZO","ELIAS","BERT","ELBERT","RAMIRO","CONRAD","NOAH","GRADY","PHIL","CORNELIUS","LAMAR","ROLANDO","CLAY","PERCY","DEXTER","BRADFORD","DARIN","AMOS","MOSES","IRVIN","SAUL","ROMAN","RANDAL","TIMMY","DARRIN","WINSTON","BRENDAN","ABEL","DOMINICK","BOYD","EMILIO","ELIJAH","DOMINGO","EMMETT","MARLON","EMANUEL","JERALD","EDMOND","EMIL","DEWAYNE","WILL","OTTO","TEDDY","REYNALDO","BRET","JESS","TRENT","HUMBERTO","EMMANUEL","STEPHAN","VICENTE","LAMONT","GARLAND","MILES","EFRAIN","HEATH","RODGER","HARLEY","ETHAN","ELDON","ROCKY","PIERRE","JUNIOR","FREDDY","ELI","BRYCE","ANTOINE","STERLING","CHASE","GROVER","ELTON","CLEVELAND","DYLAN","CHUCK","DAMIAN","REUBEN","STAN","AUGUST","LEONARDO","JASPER","RUSSEL","ERWIN","BENITO","HANS","MONTE","BLAINE","ERNIE","CURT","QUENTIN","AGUSTIN","MURRAY","JAMAL","ADOLFO","HARRISON","TYSON","BURTON","BRADY","ELLIOTT","WILFREDO","BART","JARROD","VANCE","DENIS","DAMIEN","JOAQUIN","HARLAN","DESMOND","ELLIOT","DARWIN","GREGORIO","BUDDY","XAVIER","KERMIT","ROSCOE","ESTEBAN","ANTON","SOLOMON","SCOTTY","NORBERT","ELVIN","WILLIAMS","NOLAN","ROD","QUINTON","HAL","BRAIN","ROB","ELWOOD","KENDRICK","DARIUS","MOISES","FIDEL","THADDEUS","CLIFF","MARCEL","JACKSON","RAPHAEL","BRYON","ARMAND","ALVARO","JEFFRY","DANE","JOESPH","THURMAN","NED","RUSTY","MONTY","FABIAN","REGGIE","MASON","GRAHAM","ISAIAH","VAUGHN","GUS","LOYD","DIEGO","ADOLPH","NORRIS","MILLARD","ROCCO","GONZALO","DERICK","RODRIGO","WILEY","RIGOBERTO","ALPHONSO","TY","NOE","VERN","REED","JEFFERSON","ELVIS","BERNARDO","MAURICIO","HIRAM","DONOVAN","BASIL","RILEY","NICKOLAS","MAYNARD","SCOT","VINCE","QUINCY","EDDY","SEBASTIAN","FEDERICO","ULYSSES","HERIBERTO","DONNELL","COLE","DAVIS","GAVIN","EMERY","WARD","ROMEO","JAYSON","DANTE","CLEMENT","COY","MAXWELL","JARVIS","BRUNO","ISSAC","DUDLEY","BROCK","SANFORD","CARMELO","BARNEY","NESTOR","STEFAN","DONNY","ART","LINWOOD","BEAU","WELDON","GALEN","ISIDRO","TRUMAN","DELMAR","JOHNATHON","SILAS","FREDERIC","DICK","IRWIN","MERLIN","CHARLEY","MARCELINO","HARRIS","CARLO","TRENTON","KURTIS","HUNTER","AURELIO","WINFRED","VITO","COLLIN","DENVER","CARTER","LEONEL","EMORY","PASQUALE","MOHAMMAD","MARIANO","DANIAL","LANDON","DIRK","BRANDEN","ADAN","BUFORD","GERMAN","WILMER","EMERSON","ZACHERY","FLETCHER","JACQUES","ERROL","DALTON","MONROE","JOSUE","EDWARDO","BOOKER","WILFORD","SONNY","SHELTON","CARSON","THERON","RAYMUNDO","DAREN","HOUSTON","ROBBY","LINCOLN","GENARO","BENNETT","OCTAVIO","CORNELL","HUNG","ARRON","ANTONY","HERSCHEL","GIOVANNI","GARTH","CYRUS","CYRIL","RONNY","LON","FREEMAN","DUNCAN","KENNITH","CARMINE","ERICH","CHADWICK","WILBURN","RUSS","REID","MYLES","ANDERSON","MORTON","JONAS","FOREST","MITCHEL","MERVIN","ZANE","RICH","JAMEL","LAZARO","ALPHONSE","RANDELL","MAJOR","JARRETT","BROOKS","ABDUL","LUCIANO","SEYMOUR","EUGENIO","MOHAMMED","VALENTIN","CHANCE","ARNULFO","LUCIEN","FERDINAND","THAD","EZRA","ALDO","RUBIN","ROYAL","MITCH","EARLE","ABE","WYATT","MARQUIS","LANNY","KAREEM","JAMAR","BORIS","ISIAH","EMILE","ELMO","ARON","LEOPOLDO","EVERETTE","JOSEF","ELOY","RODRICK","REINALDO","LUCIO","JERROD","WESTON","HERSHEL","BARTON","PARKER","LEMUEL","BURT","JULES","GIL","ELISEO","AHMAD","NIGEL","EFREN","ANTWAN","ALDEN","MARGARITO","COLEMAN","DINO","OSVALDO","LES","DEANDRE","NORMAND","KIETH","TREY","NORBERTO","NAPOLEON","JEROLD","FRITZ","ROSENDO","MILFORD","CHRISTOPER","ALFONZO","LYMAN","JOSIAH","BRANT","WILTON","RICO","JAMAAL","DEWITT","BRENTON","OLIN","FOSTER","FAUSTINO","CLAUDIO","JUDSON","GINO","EDGARDO","ALEC","TANNER","JARRED","DONN","TAD","PRINCE","PORFIRIO","ODIS","LENARD","CHAUNCEY","TOD","MEL","MARCELO","KORY","AUGUSTUS","KEVEN","HILARIO","BUD","SAL","ORVAL","MAURO","ZACHARIAH","OLEN","ANIBAL","MILO","JED","DILLON","AMADO","NEWTON","LENNY","RICHIE","HORACIO","BRICE","MOHAMED","DELMER","DARIO","REYES","MAC","JONAH","JERROLD","ROBT","HANK","RUPERT","ROLLAND","KENTON","DAMION","ANTONE","WALDO","FREDRIC","BRADLY","KIP","BURL","WALKER","TYREE","JEFFEREY","AHMED","WILLY","STANFORD","OREN","NOBLE","MOSHE","MIKEL","ENOCH","BRENDON","QUINTIN","JAMISON","FLORENCIO","DARRICK","TOBIAS","HASSAN","GIUSEPPE","DEMARCUS","CLETUS","TYRELL","LYNDON","KEENAN","WERNER","GERALDO","COLUMBUS","CHET","BERTRAM","MARKUS","HUEY","HILTON","DWAIN","DONTE","TYRON","OMER","ISAIAS","HIPOLITO","FERMIN","ADALBERTO","BO","BARRETT","TEODORO","MCKINLEY","MAXIMO","GARFIELD","RALEIGH","LAWERENCE","ABRAM","RASHAD","KING","EMMITT","DARON","SAMUAL","MIQUEL","EUSEBIO","DOMENIC","DARRON","BUSTER","WILBER","RENATO","JC","HOYT","HAYWOOD","EZEKIEL","CHAS","FLORENTINO","ELROY","CLEMENTE","ARDEN","NEVILLE","EDISON","DESHAWN","NATHANIAL","JORDON","DANILO","CLAUD","SHERWOOD","RAYMON","RAYFORD","CRISTOBAL","AMBROSE","TITUS","HYMAN","FELTON","EZEQUIEL","ERASMO","STANTON","LONNY","LEN","IKE","MILAN","LINO","JAROD","HERB","ANDREAS","WALTON","RHETT","PALMER","DOUGLASS","CORDELL","OSWALDO","ELLSWORTH","VIRGILIO","TONEY","NATHANAEL","DEL","BENEDICT","MOSE","JOHNSON","ISREAL","GARRET","FAUSTO","ASA","ARLEN","ZACK","WARNER","MODESTO","FRANCESCO","MANUAL","GAYLORD","GASTON","FILIBERTO","DEANGELO","MICHALE","GRANVILLE","WES","MALIK","ZACKARY","TUAN","ELDRIDGE","CRISTOPHER","CORTEZ","ANTIONE","MALCOM","LONG","KOREY","JOSPEH","COLTON","WAYLON","VON","HOSEA","SHAD","SANTO","RUDOLF","ROLF","REY","RENALDO","MARCELLUS","LUCIUS","KRISTOFER","BOYCE","BENTON","HAYDEN","HARLAND","ARNOLDO","RUEBEN","LEANDRO","KRAIG","JERRELL","JEROMY","HOBERT","CEDRICK","ARLIE","WINFORD","WALLY","LUIGI","KENETH","JACINTO","GRAIG","FRANKLYN","EDMUNDO","SID","PORTER","LEIF","JERAMY","BUCK","WILLIAN","VINCENZO","SHON","LYNWOOD","JERE","HAI","ELDEN","DORSEY","DARELL","BRODERICK","ALONSO"
"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH","JENNIFER","MARIA","SUSAN","MARGARET","DOROTHY","LISA","NANCY","KAREN","BETTY","HELEN","SANDRA","DONNA","CAROL","RUTH","SHARON","MICHELLE","LAURA","SARAH","KIMBERLY","DEBORAH","JESSICA","SHIRLEY","CYNTHIA","ANGELA","MELISSA","BRENDA","AMY","ANNA","REBECCA","VIRGINIA","KATHLEEN","PAMELA","MARTHA","DEBRA","AMANDA","STEPHANIE","CAROLYN","CHRISTINE","MARIE","JANET","CATHERINE","FRANCES","ANN","JOYCE","DIANE","ALICE","JULIE","HEATHER","TERESA","DORIS","GLORIA","EVELYN","JEAN","CHERYL","MILDRED","KATHERINE","JOAN","ASHLEY","JUDITH","ROSE","JANICE","KELLY","NICOLE","JUDY","CHRISTINA","KATHY","THERESA","BEVERLY","DENISE","TAMMY","IRENE","JANE","LORI","RACHEL","MARILYN","ANDREA","KATHRYN","LOUISE","SARA","ANNE","JACQUELINE","WANDA","BONNIE","JULIA","RUBY","LOIS","TINA","PHYLLIS","NORMA","PAULA","DIANA","ANNIE","LILLIAN","EMILY","ROBIN","PEGGY","CRYSTAL","GLADYS","RITA","DAWN","CONNIE","FLORENCE","TRACY","EDNA","TIFFANY","CARMEN","ROSA","CINDY","GRACE","WENDY","VICTORIA","EDITH","KIM","SHERRY","SYLVIA","JOSEPHINE","THELMA","SHANNON","SHEILA","ETHEL","ELLEN","ELAINE","MARJORIE","CARRIE","CHARLOTTE","MONICA","ESTHER","PAULINE","EMMA","JUANITA","ANITA","RHONDA","HAZEL","AMBER","EVA","DEBBIE","APRIL","LESLIE","CLARA","LUCILLE","JAMIE","JOANNE","ELEANOR","VALERIE","DANIELLE","MEGAN","ALICIA","SUZANNE","MICHELE","GAIL","BERTHA","DARLENE","VERONICA","JILL","ERIN","GERALDINE","LAUREN","CATHY","JOANN","LORRAINE","LYNN","SALLY","REGINA","ERICA","BEATRICE","DOLORES","BERNICE","AUDREY","YVONNE","ANNETTE","JUNE","SAMANTHA","MARION","DANA","STACY","ANA","RENEE","IDA","VIVIAN","ROBERTA","HOLLY","BRITTANY","MELANIE","LORETTA","YOLANDA","JEANETTE","LAURIE","KATIE","KRISTEN","VANESSA","ALMA","SUE","ELSIE","BETH","JEANNE","VICKI","CARLA","TARA","ROSEMARY","EILEEN","TERRI","GERTRUDE","LUCY","TONYA","ELLA","STACEY","WILMA","GINA","KRISTIN","JESSIE","NATALIE","AGNES","VERA","WILLIE","CHARLENE","BESSIE","DELORES","MELINDA","PEARL","ARLENE","MAUREEN","COLLEEN","ALLISON","TAMARA","JOY","GEORGIA","CONSTANCE","LILLIE","CLAUDIA","JACKIE","MARCIA","TANYA","NELLIE","MINNIE","MARLENE","HEIDI","GLENDA","LYDIA","VIOLA","COURTNEY","MARIAN","STELLA","CAROLINE","DORA","JO","VICKIE","MATTIE","TERRY","MAXINE","IRMA","MABEL","MARSHA","MYRTLE","LENA","CHRISTY","DEANNA","PATSY","HILDA","GWENDOLYN","JENNIE","NORA","MARGIE","NINA","CASSANDRA","LEAH","PENNY","KAY","PRISCILLA","NAOMI","CAROLE","BRANDY","OLGA","BILLIE","DIANNE","TRACEY","LEONA","JENNY","FELICIA","SONIA","MIRIAM","VELMA","BECKY","BOBBIE","VIOLET","KRISTINA","TONI","MISTY","MAE","SHELLY","DAISY","RAMONA","SHERRI","ERIKA","KATRINA","CLAIRE","LINDSEY","LINDSAY","GENEVA","GUADALUPE","BELINDA","MARGARITA","SHERYL","CORA","FAYE","ADA","NATASHA","SABRINA","ISABEL","MARGUERITE","HATTIE","HARRIET","MOLLY","CECILIA","KRISTI","BRANDI","BLANCHE","SANDY","ROSIE","JOANNA","IRIS","EUNICE","ANGIE","INEZ","LYNDA","MADELINE","AMELIA","ALBERTA","GENEVIEVE","MONIQUE","JODI","JANIE","MAGGIE","KAYLA","SONYA","JAN","LEE","KRISTINE","CANDACE","FANNIE","MARYANN","OPAL","ALISON","YVETTE","MELODY","LUZ","SUSIE","OLIVIA","FLORA","SHELLEY","KRISTY","MAMIE","LULA","LOLA","VERNA","BEULAH","ANTOINETTE","CANDICE","JUANA","JEANNETTE","PAM","KELLI","HANNAH","WHITNEY","BRIDGET","KARLA","CELIA","LATOYA","PATTY","SHELIA","GAYLE","DELLA","VICKY","LYNNE","SHERI","MARIANNE","KARA","JACQUELYN","ERMA","BLANCA","MYRA","LETICIA","PAT","KRISTA","ROXANNE","ANGELICA","JOHNNIE","ROBYN","FRANCIS","ADRIENNE","ROSALIE","ALEXANDRA","BROOKE","BETHANY","SADIE","BERNADETTE","TRACI","JODY","KENDRA","JASMINE","NICHOLE","RACHAEL","CHELSEA","MABLE","ERNESTINE","MURIEL","MARCELLA","ELENA","KRYSTAL","ANGELINA","NADINE","KARI","ESTELLE","DIANNA","PAULETTE","LORA","MONA","DOREEN","ROSEMARIE","ANGEL","DESIREE","ANTONIA","HOPE","GINGER","JANIS","BETSY","CHRISTIE","FREDA","MERCEDES","MEREDITH","LYNETTE","TERI","CRISTINA","EULA","LEIGH","MEGHAN","SOPHIA","ELOISE","ROCHELLE","GRETCHEN","CECELIA","RAQUEL","HENRIETTA","ALYSSA","JANA","KELLEY","GWEN","KERRY","JENNA","TRICIA","LAVERNE","OLIVE","ALEXIS","TASHA","SILVIA","ELVIRA","CASEY","DELIA","SOPHIE","KATE","PATTI","LORENA","KELLIE","SONJA","LILA","LANA","DARLA","MAY","MINDY","ESSIE","MANDY","LORENE","ELSA","JOSEFINA","JEANNIE","MIRANDA","DIXIE","LUCIA","MARTA","FAITH","LELA","JOHANNA","SHARI","CAMILLE","TAMI","SHAWNA","ELISA","EBONY","MELBA","ORA","NETTIE","TABITHA","OLLIE","JAIME","WINIFRED","KRISTIE","MARINA","ALISHA","AIMEE","RENA","MYRNA","MARLA","TAMMIE","LATASHA","BONITA","PATRICE","RONDA","SHERRIE","ADDIE","FRANCINE","DELORIS","STACIE","ADRIANA","CHERI","SHELBY","ABIGAIL","CELESTE","JEWEL","CARA","ADELE","REBEKAH","LUCINDA","DORTHY","CHRIS","EFFIE","TRINA","REBA","SHAWN","SALLIE","AURORA","LENORA","ETTA","LOTTIE","KERRI","TRISHA","NIKKI","ESTELLA","FRANCISCA","JOSIE","TRACIE","MARISSA","KARIN","BRITTNEY","JANELLE","LOURDES","LAUREL","HELENE","FERN","ELVA","CORINNE","KELSEY","INA","BETTIE","ELISABETH","AIDA","CAITLIN","INGRID","IVA","EUGENIA","CHRISTA","GOLDIE","CASSIE","MAUDE","JENIFER","THERESE","FRANKIE","DENA","LORNA","JANETTE","LATONYA","CANDY","MORGAN","CONSUELO","TAMIKA","ROSETTA","DEBORA","CHERIE","POLLY","DINA","JEWELL","FAY","JILLIAN","DOROTHEA","NELL","TRUDY","ESPERANZA","PATRICA","KIMBERLEY","SHANNA","HELENA","CAROLINA","CLEO","STEFANIE","ROSARIO","OLA","JANINE","MOLLIE","LUPE","ALISA","LOU","MARIBEL","SUSANNE","BETTE","SUSANA","ELISE","CECILE","ISABELLE","LESLEY","JOCELYN","PAIGE","JONI","RACHELLE","LEOLA","DAPHNE","ALTA","ESTER","PETRA","GRACIELA","IMOGENE","JOLENE","KEISHA","LACEY","GLENNA","GABRIELA","KERI","URSULA","LIZZIE","KIRSTEN","SHANA","ADELINE","MAYRA","JAYNE","JACLYN","GRACIE","SONDRA","CARMELA","MARISA","ROSALIND","CHARITY","TONIA","BEATRIZ","MARISOL","CLARICE","JEANINE","SHEENA","ANGELINE","FRIEDA","LILY","ROBBIE","SHAUNA","MILLIE","CLAUDETTE","CATHLEEN","ANGELIA","GABRIELLE","AUTUMN","KATHARINE","SUMMER","JODIE","STACI","LEA","CHRISTI","JIMMIE","JUSTINE","ELMA","LUELLA","MARGRET","DOMINIQUE","SOCORRO","RENE","MARTINA","MARGO","MAVIS","CALLIE","BOBBI","MARITZA","LUCILE","LEANNE","JEANNINE","DEANA","AILEEN","LORIE","LADONNA","WILLA","MANUELA","GALE","SELMA","DOLLY","SYBIL","ABBY","LARA","DALE","IVY","DEE","WINNIE","MARCY","LUISA","JERI","MAGDALENA","OFELIA","MEAGAN","AUDRA","MATILDA","LEILA","CORNELIA","BIANCA","SIMONE","BETTYE","RANDI","VIRGIE","LATISHA","BARBRA","GEORGINA","ELIZA","LEANN","BRIDGETTE","RHODA","HALEY","ADELA","NOLA","BERNADINE","FLOSSIE","ILA","GRETA","RUTHIE","NELDA","MINERVA","LILLY","TERRIE","LETHA","HILARY","ESTELA","VALARIE","BRIANNA","ROSALYN","EARLINE","CATALINA","AVA","MIA","CLARISSA","LIDIA","CORRINE","ALEXANDRIA","CONCEPCION","TIA","SHARRON","RAE","DONA","ERICKA","JAMI","ELNORA","CHANDRA","LENORE","NEVA","MARYLOU","MELISA","TABATHA","SERENA","AVIS","ALLIE","SOFIA","JEANIE","ODESSA","NANNIE","HARRIETT","LORAINE","PENELOPE","MILAGROS","EMILIA","BENITA","ALLYSON","ASHLEE","TANIA","TOMMIE","ESMERALDA","KARINA","EVE","PEARLIE","ZELMA","MALINDA","NOREEN","TAMEKA","SAUNDRA","HILLARY","AMIE","ALTHEA","ROSALINDA","JORDAN","LILIA","ALANA","GAY","CLARE","ALEJANDRA","ELINOR","MICHAEL","LORRIE","JERRI","DARCY","EARNESTINE","CARMELLA","TAYLOR","NOEMI","MARCIE","LIZA","ANNABELLE","LOUISA","EARLENE","MALLORY","CARLENE","NITA","SELENA","TANISHA","KATY","JULIANNE","JOHN","LAKISHA","EDWINA","MARICELA","MARGERY","KENYA","DOLLIE","ROXIE","ROSLYN","KATHRINE","NANETTE","CHARMAINE","LAVONNE","ILENE","KRIS","TAMMI","SUZETTE","CORINE","KAYE","JERRY","MERLE","CHRYSTAL","LINA","DEANNE","LILIAN","JULIANA","ALINE","LUANN","KASEY","MARYANNE","EVANGELINE","COLETTE","MELVA","LAWANDA","YESENIA","NADIA","MADGE","KATHIE","EDDIE","OPHELIA","VALERIA","NONA","MITZI","MARI","GEORGETTE","CLAUDINE","FRAN","ALISSA","ROSEANN","LAKEISHA","SUSANNA","REVA","DEIDRE","CHASITY","SHEREE","CARLY","JAMES","ELVIA","ALYCE","DEIRDRE","GENA","BRIANA","ARACELI","KATELYN","ROSANNE","WENDI","TESSA","BERTA","MARVA","IMELDA","MARIETTA","MARCI","LEONOR","ARLINE","SASHA","MADELYN","JANNA","JULIETTE","DEENA","AURELIA","JOSEFA","AUGUSTA","LILIANA","YOUNG","CHRISTIAN","LESSIE","AMALIA","SAVANNAH","ANASTASIA","VILMA","NATALIA","ROSELLA","LYNNETTE","CORINA","ALFREDA","LEANNA","CAREY","AMPARO","COLEEN","TAMRA","AISHA","WILDA","KARYN","CHERRY","QUEEN","MAURA","MAI","EVANGELINA","ROSANNA","HALLIE","ERNA","ENID","MARIANA","LACY","JULIET","JACKLYN","FREIDA","MADELEINE","MARA","HESTER","CATHRYN","LELIA","CASANDRA","BRIDGETT","ANGELITA","JANNIE","DIONNE","ANNMARIE","KATINA","BERYL","PHOEBE","MILLICENT","KATHERYN","DIANN","CARISSA","MARYELLEN","LIZ","LAURI","HELGA","GILDA","ADRIAN","RHEA","MARQUITA","HOLLIE","TISHA","TAMERA","ANGELIQUE","FRANCESCA","BRITNEY","KAITLIN","LOLITA","FLORINE","ROWENA","REYNA","TWILA","FANNY","JANELL","INES","CONCETTA","BERTIE","ALBA","BRIGITTE","ALYSON","VONDA","PANSY","ELBA","NOELLE","LETITIA","KITTY","DEANN","BRANDIE","LOUELLA","LETA","FELECIA","SHARLENE","LESA","BEVERLEY","ROBERT","ISABELLA","HERMINIA","TERRA","CELINA","TORI","OCTAVIA","JADE","DENICE","GERMAINE","SIERRA","MICHELL","CORTNEY","NELLY","DORETHA","SYDNEY","DEIDRA","MONIKA","LASHONDA","JUDI","CHELSEY","ANTIONETTE","MARGOT","BOBBY","ADELAIDE","NAN","LEEANN","ELISHA","DESSIE","LIBBY","KATHI","GAYLA","LATANYA","MINA","MELLISA","KIMBERLEE","JASMIN","RENAE","ZELDA","ELDA","MA","JUSTINA","GUSSIE","EMILIE","CAMILLA","ABBIE","ROCIO","KAITLYN","JESSE","EDYTHE","ASHLEIGH","SELINA","LAKESHA","GERI","ALLENE","PAMALA","MICHAELA","DAYNA","CARYN","ROSALIA","SUN","JACQULINE","REBECA","MARYBETH","KRYSTLE","IOLA","DOTTIE","BENNIE","BELLE","AUBREY","GRISELDA","ERNESTINA","ELIDA","ADRIANNE","DEMETRIA","DELMA","CHONG","JAQUELINE","DESTINY","ARLEEN","VIRGINA","RETHA","FATIMA","TILLIE","ELEANORE","CARI","TREVA","BIRDIE","WILHELMINA","ROSALEE","MAURINE","LATRICE","YONG","JENA","TARYN","ELIA","DEBBY","MAUDIE","JEANNA","DELILAH","CATRINA","SHONDA","HORTENCIA","THEODORA","TERESITA","ROBBIN","DANETTE","MARYJANE","FREDDIE","DELPHINE","BRIANNE","NILDA","DANNA","CINDI","BESS","IONA","HANNA","ARIEL","WINONA","VIDA","ROSITA","MARIANNA","WILLIAM","RACHEAL","GUILLERMINA","ELOISA","CELESTINE","CAREN","MALISSA","LONA","CHANTEL","SHELLIE","MARISELA","LEORA","AGATHA","SOLEDAD","MIGDALIA","IVETTE","CHRISTEN","ATHENA","JANEL","CHLOE","VEDA","PATTIE","TESSIE","TERA","MARILYNN","LUCRETIA","KARRIE","DINAH","DANIELA","ALECIA","ADELINA","VERNICE","SHIELA","PORTIA","MERRY","LASHAWN","DEVON","DARA","TAWANA","OMA","VERDA","CHRISTIN","ALENE","ZELLA","SANDI","RAFAELA","MAYA","KIRA","CANDIDA","ALVINA","SUZAN","SHAYLA","LYN","LETTIE","ALVA","SAMATHA","ORALIA","MATILDE","MADONNA","LARISSA","VESTA","RENITA","INDIA","DELOIS","SHANDA","PHILLIS","LORRI","ERLINDA","CRUZ","CATHRINE","BARB","ZOE","ISABELL","IONE","GISELA","CHARLIE","VALENCIA","ROXANNA","MAYME","KISHA","ELLIE","MELLISSA","DORRIS","DALIA","BELLA","ANNETTA","ZOILA","RETA","REINA","LAURETTA","KYLIE","CHRISTAL","PILAR","CHARLA","ELISSA","TIFFANI","TANA","PAULINA","LEOTA","BREANNA","JAYME","CARMEL","VERNELL","TOMASA","MANDI","DOMINGA","SANTA","MELODIE","LURA","ALEXA","TAMELA","RYAN","MIRNA","KERRIE","VENUS","NOEL","FELICITA","CRISTY","CARMELITA","BERNIECE","ANNEMARIE","TIARA","ROSEANNE","MISSY","CORI","ROXANA","PRICILLA","KRISTAL","JUNG","ELYSE","HAYDEE","ALETHA","BETTINA","MARGE","GILLIAN","FILOMENA","CHARLES","ZENAIDA","HARRIETTE","CARIDAD","VADA","UNA","ARETHA","PEARLINE","MARJORY","MARCELA","FLOR","EVETTE","ELOUISE","ALINA","TRINIDAD","DAVID","DAMARIS","CATHARINE","CARROLL","BELVA","NAKIA","MARLENA","LUANNE","LORINE","KARON","DORENE","DANITA","BRENNA","TATIANA","SAMMIE","LOUANN","LOREN","JULIANNA","ANDRIA","PHILOMENA","LUCILA","LEONORA","DOVIE","ROMONA","MIMI","JACQUELIN","GAYE","TONJA","MISTI","JOE","GENE","CHASTITY","STACIA","ROXANN","MICAELA","NIKITA","MEI","VELDA","MARLYS","JOHNNA","AURA","LAVERN","IVONNE","HAYLEY","NICKI","MAJORIE","HERLINDA","GEORGE","ALPHA","YADIRA","PERLA","GREGORIA","DANIEL","ANTONETTE","SHELLI","MOZELLE","MARIAH","JOELLE","CORDELIA","JOSETTE","CHIQUITA","TRISTA","LOUIS","LAQUITA","GEORGIANA","CANDI","SHANON","LONNIE","HILDEGARD","CECIL","VALENTINA","STEPHANY","MAGDA","KAROL","GERRY","GABRIELLA","TIANA","ROMA","RICHELLE","RAY","PRINCESS","OLETA","JACQUE","IDELLA","ALAINA","SUZANNA","JOVITA","BLAIR","TOSHA","RAVEN","NEREIDA","MARLYN","KYLA","JOSEPH","DELFINA","TENA","STEPHENIE","SABINA","NATHALIE","MARCELLE","GERTIE","DARLEEN","THEA","SHARONDA","SHANTEL","BELEN","VENESSA","ROSALINA","ONA","GENOVEVA","COREY","CLEMENTINE","ROSALBA","RENATE","RENATA","MI","IVORY","GEORGIANNA","FLOY","DORCAS","ARIANA","TYRA","THEDA","MARIAM","JULI","JESICA","DONNIE","VIKKI","VERLA","ROSELYN","MELVINA","JANNETTE","GINNY","DEBRAH","CORRIE","ASIA","VIOLETA","MYRTIS","LATRICIA","COLLETTE","CHARLEEN","ANISSA","VIVIANA","TWYLA","PRECIOUS","NEDRA","LATONIA","LAN","HELLEN","FABIOLA","ANNAMARIE","ADELL","SHARYN","CHANTAL","NIKI","MAUD","LIZETTE","LINDY","KIA","KESHA","JEANA","DANELLE","CHARLINE","CHANEL","CARROL","VALORIE","LIA","DORTHA","CRISTAL","SUNNY","LEONE","LEILANI","GERRI","DEBI","ANDRA","KESHIA","IMA","EULALIA","EASTER","DULCE","NATIVIDAD","LINNIE","KAMI","GEORGIE","CATINA","BROOK","ALDA","WINNIFRED","SHARLA","RUTHANN","MEAGHAN","MAGDALENE","LISSETTE","ADELAIDA","VENITA","TRENA","SHIRLENE","SHAMEKA","ELIZEBETH","DIAN","SHANTA","MICKEY","LATOSHA","CARLOTTA","WINDY","SOON","ROSINA","MARIANN","LEISA","JONNIE","DAWNA","CATHIE","BILLY","ASTRID","SIDNEY","LAUREEN","JANEEN","HOLLI","FAWN","VICKEY","TERESSA","SHANTE","RUBYE","MARCELINA","CHANDA","CARY","TERESE","SCARLETT","MARTY","MARNIE","LULU","LISETTE","JENIFFER","ELENOR","DORINDA","DONITA","CARMAN","BERNITA","ALTAGRACIA","ALETA","ADRIANNA","ZORAIDA","RONNIE","NICOLA","LYNDSEY","KENDALL","JANINA","CHRISSY","AMI","STARLA","PHYLIS","PHUONG","KYRA","CHARISSE","BLANCH","SANJUANITA","RONA","NANCI","MARILEE","MARANDA","CORY","BRIGETTE","SANJUANA","MARITA","KASSANDRA","JOYCELYN","IRA","FELIPA","CHELSIE","BONNY","MIREYA","LORENZA","KYONG","ILEANA","CANDELARIA","TONY","TOBY","SHERIE","OK","MARK","LUCIE","LEATRICE","LAKESHIA","GERDA","EDIE","BAMBI","MARYLIN","LAVON","HORTENSE","GARNET","EVIE","TRESSA","SHAYNA","LAVINA","KYUNG","JEANETTA","SHERRILL","SHARA","PHYLISS","MITTIE","ANABEL","ALESIA","THUY","TAWANDA","RICHARD","JOANIE","TIFFANIE","LASHANDA","KARISSA","ENRIQUETA","DARIA","DANIELLA","CORINNA","ALANNA","ABBEY","ROXANE","ROSEANNA","MAGNOLIA","LIDA","KYLE","JOELLEN","ERA","CORAL","CARLEEN","TRESA","PEGGIE","NOVELLA","NILA","MAYBELLE","JENELLE","CARINA","NOVA","MELINA","MARQUERITE","MARGARETTE","JOSEPHINA","EVONNE","DEVIN","CINTHIA","ALBINA","TOYA","TAWNYA","SHERITA","SANTOS","MYRIAM","LIZABETH","LISE","KEELY","JENNI","GISELLE","CHERYLE","ARDITH","ARDIS","ALESHA","ADRIANE","SHAINA","LINNEA","KAROLYN","HONG","FLORIDA","FELISHA","DORI","DARCI","ARTIE","ARMIDA","ZOLA","XIOMARA","VERGIE","SHAMIKA","NENA","NANNETTE","MAXIE","LOVIE","JEANE","JAIMIE","INGE","FARRAH","ELAINA","CAITLYN","STARR","FELICITAS","CHERLY","CARYL","YOLONDA","YASMIN","TEENA","PRUDENCE","PENNIE","NYDIA","MACKENZIE","ORPHA","MARVEL","LIZBETH","LAURETTE","JERRIE","HERMELINDA","CAROLEE","TIERRA","MIRIAN","META","MELONY","KORI","JENNETTE","JAMILA","ENA","ANH","YOSHIKO","SUSANNAH","SALINA","RHIANNON","JOLEEN","CRISTINE","ASHTON","ARACELY","TOMEKA","SHALONDA","MARTI","LACIE","KALA","JADA","ILSE","HAILEY","BRITTANI","ZONA","SYBLE","SHERRYL","RANDY","NIDIA","MARLO","KANDICE","KANDI","DEB","DEAN","AMERICA","ALYCIA","TOMMY","RONNA","NORENE","MERCY","JOSE","INGEBORG","GIOVANNA","GEMMA","CHRISTEL","AUDRY","ZORA","VITA","VAN","TRISH","STEPHAINE","SHIRLEE","SHANIKA","MELONIE","MAZIE","JAZMIN","INGA","HOA","HETTIE","GERALYN","FONDA","ESTRELLA","ADELLA","SU","SARITA","RINA","MILISSA","MARIBETH","GOLDA","EVON","ETHELYN","ENEDINA","CHERISE","CHANA","VELVA","TAWANNA","SADE","MIRTA","LI","KARIE","JACINTA","ELNA","DAVINA","CIERRA","ASHLIE","ALBERTHA","TANESHA","STEPHANI","NELLE","MINDI","LU","LORINDA","LARUE","FLORENE","DEMETRA","DEDRA","CIARA","CHANTELLE","ASHLY","SUZY","ROSALVA","NOELIA","LYDA","LEATHA","KRYSTYNA","KRISTAN","KARRI","DARLINE","DARCIE","CINDA","CHEYENNE","CHERRIE","AWILDA","ALMEDA","ROLANDA","LANETTE","JERILYN","GISELE","EVALYN","CYNDI","CLETA","CARIN","ZINA","ZENA","VELIA","TANIKA","PAUL","CHARISSA","THOMAS","TALIA","MARGARETE","LAVONDA","KAYLEE","KATHLENE","JONNA","IRENA","ILONA","IDALIA","CANDIS","CANDANCE","BRANDEE","ANITRA","ALIDA","SIGRID","NICOLETTE","MARYJO","LINETTE","HEDWIG","CHRISTIANA","CASSIDY","ALEXIA","TRESSIE","MODESTA","LUPITA","LITA","GLADIS","EVELIA","DAVIDA","CHERRI","CECILY","ASHELY","ANNABEL","AGUSTINA","WANITA","SHIRLY","ROSAURA","HULDA","EUN","BAILEY","YETTA","VERONA","THOMASINA","SIBYL","SHANNAN","MECHELLE","LUE","LEANDRA","LANI","KYLEE","KANDY","JOLYNN","FERNE","EBONI","CORENE","ALYSIA","ZULA","NADA","MOIRA","LYNDSAY","LORRETTA","JUAN","JAMMIE","HORTENSIA","GAYNELL","CAMERON","ADRIA","VINA","VICENTA","TANGELA","STEPHINE","NORINE","NELLA","LIANA","LESLEE","KIMBERELY","ILIANA","GLORY","FELICA","EMOGENE","ELFRIEDE","EDEN","EARTHA","CARMA","BEA","OCIE","MARRY","LENNIE","KIARA","JACALYN","CARLOTA","ARIELLE","YU","STAR","OTILIA","KIRSTIN","KACEY","JOHNETTA","JOEY","JOETTA","JERALDINE","JAUNITA","ELANA","DORTHEA","CAMI","AMADA","ADELIA","VERNITA","TAMAR","SIOBHAN","RENEA","RASHIDA","OUIDA","ODELL","NILSA","MERYL","KRISTYN","JULIETA","DANICA","BREANNE","AUREA","ANGLEA","SHERRON","ODETTE","MALIA","LORELEI","LIN","LEESA","KENNA","KATHLYN","FIONA","CHARLETTE","SUZIE","SHANTELL","SABRA","RACQUEL","MYONG","MIRA","MARTINE","LUCIENNE","LAVADA","JULIANN","JOHNIE","ELVERA","DELPHIA","CLAIR","CHRISTIANE","CHAROLETTE","CARRI","AUGUSTINE","ASHA","ANGELLA","PAOLA","NINFA","LEDA","LAI","EDA","SUNSHINE","STEFANI","SHANELL","PALMA","MACHELLE","LISSA","KECIA","KATHRYNE","KARLENE","JULISSA","JETTIE","JENNIFFER","HUI","CORRINA","CHRISTOPHER","CAROLANN","ALENA","TESS","ROSARIA","MYRTICE","MARYLEE","LIANE","KENYATTA","JUDIE","JANEY","IN","ELMIRA","ELDORA","DENNA","CRISTI","CATHI","ZAIDA","VONNIE","VIVA","VERNIE","ROSALINE","MARIELA","LUCIANA","LESLI","KARAN","FELICE","DENEEN","ADINA","WYNONA","TARSHA","SHERON","SHASTA","SHANITA","SHANI","SHANDRA","RANDA","PINKIE","PARIS","NELIDA","MARILOU","LYLA","LAURENE","LACI","JOI","JANENE","DOROTHA","DANIELE","DANI","CAROLYNN","CARLYN","BERENICE","AYESHA","ANNELIESE","ALETHEA","THERSA","TAMIKO","RUFINA","OLIVA","MOZELL","MARYLYN","MADISON","KRISTIAN","KATHYRN","KASANDRA","KANDACE","JANAE","GABRIEL","DOMENICA","DEBBRA","DANNIELLE","CHUN","BUFFY","BARBIE","ARCELIA","AJA","ZENOBIA","SHAREN","SHAREE","PATRICK","PAGE","MY","LAVINIA","KUM","KACIE","JACKELINE","HUONG","FELISA","EMELIA","ELEANORA","CYTHIA","CRISTIN","CLYDE","CLARIBEL","CARON","ANASTACIA","ZULMA","ZANDRA","YOKO","TENISHA","SUSANN","SHERILYN","SHAY","SHAWANDA","SABINE","ROMANA","MATHILDA","LINSEY","KEIKO","JOANA","ISELA","GRETTA","GEORGETTA","EUGENIE","DUSTY","DESIRAE","DELORA","CORAZON","ANTONINA","ANIKA","WILLENE","TRACEE","TAMATHA","REGAN","NICHELLE","MICKIE","MAEGAN","LUANA","LANITA","KELSIE","EDELMIRA","BREE","AFTON","TEODORA","TAMIE","SHENA","MEG","LINH","KELI","KACI","DANYELLE","BRITT","ARLETTE","ALBERTINE","ADELLE","TIFFINY","STORMY","SIMONA","NUMBERS","NICOLASA","NICHOL","NIA","NAKISHA","MEE","MAIRA","LOREEN","KIZZY","JOHNNY","JAY","FALLON","CHRISTENE","BOBBYE","ANTHONY","YING","VINCENZA","TANJA","RUBIE","RONI","QUEENIE","MARGARETT","KIMBERLI","IRMGARD","IDELL","HILMA","EVELINA","ESTA","EMILEE","DENNISE","DANIA","CARL","CARIE","ANTONIO","WAI","SANG","RISA","RIKKI","PARTICIA","MUI","MASAKO","MARIO","LUVENIA","LOREE","LONI","LIEN","KEVIN","GIGI","FLORENCIA","DORIAN","DENITA","DALLAS","CHI","BILLYE","ALEXANDER","TOMIKA","SHARITA","RANA","NIKOLE","NEOMA","MARGARITE","MADALYN","LUCINA","LAILA","KALI","JENETTE","GABRIELE","EVELYNE","ELENORA","CLEMENTINA","ALEJANDRINA","ZULEMA","VIOLETTE","VANNESSA","THRESA","RETTA","PIA","PATIENCE","NOELLA","NICKIE","JONELL","DELTA","CHUNG","CHAYA","CAMELIA","BETHEL","ANYA","ANDREW","THANH","SUZANN","SPRING","SHU","MILA","LILLA","LAVERNA","KEESHA","KATTIE","GIA","GEORGENE","EVELINE","ESTELL","ELIZBETH","VIVIENNE","VALLIE","TRUDIE","STEPHANE","MICHEL","MAGALY","MADIE","KENYETTA","KARREN","JANETTA","HERMINE","HARMONY","DRUCILLA","DEBBI","CELESTINA","CANDIE","BRITNI","BECKIE","AMINA","ZITA","YUN","YOLANDE","VIVIEN","VERNETTA","TRUDI","SOMMER","PEARLE","PATRINA","OSSIE","NICOLLE","LOYCE","LETTY","LARISA","KATHARINA","JOSELYN","JONELLE","JENELL","IESHA","HEIDE","FLORINDA","FLORENTINA","FLO","ELODIA","DORINE","BRUNILDA","BRIGID","ASHLI","ARDELLA","TWANA","THU","TARAH","SUNG","SHEA","SHAVON","SHANE","SERINA","RAYNA","RAMONITA","NGA","MARGURITE","LUCRECIA","KOURTNEY","KATI","JESUS","JESENIA","DIAMOND","CRISTA","AYANA","ALICA","ALIA","VINNIE","SUELLEN","ROMELIA","RACHELL","PIPER","OLYMPIA","MICHIKO","KATHALEEN","JOLIE","JESSI","JANESSA","HANA","HA","ELEASE","CARLETTA","BRITANY","SHONA","SALOME","ROSAMOND","REGENA","RAINA","NGOC","NELIA","LOUVENIA","LESIA","LATRINA","LATICIA","LARHONDA","JINA","JACKI","HOLLIS","HOLLEY","EMMY","DEEANN","CORETTA","ARNETTA","VELVET","THALIA","SHANICE","NETA","MIKKI","MICKI","LONNA","LEANA","LASHUNDA","KILEY","JOYE","JACQULYN","IGNACIA","HYUN","HIROKO","HENRY","HENRIETTE","ELAYNE","DELINDA","DARNELL","DAHLIA","COREEN","CONSUELA","CONCHITA","CELINE","BABETTE","AYANNA","ANETTE","ALBERTINA","SKYE","SHAWNEE","SHANEKA","QUIANA","PAMELIA","MIN","MERRI","MERLENE","MARGIT","KIESHA","KIERA","KAYLENE","JODEE","JENISE","ERLENE","EMMIE","ELSE","DARYL","DALILA","DAISEY","CODY","CASIE","BELIA","BABARA","VERSIE","VANESA","SHELBA","SHAWNDA","SAM","NORMAN","NIKIA","NAOMA","MARNA","MARGERET","MADALINE","LAWANA","KINDRA","JUTTA","JAZMINE","JANETT","HANNELORE","GLENDORA","GERTRUD","GARNETT","FREEDA","FREDERICA","FLORANCE","FLAVIA","DENNIS","CARLINE","BEVERLEE","ANJANETTE","VALDA","TRINITY","TAMALA","STEVIE","SHONNA","SHA","SARINA","ONEIDA","MICAH","MERILYN","MARLEEN","LURLINE","LENNA","KATHERIN","JIN","JENI","HAE","GRACIA","GLADY","FARAH","ERIC","ENOLA","EMA","DOMINQUE","DEVONA","DELANA","CECILA","CAPRICE","ALYSHA","ALI","ALETHIA","VENA","THERESIA","TAWNY","SONG","SHAKIRA","SAMARA","SACHIKO","RACHELE","PAMELLA","NICKY","MARNI","MARIEL","MAREN","MALISA","LIGIA","LERA","LATORIA","LARAE","KIMBER","KATHERN","KAREY","JENNEFER","JANETH","HALINA","FREDIA","DELISA","DEBROAH","CIERA","CHIN","ANGELIKA","ANDREE","ALTHA","YEN","VIVAN","TERRESA","TANNA","SUK","SUDIE","SOO","SIGNE","SALENA","RONNI","REBBECCA","MYRTIE","MCKENZIE","MALIKA","MAIDA","LOAN","LEONARDA","KAYLEIGH","FRANCE","ETHYL","ELLYN","DAYLE","CAMMIE","BRITTNI","BIRGIT","AVELINA","ASUNCION","ARIANNA","AKIKO","VENICE","TYESHA","TONIE","TIESHA","TAKISHA","STEFFANIE","SINDY","SANTANA","MEGHANN","MANDA","MACIE","LADY","KELLYE","KELLEE","JOSLYN","JASON","INGER","INDIRA","GLINDA","GLENNIS","FERNANDA","FAUSTINA","ENEIDA","ELICIA","DOT","DIGNA","DELL","ARLETTA","ANDRE","WILLIA","TAMMARA","TABETHA","SHERRELL","SARI","REFUGIO","REBBECA","PAULETTA","NIEVES","NATOSHA","NAKITA","MAMMIE","KENISHA","KAZUKO","KASSIE","GARY","EARLEAN","DAPHINE","CORLISS","CLOTILDE","CAROLYNE","BERNETTA","AUGUSTINA","AUDREA","ANNIS","ANNABELL","YAN","TENNILLE","TAMICA","SELENE","SEAN","ROSANA","REGENIA","QIANA","MARKITA","MACY","LEEANNE","LAURINE","KYM","JESSENIA","JANITA","GEORGINE","GENIE","EMIKO","ELVIE","DEANDRA","DAGMAR","CORIE","COLLEN","CHERISH","ROMAINE","PORSHA","PEARLENE","MICHELINE","MERNA","MARGORIE","MARGARETTA","LORE","KENNETH","JENINE","HERMINA","FREDERICKA","ELKE","DRUSILLA","DORATHY","DIONE","DESIRE","CELENA","BRIGIDA","ANGELES","ALLEGRA","THEO","TAMEKIA","SYNTHIA","STEPHEN","SOOK","SLYVIA","ROSANN","REATHA","RAYE","MARQUETTA","MARGART","LING","LAYLA","KYMBERLY","KIANA","KAYLEEN","KATLYN","KARMEN","JOELLA","IRINA","EMELDA","ELENI","DETRA","CLEMMIE","CHERYLL","CHANTELL","CATHEY","ARNITA","ARLA","ANGLE","ANGELIC","ALYSE","ZOFIA","THOMASINE","TENNIE","SON","SHERLY","SHERLEY","SHARYL","REMEDIOS","PETRINA","NICKOLE","MYUNG","MYRLE","MOZELLA","LOUANNE","LISHA","LATIA","LANE","KRYSTA","JULIENNE","JOEL","JEANENE","JACQUALINE","ISAURA","GWENDA","EARLEEN","DONALD","CLEOPATRA","CARLIE","AUDIE","ANTONIETTA","ALISE","ALEX","VERDELL","VAL","TYLER","TOMOKO","THAO","TALISHA","STEVEN","SO","SHEMIKA","SHAUN","SCARLET","SAVANNA","SANTINA","ROSIA","RAEANN","ODILIA","NANA","MINNA","MAGAN","LYNELLE","LE","KARMA","JOEANN","IVANA","INELL","ILANA","HYE","HONEY","HEE","GUDRUN","FRANK","DREAMA","CRISSY","CHANTE","CARMELINA","ARVILLA","ARTHUR","ANNAMAE","ALVERA","ALEIDA","AARON","YEE","YANIRA","VANDA","TIANNA","TAM","STEFANIA","SHIRA","PERRY","NICOL","NANCIE","MONSERRATE","MINH","MELYNDA","MELANY","MATTHEW","LOVELLA","LAURE","KIRBY","KACY","JACQUELYNN","HYON","GERTHA","FRANCISCO","ELIANA","CHRISTENA","CHRISTEEN","CHARISE","CATERINA","CARLEY","CANDYCE","ARLENA","AMMIE","YANG","WILLETTE","VANITA","TUYET","TINY","SYREETA","SILVA","SCOTT","RONALD","PENNEY","NYLA","MICHAL","MAURICE","MARYAM","MARYA","MAGEN","LUDIE","LOMA","LIVIA","LANELL","KIMBERLIE","JULEE","DONETTA","DIEDRA","DENISHA","DEANE","DAWNE","CLARINE","CHERRYL","BRONWYN","BRANDON","ALLA","VALERY","TONDA","SUEANN","SORAYA","SHOSHANA","SHELA","SHARLEEN","SHANELLE","NERISSA","MICHEAL","MERIDITH","MELLIE","MAYE","MAPLE","MAGARET","LUIS","LILI","LEONILA","LEONIE","LEEANNA","LAVONIA","LAVERA","KRISTEL","KATHEY","KATHE","JUSTIN","JULIAN","JIMMY","JANN","ILDA","HILDRED","HILDEGARDE","GENIA","FUMIKO","EVELIN","ERMELINDA","ELLY","DUNG","DOLORIS","DIONNA","DANAE","BERNEICE","ANNICE","ALIX","VERENA","VERDIE","TRISTAN","SHAWNNA","SHAWANA","SHAUNNA","ROZELLA","RANDEE","RANAE","MILAGRO","LYNELL","LUISE","LOUIE","LOIDA","LISBETH","KARLEEN","JUNITA","JONA","ISIS","HYACINTH","HEDY","GWENN","ETHELENE","ERLINE","EDWARD","DONYA","DOMONIQUE","DELICIA","DANNETTE","CICELY","BRANDA","BLYTHE","BETHANN","ASHLYN","ANNALEE","ALLINE","YUKO","VELLA","TRANG","TOWANDA","TESHA","SHERLYN","NARCISA","MIGUELINA","MERI","MAYBELL","MARLANA","MARGUERITA","MADLYN","LUNA","LORY","LORIANN","LIBERTY","LEONORE","LEIGHANN","LAURICE","LATESHA","LARONDA","KATRICE","KASIE","KARL","KALEY","JADWIGA","GLENNIE","GEARLDINE","FRANCINA","EPIFANIA","DYAN","DORIE","DIEDRE","DENESE","DEMETRICE","DELENA","DARBY","CRISTIE","CLEORA","CATARINA","CARISA","BERNIE","BARBERA","ALMETA","TRULA","TEREASA","SOLANGE","SHEILAH","SHAVONNE","SANORA","ROCHELL","MATHILDE","MARGARETA","MAIA","LYNSEY","LAWANNA","LAUNA","KENA","KEENA","KATIA","JAMEY","GLYNDA","GAYLENE","ELVINA","ELANOR","DANUTA","DANIKA","CRISTEN","CORDIE","COLETTA","CLARITA","CARMON","BRYNN","AZUCENA","AUNDREA","ANGELE","YI","WALTER","VERLIE","VERLENE","TAMESHA","SILVANA","SEBRINA","SAMIRA","REDA","RAYLENE","PENNI","PANDORA","NORAH","NOMA","MIREILLE","MELISSIA","MARYALICE","LARAINE","KIMBERY","KARYL","KARINE","KAM","JOLANDA","JOHANA","JESUSA","JALEESA","JAE","JACQUELYNE","IRISH","ILUMINADA","HILARIA","HANH","GENNIE","FRANCIE","FLORETTA","EXIE","EDDA","DREMA","DELPHA","BEV","BARBAR","ASSUNTA","ARDELL","ANNALISA","ALISIA","YUKIKO","YOLANDO","WONDA","WEI","WALTRAUD","VETA","TEQUILA","TEMEKA","TAMEIKA","SHIRLEEN","SHENITA","PIEDAD","OZELLA","MIRTHA","MARILU","KIMIKO","JULIANE","JENICE","JEN","JANAY","JACQUILINE","HILDE","FE","FAE","EVAN","EUGENE","ELOIS","ECHO","DEVORAH","CHAU","BRINDA","BETSEY","ARMINDA","ARACELIS","APRYL","ANNETT","ALISHIA","VEOLA","USHA","TOSHIKO","THEOLA","TASHIA","TALITHA","SHERY","RUDY","RENETTA","REIKO","RASHEEDA","OMEGA","OBDULIA","MIKA","MELAINE","MEGGAN","MARTIN","MARLEN","MARGET","MARCELINE","MANA","MAGDALEN","LIBRADA","LEZLIE","LEXIE","LATASHIA","LASANDRA","KELLE","ISIDRA","ISA","INOCENCIA","GWYN","FRANCOISE","ERMINIA","ERINN","DIMPLE","DEVORA","CRISELDA","ARMANDA","ARIE","ARIANE","ANGELO","ANGELENA","ALLEN","ALIZA","ADRIENE","ADALINE","XOCHITL","TWANNA","TRAN","TOMIKO","TAMISHA","TAISHA","SUSY","SIU","RUTHA","ROXY","RHONA","RAYMOND","OTHA","NORIKO","NATASHIA","MERRIE","MELVIN","MARINDA","MARIKO","MARGERT","LORIS","LIZZETTE","LEISHA","KAILA","KA","JOANNIE","JERRICA","JENE","JANNET","JANEE","JACINDA","HERTA","ELENORE","DORETTA","DELAINE","DANIELL","CLAUDIE","CHINA","BRITTA","APOLONIA","AMBERLY","ALEASE","YURI","YUK","WEN","WANETA","UTE","TOMI","SHARRI","SANDIE","ROSELLE","REYNALDA","RAGUEL","PHYLICIA","PATRIA","OLIMPIA","ODELIA","MITZIE","MITCHELL","MISS","MINDA","MIGNON","MICA","MENDY","MARIVEL","MAILE","LYNETTA","LAVETTE","LAURYN","LATRISHA","LAKIESHA","KIERSTEN","KARY","JOSPHINE","JOLYN","JETTA","JANISE","JACQUIE","IVELISSE","GLYNIS","GIANNA","GAYNELLE","EMERALD","DEMETRIUS","DANYELL","DANILLE","DACIA","CORALEE","CHER","CEOLA","BRETT","BELL","ARIANNE","ALESHIA","YUNG","WILLIEMAE","TROY","TRINH","THORA","TAI","SVETLANA","SHERIKA","SHEMEKA","SHAUNDA","ROSELINE","RICKI","MELDA","MALLIE","LAVONNA","LATINA","LARRY","LAQUANDA","LALA","LACHELLE","KLARA","KANDIS","JOHNA","JEANMARIE","JAYE","HANG","GRAYCE","GERTUDE","EMERITA","EBONIE","CLORINDA","CHING","CHERY","CAROLA","BREANN","BLOSSOM","BERNARDINE","BECKI","ARLETHA","ARGELIA","ARA","ALITA","YULANDA","YON","YESSENIA","TOBI","TASIA","SYLVIE","SHIRL","SHIRELY","SHERIDAN","SHELLA","SHANTELLE","SACHA","ROYCE","REBECKA","REAGAN","PROVIDENCIA","PAULENE","MISHA","MIKI","MARLINE","MARICA","LORITA","LATOYIA","LASONYA","KERSTIN","KENDA","KEITHA","KATHRIN","JAYMIE","JACK","GRICELDA","GINETTE","ERYN","ELINA","ELFRIEDA","DANYEL","CHEREE","CHANELLE","BARRIE","AVERY","AURORE","ANNAMARIA","ALLEEN","AILENE","AIDE","YASMINE","VASHTI","VALENTINE","TREASA","TORY","TIFFANEY","SHERYLL","SHARIE","SHANAE","SAU","RAISA","PA","NEDA","MITSUKO","MIRELLA","MILDA","MARYANNA","MARAGRET","MABELLE","LUETTA","LORINA","LETISHA","LATARSHA","LANELLE","LAJUANA","KRISSY","KARLY","KARENA","JON","JESSIKA","JERICA","JEANELLE","JANUARY","JALISA","JACELYN","IZOLA","IVEY","GREGORY","EUNA","ETHA","DREW","DOMITILA","DOMINICA","DAINA","CREOLA","CARLI","CAMIE","BUNNY","BRITTNY","ASHANTI","ANISHA","ALEEN","ADAH","YASUKO","WINTER","VIKI","VALRIE","TONA","TINISHA","THI","TERISA","TATUM","TANEKA","SIMONNE","SHALANDA","SERITA","RESSIE","REFUGIA","PAZ","OLENE","NA","MERRILL","MARGHERITA","MANDIE","MAN","MAIRE","LYNDIA","LUCI","LORRIANE","LORETA","LEONIA","LAVONA","LASHAWNDA","LAKIA","KYOKO","KRYSTINA","KRYSTEN","KENIA","KELSI","JUDE","JEANICE","ISOBEL","GEORGIANN","GENNY","FELICIDAD","EILENE","DEON","DELOISE","DEEDEE","DANNIE","CONCEPTION","CLORA","CHERILYN","CHANG","CALANDRA","BERRY","ARMANDINA","ANISA","ULA","TIMOTHY","TIERA","THERESSA","STEPHANIA","SIMA","SHYLA","SHONTA","SHERA","SHAQUITA","SHALA","SAMMY","ROSSANA","NOHEMI","NERY","MORIAH","MELITA","MELIDA","MELANI","MARYLYNN","MARISHA","MARIETTE","MALORIE","MADELENE","LUDIVINA","LORIA","LORETTE","LORALEE","LIANNE","LEON","LAVENIA","LAURINDA","LASHON","KIT","KIMI","KEILA","KATELYNN","KAI","JONE","JOANE","JI","JAYNA","JANELLA","JA","HUE","HERTHA","FRANCENE","ELINORE","DESPINA","DELSIE","DEEDRA","CLEMENCIA","CARRY","CAROLIN","CARLOS","BULAH","BRITTANIE","BOK","BLONDELL","BIBI","BEAULAH","BEATA","ANNITA","AGRIPINA","VIRGEN","VALENE","UN","TWANDA","TOMMYE","TOI","TARRA","TARI","TAMMERA","SHAKIA","SADYE","RUTHANNE","ROCHEL","RIVKA","PURA","NENITA","NATISHA","MING","MERRILEE","MELODEE","MARVIS","LUCILLA","LEENA","LAVETA","LARITA","LANIE","KEREN","ILEEN","GEORGEANN","GENNA","GENESIS","FRIDA","EWA","EUFEMIA","EMELY","ELA","EDYTH","DEONNA","DEADRA","DARLENA","CHANELL","CHAN","CATHERN","CASSONDRA","CASSAUNDRA","BERNARDA","BERNA","ARLINDA","ANAMARIA","ALBERT","WESLEY","VERTIE","VALERI","TORRI","TATYANA","STASIA","SHERISE","SHERILL","SEASON","SCOTTIE","SANDA","RUTHE","ROSY","ROBERTO","ROBBI","RANEE","QUYEN","PEARLY","PALMIRA","ONITA","NISHA","NIESHA","NIDA","NEVADA","NAM","MERLYN","MAYOLA","MARYLOUISE","MARYLAND","MARX","MARTH","MARGENE","MADELAINE","LONDA","LEONTINE","LEOMA","LEIA","LAWRENCE","LAURALEE","LANORA","LAKITA","KIYOKO","KETURAH","KATELIN","KAREEN","JONIE","JOHNETTE","JENEE","JEANETT","IZETTA","HIEDI","HEIKE","HASSIE","HAROLD","GIUSEPPINA","GEORGANN","FIDELA","FERNANDE","ELWANDA","ELLAMAE","ELIZ","DUSTI","DOTTY","CYNDY","CORALIE","CELESTA","ARGENTINA","ALVERTA","XENIA","WAVA","VANETTA","TORRIE","TASHINA","TANDY","TAMBRA","TAMA","STEPANIE","SHILA","SHAUNTA","SHARAN","SHANIQUA","SHAE","SETSUKO","SERAFINA","SANDEE","ROSAMARIA","PRISCILA","OLINDA","NADENE","MUOI","MICHELINA","MERCEDEZ","MARYROSE","MARIN","MARCENE","MAO","MAGALI","MAFALDA","LOGAN","LINN","LANNIE","KAYCE","KAROLINE","KAMILAH","KAMALA","JUSTA","JOLINE","JENNINE","JACQUETTA","IRAIDA","GERALD","GEORGEANNA","FRANCHESCA","FAIRY","EMELINE","ELANE","EHTEL","EARLIE","DULCIE","DALENE","CRIS","CLASSIE","CHERE","CHARIS","CAROYLN","CARMINA","CARITA","BRIAN","BETHANIE","AYAKO","ARICA","AN","ALYSA","ALESSANDRA","AKILAH","ADRIEN","ZETTA","YOULANDA","YELENA","YAHAIRA","XUAN","WENDOLYN","VICTOR","TIJUANA","TERRELL","TERINA","TERESIA","SUZI","SUNDAY","SHERELL","SHAVONDA","SHAUNTE","SHARDA","SHAKITA","SENA","RYANN","RUBI","RIVA","REGINIA","REA","RACHAL","PARTHENIA","PAMULA","MONNIE","MONET","MICHAELE","MELIA","MARINE","MALKA","MAISHA","LISANDRA","LEO","LEKISHA","LEAN","LAURENCE","LAKENDRA","KRYSTIN","KORTNEY","KIZZIE","KITTIE","KERA","KENDAL","KEMBERLY","KANISHA","JULENE","JULE","JOSHUA","JOHANNE","JEFFREY","JAMEE","HAN","HALLEY","GIDGET","GALINA","FREDRICKA","FLETA","FATIMAH","EUSEBIA","ELZA","ELEONORE","DORTHEY","DORIA","DONELLA","DINORAH","DELORSE","CLARETHA","CHRISTINIA","CHARLYN","BONG","BELKIS","AZZIE","ANDERA","AIKO","ADENA","YER","YAJAIRA","WAN","VANIA","ULRIKE","TOSHIA","TIFANY","STEFANY","SHIZUE","SHENIKA","SHAWANNA","SHAROLYN","SHARILYN","SHAQUANA","SHANTAY","SEE","ROZANNE","ROSELEE","RICKIE","REMONA","REANNA","RAELENE","QUINN","PHUNG","PETRONILA","NATACHA","NANCEY","MYRL","MIYOKO","MIESHA","MERIDETH","MARVELLA","MARQUITTA","MARHTA","MARCHELLE","LIZETH","LIBBIE","LAHOMA","LADAWN","KINA","KATHELEEN","KATHARYN","KARISA","KALEIGH","JUNIE","JULIEANN","JOHNSIE","JANEAN","JAIMEE","JACKQUELINE","HISAKO","HERMA","HELAINE","GWYNETH","GLENN","GITA","EUSTOLIA","EMELINA","ELIN","EDRIS","DONNETTE","DONNETTA","DIERDRE","DENAE","DARCEL","CLAUDE","CLARISA","CINDERELLA","CHIA","CHARLESETTA","CHARITA","CELSA","CASSY","CASSI","CARLEE","BRUNA","BRITTANEY","BRANDE","BILLI","BAO","ANTONETTA","ANGLA","ANGELYN","ANALISA","ALANE","WENONA","WENDIE","VERONIQUE","VANNESA","TOBIE","TEMPIE","SUMIKO","SULEMA","SPARKLE","SOMER","SHEBA","SHAYNE","SHARICE","SHANEL","SHALON","SAGE","ROY","ROSIO","ROSELIA","RENAY","REMA","REENA","PORSCHE","PING","PEG","OZIE","ORETHA","ORALEE","ODA","NU","NGAN","NAKESHA","MILLY","MARYBELLE","MARLIN","MARIS","MARGRETT","MARAGARET","MANIE","LURLENE","LILLIA","LIESELOTTE","LAVELLE","LASHAUNDA","LAKEESHA","KEITH","KAYCEE","KALYN","JOYA","JOETTE","JENAE","JANIECE","ILLA","GRISEL","GLAYDS","GENEVIE","GALA","FREDDA","FRED","ELMER","ELEONOR","DEBERA","DEANDREA","DAN","CORRINNE","CORDIA","CONTESSA","COLENE","CLEOTILDE","CHARLOTT","CHANTAY","CECILLE","BEATRIS","AZALEE","ARLEAN","ARDATH","ANJELICA","ANJA","ALFREDIA","ALEISHA","ADAM","ZADA","YUONNE","XIAO","WILLODEAN","WHITLEY","VENNIE","VANNA","TYISHA","TOVA","TORIE","TONISHA","TILDA","TIEN","TEMPLE","SIRENA","SHERRIL","SHANTI","SHAN","SENAIDA","SAMELLA","ROBBYN","RENDA","REITA","PHEBE","PAULITA","NOBUKO","NGUYET","NEOMI","MOON","MIKAELA","MELANIA","MAXIMINA","MARG","MAISIE","LYNNA","LILLI","LAYNE","LASHAUN","LAKENYA","LAEL","KIRSTIE","KATHLINE","KASHA","KARLYN","KARIMA","JOVAN","JOSEFINE","JENNELL","JACQUI","JACKELYN","HYO","HIEN","GRAZYNA","FLORRIE","FLORIA","ELEONORA","DWANA","DORLA","DONG","DELMY","DEJA","DEDE","DANN","CRYSTA","CLELIA","CLARIS","CLARENCE","CHIEKO","CHERLYN","CHERELLE","CHARMAIN","CHARA","CAMMY","BEE","ARNETTE","ARDELLE","ANNIKA","AMIEE","AMEE","ALLENA","YVONE","YUKI","YOSHIE","YEVETTE","YAEL","WILLETTA","VONCILE","VENETTA","TULA","TONETTE","TIMIKA","TEMIKA","TELMA","TEISHA","TAREN","TA","STACEE","SHIN","SHAWNTA","SATURNINA","RICARDA","POK","PASTY","ONIE","NUBIA","MORA","MIKE","MARIELLE","MARIELLA","MARIANELA","MARDELL","MANY","LUANNA","LOISE","LISABETH","LINDSY","LILLIANA","LILLIAM","LELAH","LEIGHA","LEANORA","LANG","KRISTEEN","KHALILAH","KEELEY","KANDRA","JUNKO","JOAQUINA","JERLENE","JANI","JAMIKA","JAME","HSIU","HERMILA","GOLDEN","GENEVIVE","EVIA","EUGENA","EMMALINE","ELFREDA","ELENE","DONETTE","DELCIE","DEEANNA","DARCEY","CUC","CLARINDA","CIRA","CHAE","CELINDA","CATHERYN","CATHERIN","CASIMIRA","CARMELIA","CAMELLIA","BREANA","BOBETTE","BERNARDINA","BEBE","BASILIA","ARLYNE","AMAL","ALAYNA","ZONIA","ZENIA","YURIKO","YAEKO","WYNELL","WILLOW","WILLENA","VERNIA","TU","TRAVIS","TORA","TERRILYN","TERICA","TENESHA","TAWNA","TAJUANA","TAINA","STEPHNIE","SONA","SOL","SINA","SHONDRA","SHIZUKO","SHERLENE","SHERICE","SHARIKA","ROSSIE","ROSENA","RORY","RIMA","RIA","RHEBA","RENNA","PETER","NATALYA","NANCEE","MELODI","MEDA","MAXIMA","MATHA","MARKETTA","MARICRUZ","MARCELENE","MALVINA","LUBA","LOUETTA","LEIDA","LECIA","LAURAN","LASHAWNA","LAINE","KHADIJAH","KATERINE","KASI","KALLIE","JULIETTA","JESUSITA","JESTINE","JESSIA","JEREMY","JEFFIE","JANYCE","ISADORA","GEORGIANNE","FIDELIA","EVITA","EURA","EULAH","ESTEFANA","ELSY","ELIZABET","ELADIA","DODIE","DION","DIA","DENISSE","DELORAS","DELILA","DAYSI","DAKOTA","CURTIS","CRYSTLE","CONCHA","COLBY","CLARETTA","CHU","CHRISTIA","CHARLSIE","CHARLENA","CARYLON","BETTYANN","ASLEY","ASHLEA","AMIRA","AI","AGUEDA","AGNUS","YUETTE","VINITA","VICTORINA","TYNISHA","TREENA","TOCCARA","TISH","THOMASENA","TEGAN","SOILA","SHILOH","SHENNA","SHARMAINE","SHANTAE","SHANDI","SEPTEMBER","SARAN","SARAI","SANA","SAMUEL","SALLEY","ROSETTE","ROLANDE","REGINE","OTELIA","OSCAR","OLEVIA","NICHOLLE","NECOLE","NAIDA","MYRTA","MYESHA","MITSUE","MINTA","MERTIE","MARGY","MAHALIA","MADALENE","LOVE","LOURA","LOREAN","LEWIS","LESHA","LEONIDA","LENITA","LAVONE","LASHELL","LASHANDRA","LAMONICA","KIMBRA","KATHERINA","KARRY","KANESHA","JULIO","JONG","JENEVA","JAQUELYN","HWA","GILMA","GHISLAINE","GERTRUDIS","FRANSISCA","FERMINA","ETTIE","ETSUKO","ELLIS","ELLAN","ELIDIA","EDRA","DORETHEA","DOREATHA","DENYSE","DENNY","DEETTA","DAINE","CYRSTAL","CORRIN","CAYLA","CARLITA","CAMILA","BURMA","BULA","BUENA","BLAKE","BARABARA","AVRIL","AUSTIN","ALAINE","ZANA","WILHEMINA","WANETTA","VIRGIL","VI","VERONIKA","VERNON","VERLINE","VASILIKI","TONITA","TISA","TEOFILA","TAYNA","TAUNYA","TANDRA","TAKAKO","SUNNI","SUANNE","SIXTA","SHARELL","SEEMA","RUSSELL","ROSENDA","ROBENA","RAYMONDE","PEI","PAMILA","OZELL","NEIDA","NEELY","MISTIE","MICHA","MERISSA","MAURITA","MARYLN","MARYETTA","MARSHALL","MARCELL","MALENA","MAKEDA","MADDIE","LOVETTA","LOURIE","LORRINE","LORILEE","LESTER","LAURENA","LASHAY","LARRAINE","LAREE","LACRESHA","KRISTLE","KRISHNA","KEVA","KEIRA","KAROLE","JOIE","JINNY","JEANNETTA","JAMA","HEIDY","GILBERTE","GEMA","FAVIOLA","EVELYNN","ENDA","ELLI","ELLENA","DIVINA","DAGNY","COLLENE","CODI","CINDIE","CHASSIDY","CHASIDY","CATRICE","CATHERINA","CASSEY","CAROLL","CARLENA","CANDRA","CALISTA","BRYANNA","BRITTENY","BEULA","BARI","AUDRIE","AUDRIA","ARDELIA","ANNELLE","ANGILA","ALONA","ALLYN","DOUGLAS","ROGER","JONATHAN","RALPH","NICHOLAS","BENJAMIN","BRUCE","HARRY","WAYNE","STEVE","HOWARD","ERNEST","PHILLIP","TODD","CRAIG","ALAN","PHILIP","EARL","DANNY","BRYAN","STANLEY","LEONARD","NATHAN","MANUEL","RODNEY","MARVIN","VINCENT","JEFFERY","JEFF","CHAD","JACOB","ALFRED","BRADLEY","HERBERT","FREDERICK","EDWIN","DON","RICKY","RANDALL","BARRY","BERNARD","LEROY","MARCUS","THEODORE","CLIFFORD","MIGUEL","JIM","TOM","CALVIN","BILL","LLOYD","DEREK","WARREN","DARRELL","JEROME","FLOYD","ALVIN","TIM","GORDON","GREG","JORGE","DUSTIN","PEDRO","DERRICK","ZACHARY","HERMAN","GLEN","HECTOR","RICARDO","RICK","BRENT","RAMON","GILBERT","MARC","REGINALD","RUBEN","NATHANIEL","RAFAEL","EDGAR","MILTON","RAUL","BEN","CHESTER","DUANE","FRANKLIN","BRAD","RON","ROLAND","ARNOLD","HARVEY","JARED","ERIK","DARRYL","NEIL","JAVIER","FERNANDO","CLINTON","TED","MATHEW","TYRONE","DARREN","LANCE","KURT","ALLAN","NELSON","GUY","CLAYTON","HUGH","MAX","DWAYNE","DWIGHT","ARMANDO","FELIX","EVERETT","IAN","WALLACE","KEN","BOB","ALFREDO","ALBERTO","DAVE","IVAN","BYRON","ISAAC","MORRIS","CLIFTON","WILLARD","ROSS","ANDY","SALVADOR","KIRK","SERGIO","SETH","KENT","TERRANCE","EDUARDO","TERRENCE","ENRIQUE","WADE","STUART","FREDRICK","ARTURO","ALEJANDRO","NICK","LUTHER","WENDELL","JEREMIAH","JULIUS","OTIS","TREVOR","OLIVER","LUKE","HOMER","GERARD","DOUG","KENNY","HUBERT","LYLE","MATT","ALFONSO","ORLANDO","REX","CARLTON","ERNESTO","NEAL","PABLO","LORENZO","OMAR","WILBUR","GRANT","HORACE","RODERICK","ABRAHAM","WILLIS","RICKEY","ANDRES","CESAR","JOHNATHAN","MALCOLM","RUDOLPH","DAMON","KELVIN","PRESTON","ALTON","ARCHIE","MARCO","WM","PETE","RANDOLPH","GARRY","GEOFFREY","JONATHON","FELIPE","GERARDO","ED","DOMINIC","DELBERT","COLIN","GUILLERMO","EARNEST","LUCAS","BENNY","SPENCER","RODOLFO","MYRON","EDMUND","GARRETT","SALVATORE","CEDRIC","LOWELL","GREGG","SHERMAN","WILSON","SYLVESTER","ROOSEVELT","ISRAEL","JERMAINE","FORREST","WILBERT","LELAND","SIMON","CLARK","IRVING","BRYANT","OWEN","RUFUS","WOODROW","KRISTOPHER","MACK","LEVI","MARCOS","GUSTAVO","JAKE","LIONEL","GILBERTO","CLINT","NICOLAS","ISMAEL","ORVILLE","ERVIN","DEWEY","AL","WILFRED","JOSH","HUGO","IGNACIO","CALEB","TOMAS","SHELDON","ERICK","STEWART","DOYLE","DARREL","ROGELIO","TERENCE","SANTIAGO","ALONZO","ELIAS","BERT","ELBERT","RAMIRO","CONRAD","NOAH","GRADY","PHIL","CORNELIUS","LAMAR","ROLANDO","CLAY","PERCY","DEXTER","BRADFORD","DARIN","AMOS","MOSES","IRVIN","SAUL","ROMAN","RANDAL","TIMMY","DARRIN","WINSTON","BRENDAN","ABEL","DOMINICK","BOYD","EMILIO","ELIJAH","DOMINGO","EMMETT","MARLON","EMANUEL","JERALD","EDMOND","EMIL","DEWAYNE","WILL","OTTO","TEDDY","REYNALDO","BRET","JESS","TRENT","HUMBERTO","EMMANUEL","STEPHAN","VICENTE","LAMONT","GARLAND","MILES","EFRAIN","HEATH","RODGER","HARLEY","ETHAN","ELDON","ROCKY","PIERRE","JUNIOR","FREDDY","ELI","BRYCE","ANTOINE","STERLING","CHASE","GROVER","ELTON","CLEVELAND","DYLAN","CHUCK","DAMIAN","REUBEN","STAN","AUGUST","LEONARDO","JASPER","RUSSEL","ERWIN","BENITO","HANS","MONTE","BLAINE","ERNIE","CURT","QUENTIN","AGUSTIN","MURRAY","JAMAL","ADOLFO","HARRISON","TYSON","BURTON","BRADY","ELLIOTT","WILFREDO","BART","JARROD","VANCE","DENIS","DAMIEN","JOAQUIN","HARLAN","DESMOND","ELLIOT","DARWIN","GREGORIO","BUDDY","XAVIER","KERMIT","ROSCOE","ESTEBAN","ANTON","SOLOMON","SCOTTY","NORBERT","ELVIN","WILLIAMS","NOLAN","ROD","QUINTON","HAL","BRAIN","ROB","ELWOOD","KENDRICK","DARIUS","MOISES","FIDEL","THADDEUS","CLIFF","MARCEL","JACKSON","RAPHAEL","BRYON","ARMAND","ALVARO","JEFFRY","DANE","JOESPH","THURMAN","NED","RUSTY","MONTY","FABIAN","REGGIE","MASON","GRAHAM","ISAIAH","VAUGHN","GUS","LOYD","DIEGO","ADOLPH","NORRIS","MILLARD","ROCCO","GONZALO","DERICK","RODRIGO","WILEY","RIGOBERTO","ALPHONSO","TY","NOE","VERN","REED","JEFFERSON","ELVIS","BERNARDO","MAURICIO","HIRAM","DONOVAN","BASIL","RILEY","NICKOLAS","MAYNARD","SCOT","VINCE","QUINCY","EDDY","SEBASTIAN","FEDERICO","ULYSSES","HERIBERTO","DONNELL","COLE","DAVIS","GAVIN","EMERY","WARD","ROMEO","JAYSON","DANTE","CLEMENT","COY","MAXWELL","JARVIS","BRUNO","ISSAC","DUDLEY","BROCK","SANFORD","CARMELO","BARNEY","NESTOR","STEFAN","DONNY","ART","LINWOOD","BEAU","WELDON","GALEN","ISIDRO","TRUMAN","DELMAR","JOHNATHON","SILAS","FREDERIC","DICK","IRWIN","MERLIN","CHARLEY","MARCELINO","HARRIS","CARLO","TRENTON","KURTIS","HUNTER","AURELIO","WINFRED","VITO","COLLIN","DENVER","CARTER","LEONEL","EMORY","PASQUALE","MOHAMMAD","MARIANO","DANIAL","LANDON","DIRK","BRANDEN","ADAN","BUFORD","GERMAN","WILMER","EMERSON","ZACHERY","FLETCHER","JACQUES","ERROL","DALTON","MONROE","JOSUE","EDWARDO","BOOKER","WILFORD","SONNY","SHELTON","CARSON","THERON","RAYMUNDO","DAREN","HOUSTON","ROBBY","LINCOLN","GENARO","BENNETT","OCTAVIO","CORNELL","HUNG","ARRON","ANTONY","HERSCHEL","GIOVANNI","GARTH","CYRUS","CYRIL","RONNY","LON","FREEMAN","DUNCAN","KENNITH","CARMINE","ERICH","CHADWICK","WILBURN","RUSS","REID","MYLES","ANDERSON","MORTON","JONAS","FOREST","MITCHEL","MERVIN","ZANE","RICH","JAMEL","LAZARO","ALPHONSE","RANDELL","MAJOR","JARRETT","BROOKS","ABDUL","LUCIANO","SEYMOUR","EUGENIO","MOHAMMED","VALENTIN","CHANCE","ARNULFO","LUCIEN","FERDINAND","THAD","EZRA","ALDO","RUBIN","ROYAL","MITCH","EARLE","ABE","WYATT","MARQUIS","LANNY","KAREEM","JAMAR","BORIS","ISIAH","EMILE","ELMO","ARON","LEOPOLDO","EVERETTE","JOSEF","ELOY","RODRICK","REINALDO","LUCIO","JERROD","WESTON","HERSHEL","BARTON","PARKER","LEMUEL","BURT","JULES","GIL","ELISEO","AHMAD","NIGEL","EFREN","ANTWAN","ALDEN","MARGARITO","COLEMAN","DINO","OSVALDO","LES","DEANDRE","NORMAND","KIETH","TREY","NORBERTO","NAPOLEON","JEROLD","FRITZ","ROSENDO","MILFORD","CHRISTOPER","ALFONZO","LYMAN","JOSIAH","BRANT","WILTON","RICO","JAMAAL","DEWITT","BRENTON","OLIN","FOSTER","FAUSTINO","CLAUDIO","JUDSON","GINO","EDGARDO","ALEC","TANNER","JARRED","DONN","TAD","PRINCE","PORFIRIO","ODIS","LENARD","CHAUNCEY","TOD","MEL","MARCELO","KORY","AUGUSTUS","KEVEN","HILARIO","BUD","SAL","ORVAL","MAURO","ZACHARIAH","OLEN","ANIBAL","MILO","JED","DILLON","AMADO","NEWTON","LENNY","RICHIE","HORACIO","BRICE","MOHAMED","DELMER","DARIO","REYES","MAC","JONAH","JERROLD","ROBT","HANK","RUPERT","ROLLAND","KENTON","DAMION","ANTONE","WALDO","FREDRIC","BRADLY","KIP","BURL","WALKER","TYREE","JEFFEREY","AHMED","WILLY","STANFORD","OREN","NOBLE","MOSHE","MIKEL","ENOCH","BRENDON","QUINTIN","JAMISON","FLORENCIO","DARRICK","TOBIAS","HASSAN","GIUSEPPE","DEMARCUS","CLETUS","TYRELL","LYNDON","KEENAN","WERNER","GERALDO","COLUMBUS","CHET","BERTRAM","MARKUS","HUEY","HILTON","DWAIN","DONTE","TYRON","OMER","ISAIAS","HIPOLITO","FERMIN","ADALBERTO","BO","BARRETT","TEODORO","MCKINLEY","MAXIMO","GARFIELD","RALEIGH","LAWERENCE","ABRAM","RASHAD","KING","EMMITT","DARON","SAMUAL","MIQUEL","EUSEBIO","DOMENIC","DARRON","BUSTER","WILBER","RENATO","JC","HOYT","HAYWOOD","EZEKIEL","CHAS","FLORENTINO","ELROY","CLEMENTE","ARDEN","NEVILLE","EDISON","DESHAWN","NATHANIAL","JORDON","DANILO","CLAUD","SHERWOOD","RAYMON","RAYFORD","CRISTOBAL","AMBROSE","TITUS","HYMAN","FELTON","EZEQUIEL","ERASMO","STANTON","LONNY","LEN","IKE","MILAN","LINO","JAROD","HERB","ANDREAS","WALTON","RHETT","PALMER","DOUGLASS","CORDELL","OSWALDO","ELLSWORTH","VIRGILIO","TONEY","NATHANAEL","DEL","BENEDICT","MOSE","JOHNSON","ISREAL","GARRET","FAUSTO","ASA","ARLEN","ZACK","WARNER","MODESTO","FRANCESCO","MANUAL","GAYLORD","GASTON","FILIBERTO","DEANGELO","MICHALE","GRANVILLE","WES","MALIK","ZACKARY","TUAN","ELDRIDGE","CRISTOPHER","CORTEZ","ANTIONE","MALCOM","LONG","KOREY","JOSPEH","COLTON","WAYLON","VON","HOSEA","SHAD","SANTO","RUDOLF","ROLF","REY","RENALDO","MARCELLUS","LUCIUS","KRISTOFER","BOYCE","BENTON","HAYDEN","HARLAND","ARNOLDO","RUEBEN","LEANDRO","KRAIG","JERRELL","JEROMY","HOBERT","CEDRICK","ARLIE","WINFORD","WALLY","LUIGI","KENETH","JACINTO","GRAIG","FRANKLYN","EDMUNDO","SID","PORTER","LEIF","JERAMY","BUCK","WILLIAN","VINCENZO","SHON","LYNWOOD","JERE","HAI","ELDEN","DORSEY","DARELL","BRODERICK","ALONSO"
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
import base64 def main() -> None: inp = input("->") encoded = inp.encode("utf-8") # encoded the input (we need a bytes like object) a85encoded = base64.a85encode(encoded) # a85encoded the encoded string print(a85encoded) print(base64.a85decode(a85encoded).decode("utf-8")) # decoded it if __name__ == "__main__": main()
import base64 def main() -> None: inp = input("->") encoded = inp.encode("utf-8") # encoded the input (we need a bytes like object) a85encoded = base64.a85encode(encoded) # a85encoded the encoded string print(a85encoded) print(base64.a85decode(a85encoded).decode("utf-8")) # decoded it if __name__ == "__main__": main()
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Heap's (iterative) algorithm returns the list of all permutations possible from a list. It minimizes movement by generating each permutation from the previous one by swapping only two elements. More information: https://en.wikipedia.org/wiki/Heap%27s_algorithm. """ def heaps(arr: list) -> list: """ Pure python implementation of the iterative Heap's algorithm, returning all permutations of a list. >>> heaps([]) [()] >>> heaps([0]) [(0,)] >>> heaps([-1, 1]) [(-1, 1), (1, -1)] >>> heaps([1, 2, 3]) [(1, 2, 3), (2, 1, 3), (3, 1, 2), (1, 3, 2), (2, 3, 1), (3, 2, 1)] >>> from itertools import permutations >>> sorted(heaps([1,2,3])) == sorted(permutations([1,2,3])) True >>> all(sorted(heaps(x)) == sorted(permutations(x)) ... for x in ([], [0], [-1, 1], [1, 2, 3])) True """ if len(arr) <= 1: return [tuple(arr)] res = [] def generate(n: int, arr: list): c = [0] * n res.append(tuple(arr)) i = 0 while i < n: if c[i] < i: if i % 2 == 0: arr[0], arr[i] = arr[i], arr[0] else: arr[c[i]], arr[i] = arr[i], arr[c[i]] res.append(tuple(arr)) c[i] += 1 i = 0 else: c[i] = 0 i += 1 generate(len(arr), arr) return res if __name__ == "__main__": user_input = input("Enter numbers separated by a comma:\n").strip() arr = [int(item) for item in user_input.split(",")] print(heaps(arr))
""" Heap's (iterative) algorithm returns the list of all permutations possible from a list. It minimizes movement by generating each permutation from the previous one by swapping only two elements. More information: https://en.wikipedia.org/wiki/Heap%27s_algorithm. """ def heaps(arr: list) -> list: """ Pure python implementation of the iterative Heap's algorithm, returning all permutations of a list. >>> heaps([]) [()] >>> heaps([0]) [(0,)] >>> heaps([-1, 1]) [(-1, 1), (1, -1)] >>> heaps([1, 2, 3]) [(1, 2, 3), (2, 1, 3), (3, 1, 2), (1, 3, 2), (2, 3, 1), (3, 2, 1)] >>> from itertools import permutations >>> sorted(heaps([1,2,3])) == sorted(permutations([1,2,3])) True >>> all(sorted(heaps(x)) == sorted(permutations(x)) ... for x in ([], [0], [-1, 1], [1, 2, 3])) True """ if len(arr) <= 1: return [tuple(arr)] res = [] def generate(n: int, arr: list): c = [0] * n res.append(tuple(arr)) i = 0 while i < n: if c[i] < i: if i % 2 == 0: arr[0], arr[i] = arr[i], arr[0] else: arr[c[i]], arr[i] = arr[i], arr[c[i]] res.append(tuple(arr)) c[i] += 1 i = 0 else: c[i] = 0 i += 1 generate(len(arr), arr) return res if __name__ == "__main__": user_input = input("Enter numbers separated by a comma:\n").strip() arr = [int(item) for item in user_input.split(",")] print(heaps(arr))
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Python program for Bitonic Sort. Note that this program works only when size of input is a power of 2. """ from typing import List def comp_and_swap(array: List[int], index1: int, index2: int, direction: int) -> None: """Compare the value at given index1 and index2 of the array and swap them as per the given direction. The parameter direction indicates the sorting direction, ASCENDING(1) or DESCENDING(0); if (a[i] > a[j]) agrees with the direction, then a[i] and a[j] are interchanged. >>> arr = [12, 42, -21, 1] >>> comp_and_swap(arr, 1, 2, 1) >>> print(arr) [12, -21, 42, 1] >>> comp_and_swap(arr, 1, 2, 0) >>> print(arr) [12, 42, -21, 1] >>> comp_and_swap(arr, 0, 3, 1) >>> print(arr) [1, 42, -21, 12] >>> comp_and_swap(arr, 0, 3, 0) >>> print(arr) [12, 42, -21, 1] """ if (direction == 1 and array[index1] > array[index2]) or ( direction == 0 and array[index1] < array[index2] ): array[index1], array[index2] = array[index2], array[index1] def bitonic_merge(array: List[int], low: int, length: int, direction: int) -> None: """ It recursively sorts a bitonic sequence in ascending order, if direction = 1, and in descending if direction = 0. The sequence to be sorted starts at index position low, the parameter length is the number of elements to be sorted. >>> arr = [12, 42, -21, 1] >>> bitonic_merge(arr, 0, 4, 1) >>> print(arr) [-21, 1, 12, 42] >>> bitonic_merge(arr, 0, 4, 0) >>> print(arr) [42, 12, 1, -21] """ if length > 1: middle = int(length / 2) for i in range(low, low + middle): comp_and_swap(array, i, i + middle, direction) bitonic_merge(array, low, middle, direction) bitonic_merge(array, low + middle, middle, direction) def bitonic_sort(array: List[int], low: int, length: int, direction: int) -> None: """ This function first produces a bitonic sequence by recursively sorting its two halves in opposite sorting orders, and then calls bitonic_merge to make them in the same order. >>> arr = [12, 34, 92, -23, 0, -121, -167, 145] >>> bitonic_sort(arr, 0, 8, 1) >>> arr [-167, -121, -23, 0, 12, 34, 92, 145] >>> bitonic_sort(arr, 0, 8, 0) >>> arr [145, 92, 34, 12, 0, -23, -121, -167] """ if length > 1: middle = int(length / 2) bitonic_sort(array, low, middle, 1) bitonic_sort(array, low + middle, middle, 0) bitonic_merge(array, low, length, direction) if __name__ == "__main__": user_input = input("Enter numbers separated by a comma:\n").strip() unsorted = [int(item.strip()) for item in user_input.split(",")] bitonic_sort(unsorted, 0, len(unsorted), 1) print("\nSorted array in ascending order is: ", end="") print(*unsorted, sep=", ") bitonic_merge(unsorted, 0, len(unsorted), 0) print("Sorted array in descending order is: ", end="") print(*unsorted, sep=", ")
""" Python program for Bitonic Sort. Note that this program works only when size of input is a power of 2. """ from typing import List def comp_and_swap(array: List[int], index1: int, index2: int, direction: int) -> None: """Compare the value at given index1 and index2 of the array and swap them as per the given direction. The parameter direction indicates the sorting direction, ASCENDING(1) or DESCENDING(0); if (a[i] > a[j]) agrees with the direction, then a[i] and a[j] are interchanged. >>> arr = [12, 42, -21, 1] >>> comp_and_swap(arr, 1, 2, 1) >>> print(arr) [12, -21, 42, 1] >>> comp_and_swap(arr, 1, 2, 0) >>> print(arr) [12, 42, -21, 1] >>> comp_and_swap(arr, 0, 3, 1) >>> print(arr) [1, 42, -21, 12] >>> comp_and_swap(arr, 0, 3, 0) >>> print(arr) [12, 42, -21, 1] """ if (direction == 1 and array[index1] > array[index2]) or ( direction == 0 and array[index1] < array[index2] ): array[index1], array[index2] = array[index2], array[index1] def bitonic_merge(array: List[int], low: int, length: int, direction: int) -> None: """ It recursively sorts a bitonic sequence in ascending order, if direction = 1, and in descending if direction = 0. The sequence to be sorted starts at index position low, the parameter length is the number of elements to be sorted. >>> arr = [12, 42, -21, 1] >>> bitonic_merge(arr, 0, 4, 1) >>> print(arr) [-21, 1, 12, 42] >>> bitonic_merge(arr, 0, 4, 0) >>> print(arr) [42, 12, 1, -21] """ if length > 1: middle = int(length / 2) for i in range(low, low + middle): comp_and_swap(array, i, i + middle, direction) bitonic_merge(array, low, middle, direction) bitonic_merge(array, low + middle, middle, direction) def bitonic_sort(array: List[int], low: int, length: int, direction: int) -> None: """ This function first produces a bitonic sequence by recursively sorting its two halves in opposite sorting orders, and then calls bitonic_merge to make them in the same order. >>> arr = [12, 34, 92, -23, 0, -121, -167, 145] >>> bitonic_sort(arr, 0, 8, 1) >>> arr [-167, -121, -23, 0, 12, 34, 92, 145] >>> bitonic_sort(arr, 0, 8, 0) >>> arr [145, 92, 34, 12, 0, -23, -121, -167] """ if length > 1: middle = int(length / 2) bitonic_sort(array, low, middle, 1) bitonic_sort(array, low + middle, middle, 0) bitonic_merge(array, low, length, direction) if __name__ == "__main__": user_input = input("Enter numbers separated by a comma:\n").strip() unsorted = [int(item.strip()) for item in user_input.split(",")] bitonic_sort(unsorted, 0, len(unsorted), 1) print("\nSorted array in ascending order is: ", end="") print(*unsorted, sep=", ") bitonic_merge(unsorted, 0, len(unsorted), 0) print("Sorted array in descending order is: ", end="") print(*unsorted, sep=", ")
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
"""Implementation of Basic Math in Python.""" import math def prime_factors(n: int) -> list: """Find Prime Factors. >>> prime_factors(100) [2, 2, 5, 5] """ pf = [] while n % 2 == 0: pf.append(2) n = int(n / 2) for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i == 0: pf.append(i) n = int(n / i) if n > 2: pf.append(n) return pf def number_of_divisors(n: int) -> int: """Calculate Number of Divisors of an Integer. >>> number_of_divisors(100) 9 """ div = 1 temp = 1 while n % 2 == 0: temp += 1 n = int(n / 2) div *= temp for i in range(3, int(math.sqrt(n)) + 1, 2): temp = 1 while n % i == 0: temp += 1 n = int(n / i) div *= temp return div def sum_of_divisors(n: int) -> int: """Calculate Sum of Divisors. >>> sum_of_divisors(100) 217 """ s = 1 temp = 1 while n % 2 == 0: temp += 1 n = int(n / 2) if temp > 1: s *= (2 ** temp - 1) / (2 - 1) for i in range(3, int(math.sqrt(n)) + 1, 2): temp = 1 while n % i == 0: temp += 1 n = int(n / i) if temp > 1: s *= (i ** temp - 1) / (i - 1) return int(s) def euler_phi(n: int) -> int: """Calculate Euler's Phi Function. >>> euler_phi(100) 40 """ s = n for x in set(prime_factors(n)): s *= (x - 1) / x return int(s) if __name__ == "__main__": print(prime_factors(100)) print(number_of_divisors(100)) print(sum_of_divisors(100)) print(euler_phi(100))
"""Implementation of Basic Math in Python.""" import math def prime_factors(n: int) -> list: """Find Prime Factors. >>> prime_factors(100) [2, 2, 5, 5] """ pf = [] while n % 2 == 0: pf.append(2) n = int(n / 2) for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i == 0: pf.append(i) n = int(n / i) if n > 2: pf.append(n) return pf def number_of_divisors(n: int) -> int: """Calculate Number of Divisors of an Integer. >>> number_of_divisors(100) 9 """ div = 1 temp = 1 while n % 2 == 0: temp += 1 n = int(n / 2) div *= temp for i in range(3, int(math.sqrt(n)) + 1, 2): temp = 1 while n % i == 0: temp += 1 n = int(n / i) div *= temp return div def sum_of_divisors(n: int) -> int: """Calculate Sum of Divisors. >>> sum_of_divisors(100) 217 """ s = 1 temp = 1 while n % 2 == 0: temp += 1 n = int(n / 2) if temp > 1: s *= (2 ** temp - 1) / (2 - 1) for i in range(3, int(math.sqrt(n)) + 1, 2): temp = 1 while n % i == 0: temp += 1 n = int(n / i) if temp > 1: s *= (i ** temp - 1) / (i - 1) return int(s) def euler_phi(n: int) -> int: """Calculate Euler's Phi Function. >>> euler_phi(100) 40 """ s = n for x in set(prime_factors(n)): s *= (x - 1) / x return int(s) if __name__ == "__main__": print(prime_factors(100)) print(number_of_divisors(100)) print(sum_of_divisors(100)) print(euler_phi(100))
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
# Primality Testing with the Rabin-Miller Algorithm import random def rabinMiller(num: int) -> bool: s = num - 1 t = 0 while s % 2 == 0: s = s // 2 t += 1 for trials in range(5): a = random.randrange(2, num - 1) v = pow(a, s, num) if v != 1: i = 0 while v != (num - 1): if i == t - 1: return False else: i = i + 1 v = (v ** 2) % num return True def isPrime(num: int) -> bool: if num < 2: return False lowPrimes = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, ] if num in lowPrimes: return True for prime in lowPrimes: if (num % prime) == 0: return False return rabinMiller(num) def generateLargePrime(keysize: int = 1024) -> int: while True: num = random.randrange(2 ** (keysize - 1), 2 ** (keysize)) if isPrime(num): return num if __name__ == "__main__": num = generateLargePrime() print(("Prime number:", num)) print(("isPrime:", isPrime(num)))
# Primality Testing with the Rabin-Miller Algorithm import random def rabinMiller(num: int) -> bool: s = num - 1 t = 0 while s % 2 == 0: s = s // 2 t += 1 for trials in range(5): a = random.randrange(2, num - 1) v = pow(a, s, num) if v != 1: i = 0 while v != (num - 1): if i == t - 1: return False else: i = i + 1 v = (v ** 2) % num return True def isPrime(num: int) -> bool: if num < 2: return False lowPrimes = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, ] if num in lowPrimes: return True for prime in lowPrimes: if (num % prime) == 0: return False return rabinMiller(num) def generateLargePrime(keysize: int = 1024) -> int: while True: num = random.randrange(2 ** (keysize - 1), 2 ** (keysize)) if isPrime(num): return num if __name__ == "__main__": num = generateLargePrime() print(("Prime number:", num)) print(("isPrime:", isPrime(num)))
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Project Euler Problem 074: https://projecteuler.net/problem=74 Starting from any positive integer number it is possible to attain another one summing the factorial of its digits. Repeating this step, we can build chains of numbers. It is not difficult to prove that EVERY starting number will eventually get stuck in a loop. The request is to find how many numbers less than one million produce a chain with exactly 60 non repeating items. Solution approach: This solution simply consists in a loop that generates the chains of non repeating items. The generation of the chain stops before a repeating item or if the size of the chain is greater then the desired one. After generating each chain, the length is checked and the counter increases. """ factorial_cache = {} factorial_sum_cache = {} def factorial(a: int) -> int: """Returns the factorial of the input a >>> factorial(5) 120 >>> factorial(6) 720 >>> factorial(0) 1 """ # The factorial function is not defined for negative numbers if a < 0: raise ValueError("Invalid negative input!", a) if a in factorial_cache: return factorial_cache[a] # The case of 0! is handled separately if a == 0: factorial_cache[a] = 1 else: # use a temporary support variable to store the computation temporary_number = a temporary_computation = 1 while temporary_number > 0: temporary_computation *= temporary_number temporary_number -= 1 factorial_cache[a] = temporary_computation return factorial_cache[a] def factorial_sum(a: int) -> int: """Function to perform the sum of the factorial of all the digits in a >>> factorial_sum(69) 363600 """ if a in factorial_sum_cache: return factorial_sum_cache[a] # Prepare a variable to hold the computation fact_sum = 0 """ Convert a in string to iterate on its digits convert the digit back into an int and add its factorial to fact_sum. """ for i in str(a): fact_sum += factorial(int(i)) factorial_sum_cache[a] = fact_sum return fact_sum def solution(chain_length: int = 60, number_limit: int = 1000000) -> int: """Returns the number of numbers that produce chains with exactly 60 non repeating elements. >>> solution(10, 1000) 26 """ # the counter for the chains with the exact desired length chain_counter = 0 for i in range(1, number_limit + 1): # The temporary list will contain the elements of the chain chain_set = {i} len_chain_set = 1 last_chain_element = i # The new element of the chain new_chain_element = factorial_sum(last_chain_element) # Stop computing the chain when you find a repeating item # or the length it greater then the desired one. while new_chain_element not in chain_set and len_chain_set <= chain_length: chain_set.add(new_chain_element) len_chain_set += 1 last_chain_element = new_chain_element new_chain_element = factorial_sum(last_chain_element) # If the while exited because the chain list contains the exact amount # of elements increase the counter if len_chain_set == chain_length: chain_counter += 1 return chain_counter if __name__ == "__main__": import doctest doctest.testmod() print(f"{solution()}")
""" Project Euler Problem 074: https://projecteuler.net/problem=74 Starting from any positive integer number it is possible to attain another one summing the factorial of its digits. Repeating this step, we can build chains of numbers. It is not difficult to prove that EVERY starting number will eventually get stuck in a loop. The request is to find how many numbers less than one million produce a chain with exactly 60 non repeating items. Solution approach: This solution simply consists in a loop that generates the chains of non repeating items. The generation of the chain stops before a repeating item or if the size of the chain is greater then the desired one. After generating each chain, the length is checked and the counter increases. """ factorial_cache = {} factorial_sum_cache = {} def factorial(a: int) -> int: """Returns the factorial of the input a >>> factorial(5) 120 >>> factorial(6) 720 >>> factorial(0) 1 """ # The factorial function is not defined for negative numbers if a < 0: raise ValueError("Invalid negative input!", a) if a in factorial_cache: return factorial_cache[a] # The case of 0! is handled separately if a == 0: factorial_cache[a] = 1 else: # use a temporary support variable to store the computation temporary_number = a temporary_computation = 1 while temporary_number > 0: temporary_computation *= temporary_number temporary_number -= 1 factorial_cache[a] = temporary_computation return factorial_cache[a] def factorial_sum(a: int) -> int: """Function to perform the sum of the factorial of all the digits in a >>> factorial_sum(69) 363600 """ if a in factorial_sum_cache: return factorial_sum_cache[a] # Prepare a variable to hold the computation fact_sum = 0 """ Convert a in string to iterate on its digits convert the digit back into an int and add its factorial to fact_sum. """ for i in str(a): fact_sum += factorial(int(i)) factorial_sum_cache[a] = fact_sum return fact_sum def solution(chain_length: int = 60, number_limit: int = 1000000) -> int: """Returns the number of numbers that produce chains with exactly 60 non repeating elements. >>> solution(10, 1000) 26 """ # the counter for the chains with the exact desired length chain_counter = 0 for i in range(1, number_limit + 1): # The temporary list will contain the elements of the chain chain_set = {i} len_chain_set = 1 last_chain_element = i # The new element of the chain new_chain_element = factorial_sum(last_chain_element) # Stop computing the chain when you find a repeating item # or the length it greater then the desired one. while new_chain_element not in chain_set and len_chain_set <= chain_length: chain_set.add(new_chain_element) len_chain_set += 1 last_chain_element = new_chain_element new_chain_element = factorial_sum(last_chain_element) # If the while exited because the chain list contains the exact amount # of elements increase the counter if len_chain_set == chain_length: chain_counter += 1 return chain_counter if __name__ == "__main__": import doctest doctest.testmod() print(f"{solution()}")
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Given a partially filled 9×9 2D array, the objective is to fill a 9×9 square grid with digits numbered 1 to 9, so that every row, column, and and each of the nine 3×3 sub-grids contains all of the digits. This can be solved using Backtracking and is similar to n-queens. We check to see if a cell is safe or not and recursively call the function on the next column to see if it returns True. if yes, we have solved the puzzle. else, we backtrack and place another number in that cell and repeat this process. """ from typing import List, Optional, Tuple Matrix = List[List[int]] # assigning initial values to the grid initial_grid: Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], [0, 5, 0, 0, 9, 0, 6, 0, 0], [1, 3, 0, 0, 0, 0, 2, 5, 0], [0, 0, 0, 0, 0, 0, 0, 7, 4], [0, 0, 5, 2, 0, 6, 3, 0, 0], ] # a grid with no solution no_solution: Matrix = [ [5, 0, 6, 5, 0, 8, 4, 0, 3], [5, 2, 0, 0, 0, 0, 0, 0, 2], [1, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], [0, 5, 0, 0, 9, 0, 6, 0, 0], [1, 3, 0, 0, 0, 0, 2, 5, 0], [0, 0, 0, 0, 0, 0, 0, 7, 4], [0, 0, 5, 2, 0, 6, 3, 0, 0], ] def is_safe(grid: Matrix, row: int, column: int, n: int) -> bool: """ This function checks the grid to see if each row, column, and the 3x3 subgrids contain the digit 'n'. It returns False if it is not 'safe' (a duplicate digit is found) else returns True if it is 'safe' """ for i in range(9): if grid[row][i] == n or grid[i][column] == n: return False for i in range(3): for j in range(3): if grid[(row - row % 3) + i][(column - column % 3) + j] == n: return False return True def is_completed(grid: Matrix) -> bool: """ This function checks if the puzzle is completed or not. it is completed when all the cells are assigned with a non-zero number. >>> is_completed([[0]]) False >>> is_completed([[1]]) True >>> is_completed([[1, 2], [0, 4]]) False >>> is_completed([[1, 2], [3, 4]]) True >>> is_completed(initial_grid) False >>> is_completed(no_solution) False """ return all(all(cell != 0 for cell in row) for row in grid) def find_empty_location(grid: Matrix) -> Optional[Tuple[int, int]]: """ This function finds an empty location so that we can assign a number for that particular row and column. """ for i in range(9): for j in range(9): if grid[i][j] == 0: return i, j return None def sudoku(grid: Matrix) -> Optional[Matrix]: """ Takes a partially filled-in grid and attempts to assign values to all unassigned locations in such a way to meet the requirements for Sudoku solution (non-duplication across rows, columns, and boxes) >>> sudoku(initial_grid) # doctest: +NORMALIZE_WHITESPACE [[3, 1, 6, 5, 7, 8, 4, 9, 2], [5, 2, 9, 1, 3, 4, 7, 6, 8], [4, 8, 7, 6, 2, 9, 5, 3, 1], [2, 6, 3, 4, 1, 5, 9, 8, 7], [9, 7, 4, 8, 6, 3, 1, 2, 5], [8, 5, 1, 7, 9, 2, 6, 4, 3], [1, 3, 8, 9, 4, 7, 2, 5, 6], [6, 9, 2, 3, 5, 1, 8, 7, 4], [7, 4, 5, 2, 8, 6, 3, 1, 9]] >>> sudoku(no_solution) is None True """ if is_completed(grid): return grid location = find_empty_location(grid) if location is not None: row, column = location else: # If the location is ``None``, then the grid is solved. return grid for digit in range(1, 10): if is_safe(grid, row, column, digit): grid[row][column] = digit if sudoku(grid) is not None: return grid grid[row][column] = 0 return None def print_solution(grid: Matrix) -> None: """ A function to print the solution in the form of a 9x9 grid """ for row in grid: for cell in row: print(cell, end=" ") print() if __name__ == "__main__": # make a copy of grid so that you can compare with the unmodified grid for example_grid in (initial_grid, no_solution): print("\nExample grid:\n" + "=" * 20) print_solution(example_grid) print("\nExample grid solution:") solution = sudoku(example_grid) if solution is not None: print_solution(solution) else: print("Cannot find a solution.")
""" Given a partially filled 9×9 2D array, the objective is to fill a 9×9 square grid with digits numbered 1 to 9, so that every row, column, and and each of the nine 3×3 sub-grids contains all of the digits. This can be solved using Backtracking and is similar to n-queens. We check to see if a cell is safe or not and recursively call the function on the next column to see if it returns True. if yes, we have solved the puzzle. else, we backtrack and place another number in that cell and repeat this process. """ from typing import List, Optional, Tuple Matrix = List[List[int]] # assigning initial values to the grid initial_grid: Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], [0, 5, 0, 0, 9, 0, 6, 0, 0], [1, 3, 0, 0, 0, 0, 2, 5, 0], [0, 0, 0, 0, 0, 0, 0, 7, 4], [0, 0, 5, 2, 0, 6, 3, 0, 0], ] # a grid with no solution no_solution: Matrix = [ [5, 0, 6, 5, 0, 8, 4, 0, 3], [5, 2, 0, 0, 0, 0, 0, 0, 2], [1, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], [0, 5, 0, 0, 9, 0, 6, 0, 0], [1, 3, 0, 0, 0, 0, 2, 5, 0], [0, 0, 0, 0, 0, 0, 0, 7, 4], [0, 0, 5, 2, 0, 6, 3, 0, 0], ] def is_safe(grid: Matrix, row: int, column: int, n: int) -> bool: """ This function checks the grid to see if each row, column, and the 3x3 subgrids contain the digit 'n'. It returns False if it is not 'safe' (a duplicate digit is found) else returns True if it is 'safe' """ for i in range(9): if grid[row][i] == n or grid[i][column] == n: return False for i in range(3): for j in range(3): if grid[(row - row % 3) + i][(column - column % 3) + j] == n: return False return True def is_completed(grid: Matrix) -> bool: """ This function checks if the puzzle is completed or not. it is completed when all the cells are assigned with a non-zero number. >>> is_completed([[0]]) False >>> is_completed([[1]]) True >>> is_completed([[1, 2], [0, 4]]) False >>> is_completed([[1, 2], [3, 4]]) True >>> is_completed(initial_grid) False >>> is_completed(no_solution) False """ return all(all(cell != 0 for cell in row) for row in grid) def find_empty_location(grid: Matrix) -> Optional[Tuple[int, int]]: """ This function finds an empty location so that we can assign a number for that particular row and column. """ for i in range(9): for j in range(9): if grid[i][j] == 0: return i, j return None def sudoku(grid: Matrix) -> Optional[Matrix]: """ Takes a partially filled-in grid and attempts to assign values to all unassigned locations in such a way to meet the requirements for Sudoku solution (non-duplication across rows, columns, and boxes) >>> sudoku(initial_grid) # doctest: +NORMALIZE_WHITESPACE [[3, 1, 6, 5, 7, 8, 4, 9, 2], [5, 2, 9, 1, 3, 4, 7, 6, 8], [4, 8, 7, 6, 2, 9, 5, 3, 1], [2, 6, 3, 4, 1, 5, 9, 8, 7], [9, 7, 4, 8, 6, 3, 1, 2, 5], [8, 5, 1, 7, 9, 2, 6, 4, 3], [1, 3, 8, 9, 4, 7, 2, 5, 6], [6, 9, 2, 3, 5, 1, 8, 7, 4], [7, 4, 5, 2, 8, 6, 3, 1, 9]] >>> sudoku(no_solution) is None True """ if is_completed(grid): return grid location = find_empty_location(grid) if location is not None: row, column = location else: # If the location is ``None``, then the grid is solved. return grid for digit in range(1, 10): if is_safe(grid, row, column, digit): grid[row][column] = digit if sudoku(grid) is not None: return grid grid[row][column] = 0 return None def print_solution(grid: Matrix) -> None: """ A function to print the solution in the form of a 9x9 grid """ for row in grid: for cell in row: print(cell, end=" ") print() if __name__ == "__main__": # make a copy of grid so that you can compare with the unmodified grid for example_grid in (initial_grid, no_solution): print("\nExample grid:\n" + "=" * 20) print_solution(example_grid) print("\nExample grid solution:") solution = sudoku(example_grid) if solution is not None: print_solution(solution) else: print("Cannot find a solution.")
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
import math def rearrange(bitString32): """[summary] Regroups the given binary string. Arguments: bitString32 {[string]} -- [32 bit binary] Raises: ValueError -- [if the given string not are 32 bit binary string] Returns: [string] -- [32 bit binary string] >>> rearrange('1234567890abcdfghijklmnopqrstuvw') 'pqrstuvwhijklmno90abcdfg12345678' """ if len(bitString32) != 32: raise ValueError("Need length 32") newString = "" for i in [3, 2, 1, 0]: newString += bitString32[8 * i : 8 * i + 8] return newString def reformatHex(i): """[summary] Converts the given integer into 8-digit hex number. Arguments: i {[int]} -- [integer] >>> reformatHex(666) '9a020000' """ hexrep = format(i, "08x") thing = "" for i in [3, 2, 1, 0]: thing += hexrep[2 * i : 2 * i + 2] return thing def pad(bitString): """[summary] Fills up the binary string to a 512 bit binary string Arguments: bitString {[string]} -- [binary string] Returns: [string] -- [binary string] """ startLength = len(bitString) bitString += "1" while len(bitString) % 512 != 448: bitString += "0" lastPart = format(startLength, "064b") bitString += rearrange(lastPart[32:]) + rearrange(lastPart[:32]) return bitString def getBlock(bitString): """[summary] Iterator: Returns by each call a list of length 16 with the 32 bit integer blocks. Arguments: bitString {[string]} -- [binary string >= 512] """ currPos = 0 while currPos < len(bitString): currPart = bitString[currPos : currPos + 512] mySplits = [] for i in range(16): mySplits.append(int(rearrange(currPart[32 * i : 32 * i + 32]), 2)) yield mySplits currPos += 512 def not32(i): """ >>> not32(34) 4294967261 """ i_str = format(i, "032b") new_str = "" for c in i_str: new_str += "1" if c == "0" else "0" return int(new_str, 2) def sum32(a, b): return (a + b) % 2 ** 32 def leftrot32(i, s): return (i << s) ^ (i >> (32 - s)) def md5me(testString): """[summary] Returns a 32-bit hash code of the string 'testString' Arguments: testString {[string]} -- [message] """ bs = "" for i in testString: bs += format(ord(i), "08b") bs = pad(bs) tvals = [int(2 ** 32 * abs(math.sin(i + 1))) for i in range(64)] a0 = 0x67452301 b0 = 0xEFCDAB89 c0 = 0x98BADCFE d0 = 0x10325476 s = [ 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, ] for m in getBlock(bs): A = a0 B = b0 C = c0 D = d0 for i in range(64): if i <= 15: # f = (B & C) | (not32(B) & D) f = D ^ (B & (C ^ D)) g = i elif i <= 31: # f = (D & B) | (not32(D) & C) f = C ^ (D & (B ^ C)) g = (5 * i + 1) % 16 elif i <= 47: f = B ^ C ^ D g = (3 * i + 5) % 16 else: f = C ^ (B | not32(D)) g = (7 * i) % 16 dtemp = D D = C C = B B = sum32(B, leftrot32((A + f + tvals[i] + m[g]) % 2 ** 32, s[i])) A = dtemp a0 = sum32(a0, A) b0 = sum32(b0, B) c0 = sum32(c0, C) d0 = sum32(d0, D) digest = reformatHex(a0) + reformatHex(b0) + reformatHex(c0) + reformatHex(d0) return digest def test(): assert md5me("") == "d41d8cd98f00b204e9800998ecf8427e" assert ( md5me("The quick brown fox jumps over the lazy dog") == "9e107d9d372bb6826bd81d3542a419d6" ) print("Success.") if __name__ == "__main__": test() import doctest doctest.testmod()
import math def rearrange(bitString32): """[summary] Regroups the given binary string. Arguments: bitString32 {[string]} -- [32 bit binary] Raises: ValueError -- [if the given string not are 32 bit binary string] Returns: [string] -- [32 bit binary string] >>> rearrange('1234567890abcdfghijklmnopqrstuvw') 'pqrstuvwhijklmno90abcdfg12345678' """ if len(bitString32) != 32: raise ValueError("Need length 32") newString = "" for i in [3, 2, 1, 0]: newString += bitString32[8 * i : 8 * i + 8] return newString def reformatHex(i): """[summary] Converts the given integer into 8-digit hex number. Arguments: i {[int]} -- [integer] >>> reformatHex(666) '9a020000' """ hexrep = format(i, "08x") thing = "" for i in [3, 2, 1, 0]: thing += hexrep[2 * i : 2 * i + 2] return thing def pad(bitString): """[summary] Fills up the binary string to a 512 bit binary string Arguments: bitString {[string]} -- [binary string] Returns: [string] -- [binary string] """ startLength = len(bitString) bitString += "1" while len(bitString) % 512 != 448: bitString += "0" lastPart = format(startLength, "064b") bitString += rearrange(lastPart[32:]) + rearrange(lastPart[:32]) return bitString def getBlock(bitString): """[summary] Iterator: Returns by each call a list of length 16 with the 32 bit integer blocks. Arguments: bitString {[string]} -- [binary string >= 512] """ currPos = 0 while currPos < len(bitString): currPart = bitString[currPos : currPos + 512] mySplits = [] for i in range(16): mySplits.append(int(rearrange(currPart[32 * i : 32 * i + 32]), 2)) yield mySplits currPos += 512 def not32(i): """ >>> not32(34) 4294967261 """ i_str = format(i, "032b") new_str = "" for c in i_str: new_str += "1" if c == "0" else "0" return int(new_str, 2) def sum32(a, b): return (a + b) % 2 ** 32 def leftrot32(i, s): return (i << s) ^ (i >> (32 - s)) def md5me(testString): """[summary] Returns a 32-bit hash code of the string 'testString' Arguments: testString {[string]} -- [message] """ bs = "" for i in testString: bs += format(ord(i), "08b") bs = pad(bs) tvals = [int(2 ** 32 * abs(math.sin(i + 1))) for i in range(64)] a0 = 0x67452301 b0 = 0xEFCDAB89 c0 = 0x98BADCFE d0 = 0x10325476 s = [ 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, ] for m in getBlock(bs): A = a0 B = b0 C = c0 D = d0 for i in range(64): if i <= 15: # f = (B & C) | (not32(B) & D) f = D ^ (B & (C ^ D)) g = i elif i <= 31: # f = (D & B) | (not32(D) & C) f = C ^ (D & (B ^ C)) g = (5 * i + 1) % 16 elif i <= 47: f = B ^ C ^ D g = (3 * i + 5) % 16 else: f = C ^ (B | not32(D)) g = (7 * i) % 16 dtemp = D D = C C = B B = sum32(B, leftrot32((A + f + tvals[i] + m[g]) % 2 ** 32, s[i])) A = dtemp a0 = sum32(a0, A) b0 = sum32(b0, B) c0 = sum32(c0, C) d0 = sum32(d0, D) digest = reformatHex(a0) + reformatHex(b0) + reformatHex(c0) + reformatHex(d0) return digest def test(): assert md5me("") == "d41d8cd98f00b204e9800998ecf8427e" assert ( md5me("The quick brown fox jumps over the lazy dog") == "9e107d9d372bb6826bd81d3542a419d6" ) print("Success.") if __name__ == "__main__": test() import doctest doctest.testmod()
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
from typing import List """ A naive recursive implementation of 0-1 Knapsack Problem https://en.wikipedia.org/wiki/Knapsack_problem """ def knapsack(capacity: int, weights: List[int], values: List[int], counter: int) -> int: """ Returns the maximum value that can be put in a knapsack of a capacity cap, whereby each weight w has a specific value val. >>> cap = 50 >>> val = [60, 100, 120] >>> w = [10, 20, 30] >>> c = len(val) >>> knapsack(cap, w, val, c) 220 The result is 220 cause the values of 100 and 120 got the weight of 50 which is the limit of the capacity. """ # Base Case if counter == 0 or capacity == 0: return 0 # If weight of the nth item is more than Knapsack of capacity, # then this item cannot be included in the optimal solution, # else return the maximum of two cases: # (1) nth item included # (2) not included if weights[counter - 1] > capacity: return knapsack(capacity, weights, values, counter - 1) else: left_capacity = capacity - weights[counter - 1] new_value_included = values[counter - 1] + knapsack( left_capacity, weights, values, counter - 1 ) without_new_value = knapsack(capacity, weights, values, counter - 1) return max(new_value_included, without_new_value) if __name__ == "__main__": import doctest doctest.testmod()
from typing import List """ A naive recursive implementation of 0-1 Knapsack Problem https://en.wikipedia.org/wiki/Knapsack_problem """ def knapsack(capacity: int, weights: List[int], values: List[int], counter: int) -> int: """ Returns the maximum value that can be put in a knapsack of a capacity cap, whereby each weight w has a specific value val. >>> cap = 50 >>> val = [60, 100, 120] >>> w = [10, 20, 30] >>> c = len(val) >>> knapsack(cap, w, val, c) 220 The result is 220 cause the values of 100 and 120 got the weight of 50 which is the limit of the capacity. """ # Base Case if counter == 0 or capacity == 0: return 0 # If weight of the nth item is more than Knapsack of capacity, # then this item cannot be included in the optimal solution, # else return the maximum of two cases: # (1) nth item included # (2) not included if weights[counter - 1] > capacity: return knapsack(capacity, weights, values, counter - 1) else: left_capacity = capacity - weights[counter - 1] new_value_included = values[counter - 1] + knapsack( left_capacity, weights, values, counter - 1 ) without_new_value = knapsack(capacity, weights, values, counter - 1) return max(new_value_included, without_new_value) if __name__ == "__main__": import doctest doctest.testmod()
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" In a multi-threaded download, this algorithm could be used to provide each worker thread with a block of non-overlapping bytes to download. For example: for i in allocation_list: requests.get(url,headers={'Range':f'bytes={i}'}) """ from __future__ import annotations def allocation_num(number_of_bytes: int, partitions: int) -> list[str]: """ Divide a number of bytes into x partitions. :param number_of_bytes: the total of bytes. :param partitions: the number of partition need to be allocated. :return: list of bytes to be assigned to each worker thread >>> allocation_num(16647, 4) ['1-4161', '4162-8322', '8323-12483', '12484-16647'] >>> allocation_num(50000, 5) ['1-10000', '10001-20000', '20001-30000', '30001-40000', '40001-50000'] >>> allocation_num(888, 999) Traceback (most recent call last): ... ValueError: partitions can not > number_of_bytes! >>> allocation_num(888, -4) Traceback (most recent call last): ... ValueError: partitions must be a positive number! """ if partitions <= 0: raise ValueError("partitions must be a positive number!") if partitions > number_of_bytes: raise ValueError("partitions can not > number_of_bytes!") bytes_per_partition = number_of_bytes // partitions allocation_list = [] for i in range(partitions): start_bytes = i * bytes_per_partition + 1 end_bytes = ( number_of_bytes if i == partitions - 1 else (i + 1) * bytes_per_partition ) allocation_list.append(f"{start_bytes}-{end_bytes}") return allocation_list if __name__ == "__main__": import doctest doctest.testmod()
""" In a multi-threaded download, this algorithm could be used to provide each worker thread with a block of non-overlapping bytes to download. For example: for i in allocation_list: requests.get(url,headers={'Range':f'bytes={i}'}) """ from __future__ import annotations def allocation_num(number_of_bytes: int, partitions: int) -> list[str]: """ Divide a number of bytes into x partitions. :param number_of_bytes: the total of bytes. :param partitions: the number of partition need to be allocated. :return: list of bytes to be assigned to each worker thread >>> allocation_num(16647, 4) ['1-4161', '4162-8322', '8323-12483', '12484-16647'] >>> allocation_num(50000, 5) ['1-10000', '10001-20000', '20001-30000', '30001-40000', '40001-50000'] >>> allocation_num(888, 999) Traceback (most recent call last): ... ValueError: partitions can not > number_of_bytes! >>> allocation_num(888, -4) Traceback (most recent call last): ... ValueError: partitions must be a positive number! """ if partitions <= 0: raise ValueError("partitions must be a positive number!") if partitions > number_of_bytes: raise ValueError("partitions can not > number_of_bytes!") bytes_per_partition = number_of_bytes // partitions allocation_list = [] for i in range(partitions): start_bytes = i * bytes_per_partition + 1 end_bytes = ( number_of_bytes if i == partitions - 1 else (i + 1) * bytes_per_partition ) allocation_list.append(f"{start_bytes}-{end_bytes}") return allocation_list if __name__ == "__main__": import doctest doctest.testmod()
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
__author__ = "Tobias Carryer" from time import time class LinearCongruentialGenerator: """ A pseudorandom number generator. """ def __init__(self, multiplier, increment, modulo, seed=int(time())): """ These parameters are saved and used when nextNumber() is called. modulo is the largest number that can be generated (exclusive). The most efficient values are powers of 2. 2^32 is a common value. """ self.multiplier = multiplier self.increment = increment self.modulo = modulo self.seed = seed def next_number(self): """ The smallest number that can be generated is zero. The largest number that can be generated is modulo-1. modulo is set in the constructor. """ self.seed = (self.multiplier * self.seed + self.increment) % self.modulo return self.seed if __name__ == "__main__": # Show the LCG in action. lcg = LinearCongruentialGenerator(1664525, 1013904223, 2 << 31) while True: print(lcg.next_number())
__author__ = "Tobias Carryer" from time import time class LinearCongruentialGenerator: """ A pseudorandom number generator. """ def __init__(self, multiplier, increment, modulo, seed=int(time())): """ These parameters are saved and used when nextNumber() is called. modulo is the largest number that can be generated (exclusive). The most efficient values are powers of 2. 2^32 is a common value. """ self.multiplier = multiplier self.increment = increment self.modulo = modulo self.seed = seed def next_number(self): """ The smallest number that can be generated is zero. The largest number that can be generated is modulo-1. modulo is set in the constructor. """ self.seed = (self.multiplier * self.seed + self.increment) % self.modulo return self.seed if __name__ == "__main__": # Show the LCG in action. lcg = LinearCongruentialGenerator(1664525, 1013904223, 2 << 31) while True: print(lcg.next_number())
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
# https://en.wikipedia.org/wiki/Continuous_knapsack_problem # https://www.guru99.com/fractional-knapsack-problem-greedy.html # https://medium.com/walkinthecode/greedy-algorithm-fractional-knapsack-problem-9aba1daecc93 from __future__ import annotations def fractional_knapsack( value: list[int], weight: list[int], capacity: int ) -> tuple[int, list[int]]: """ >>> value = [1, 3, 5, 7, 9] >>> weight = [0.9, 0.7, 0.5, 0.3, 0.1] >>> fractional_knapsack(value, weight, 5) (25, [1, 1, 1, 1, 1]) >>> fractional_knapsack(value, weight, 15) (25, [1, 1, 1, 1, 1]) >>> fractional_knapsack(value, weight, 25) (25, [1, 1, 1, 1, 1]) >>> fractional_knapsack(value, weight, 26) (25, [1, 1, 1, 1, 1]) >>> fractional_knapsack(value, weight, -1) (-90.0, [0, 0, 0, 0, -10.0]) >>> fractional_knapsack([1, 3, 5, 7], weight, 30) (16, [1, 1, 1, 1]) >>> fractional_knapsack(value, [0.9, 0.7, 0.5, 0.3, 0.1], 30) (25, [1, 1, 1, 1, 1]) >>> fractional_knapsack([], [], 30) (0, []) """ index = list(range(len(value))) ratio = [v / w for v, w in zip(value, weight)] index.sort(key=lambda i: ratio[i], reverse=True) max_value = 0 fractions = [0] * len(value) for i in index: if weight[i] <= capacity: fractions[i] = 1 max_value += value[i] capacity -= weight[i] else: fractions[i] = capacity / weight[i] max_value += value[i] * capacity / weight[i] break return max_value, fractions if __name__ == "__main__": n = int(input("Enter number of items: ")) value = input(f"Enter the values of the {n} item(s) in order: ").split() value = [int(v) for v in value] weight = input(f"Enter the positive weights of the {n} item(s) in order: ".split()) weight = [int(w) for w in weight] capacity = int(input("Enter maximum weight: ")) max_value, fractions = fractional_knapsack(value, weight, capacity) print("The maximum value of items that can be carried:", max_value) print("The fractions in which the items should be taken:", fractions)
# https://en.wikipedia.org/wiki/Continuous_knapsack_problem # https://www.guru99.com/fractional-knapsack-problem-greedy.html # https://medium.com/walkinthecode/greedy-algorithm-fractional-knapsack-problem-9aba1daecc93 from __future__ import annotations def fractional_knapsack( value: list[int], weight: list[int], capacity: int ) -> tuple[int, list[int]]: """ >>> value = [1, 3, 5, 7, 9] >>> weight = [0.9, 0.7, 0.5, 0.3, 0.1] >>> fractional_knapsack(value, weight, 5) (25, [1, 1, 1, 1, 1]) >>> fractional_knapsack(value, weight, 15) (25, [1, 1, 1, 1, 1]) >>> fractional_knapsack(value, weight, 25) (25, [1, 1, 1, 1, 1]) >>> fractional_knapsack(value, weight, 26) (25, [1, 1, 1, 1, 1]) >>> fractional_knapsack(value, weight, -1) (-90.0, [0, 0, 0, 0, -10.0]) >>> fractional_knapsack([1, 3, 5, 7], weight, 30) (16, [1, 1, 1, 1]) >>> fractional_knapsack(value, [0.9, 0.7, 0.5, 0.3, 0.1], 30) (25, [1, 1, 1, 1, 1]) >>> fractional_knapsack([], [], 30) (0, []) """ index = list(range(len(value))) ratio = [v / w for v, w in zip(value, weight)] index.sort(key=lambda i: ratio[i], reverse=True) max_value = 0 fractions = [0] * len(value) for i in index: if weight[i] <= capacity: fractions[i] = 1 max_value += value[i] capacity -= weight[i] else: fractions[i] = capacity / weight[i] max_value += value[i] * capacity / weight[i] break return max_value, fractions if __name__ == "__main__": n = int(input("Enter number of items: ")) value = input(f"Enter the values of the {n} item(s) in order: ").split() value = [int(v) for v in value] weight = input(f"Enter the positive weights of the {n} item(s) in order: ".split()) weight = [int(w) for w in weight] capacity = int(input("Enter maximum weight: ")) max_value, fractions = fractional_knapsack(value, weight, capacity) print("The maximum value of items that can be carried:", max_value) print("The fractions in which the items should be taken:", fractions)
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
# Video Explanation: https://www.youtube.com/watch?v=6w60Zi1NtL8&feature=emb_logo from __future__ import annotations def maximum_non_adjacent_sum(nums: list[int]) -> int: """ Find the maximum non-adjacent sum of the integers in the nums input list >>> print(maximum_non_adjacent_sum([1, 2, 3])) 4 >>> maximum_non_adjacent_sum([1, 5, 3, 7, 2, 2, 6]) 18 >>> maximum_non_adjacent_sum([-1, -5, -3, -7, -2, -2, -6]) 0 >>> maximum_non_adjacent_sum([499, 500, -3, -7, -2, -2, -6]) 500 """ if not nums: return 0 max_including = nums[0] max_excluding = 0 for num in nums[1:]: max_including, max_excluding = ( max_excluding + num, max(max_including, max_excluding), ) return max(max_excluding, max_including) if __name__ == "__main__": import doctest doctest.testmod()
# Video Explanation: https://www.youtube.com/watch?v=6w60Zi1NtL8&feature=emb_logo from __future__ import annotations def maximum_non_adjacent_sum(nums: list[int]) -> int: """ Find the maximum non-adjacent sum of the integers in the nums input list >>> print(maximum_non_adjacent_sum([1, 2, 3])) 4 >>> maximum_non_adjacent_sum([1, 5, 3, 7, 2, 2, 6]) 18 >>> maximum_non_adjacent_sum([-1, -5, -3, -7, -2, -2, -6]) 0 >>> maximum_non_adjacent_sum([499, 500, -3, -7, -2, -2, -6]) 500 """ if not nums: return 0 max_including = nums[0] max_excluding = 0 for num in nums[1:]: max_including, max_excluding = ( max_excluding + num, max(max_including, max_excluding), ) return max(max_excluding, max_including) if __name__ == "__main__": import doctest doctest.testmod()
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Problem 112: https://projecteuler.net/problem=112 Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a positive integer that is neither increasing nor decreasing a "bouncy" number, for example, 155349. Clearly there cannot be any bouncy numbers below one-hundred, but just over half of the numbers below one-thousand (525) are bouncy. In fact, the least number for which the proportion of bouncy numbers first reaches 50% is 538. Surprisingly, bouncy numbers become more and more common and by the time we reach 21780 the proportion of bouncy numbers is equal to 90%. Find the least number for which the proportion of bouncy numbers is exactly 99%. """ def check_bouncy(n: int) -> bool: """ Returns True if number is bouncy, False otherwise >>> check_bouncy(6789) False >>> check_bouncy(-12345) False >>> check_bouncy(0) False >>> check_bouncy(6.74) Traceback (most recent call last): ... ValueError: check_bouncy() accepts only integer arguments >>> check_bouncy(132475) True >>> check_bouncy(34) False >>> check_bouncy(341) True >>> check_bouncy(47) False >>> check_bouncy(-12.54) Traceback (most recent call last): ... ValueError: check_bouncy() accepts only integer arguments >>> check_bouncy(-6548) True """ if not isinstance(n, int): raise ValueError("check_bouncy() accepts only integer arguments") return "".join(sorted(str(n))) != str(n) and "".join(sorted(str(n)))[::-1] != str(n) def solution(percent: float = 99) -> int: """ Returns the least number for which the proportion of bouncy numbers is exactly 'percent' >>> solution(50) 538 >>> solution(90) 21780 >>> solution(80) 4770 >>> solution(105) Traceback (most recent call last): ... ValueError: solution() only accepts values from 0 to 100 >>> solution(100.011) Traceback (most recent call last): ... ValueError: solution() only accepts values from 0 to 100 """ if not 0 < percent < 100: raise ValueError("solution() only accepts values from 0 to 100") bouncy_num = 0 num = 1 while True: if check_bouncy(num): bouncy_num += 1 if (bouncy_num / num) * 100 >= percent: return num num += 1 if __name__ == "__main__": from doctest import testmod testmod() print(f"{solution(99)}")
""" Problem 112: https://projecteuler.net/problem=112 Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a positive integer that is neither increasing nor decreasing a "bouncy" number, for example, 155349. Clearly there cannot be any bouncy numbers below one-hundred, but just over half of the numbers below one-thousand (525) are bouncy. In fact, the least number for which the proportion of bouncy numbers first reaches 50% is 538. Surprisingly, bouncy numbers become more and more common and by the time we reach 21780 the proportion of bouncy numbers is equal to 90%. Find the least number for which the proportion of bouncy numbers is exactly 99%. """ def check_bouncy(n: int) -> bool: """ Returns True if number is bouncy, False otherwise >>> check_bouncy(6789) False >>> check_bouncy(-12345) False >>> check_bouncy(0) False >>> check_bouncy(6.74) Traceback (most recent call last): ... ValueError: check_bouncy() accepts only integer arguments >>> check_bouncy(132475) True >>> check_bouncy(34) False >>> check_bouncy(341) True >>> check_bouncy(47) False >>> check_bouncy(-12.54) Traceback (most recent call last): ... ValueError: check_bouncy() accepts only integer arguments >>> check_bouncy(-6548) True """ if not isinstance(n, int): raise ValueError("check_bouncy() accepts only integer arguments") return "".join(sorted(str(n))) != str(n) and "".join(sorted(str(n)))[::-1] != str(n) def solution(percent: float = 99) -> int: """ Returns the least number for which the proportion of bouncy numbers is exactly 'percent' >>> solution(50) 538 >>> solution(90) 21780 >>> solution(80) 4770 >>> solution(105) Traceback (most recent call last): ... ValueError: solution() only accepts values from 0 to 100 >>> solution(100.011) Traceback (most recent call last): ... ValueError: solution() only accepts values from 0 to 100 """ if not 0 < percent < 100: raise ValueError("solution() only accepts values from 0 to 100") bouncy_num = 0 num = 1 while True: if check_bouncy(num): bouncy_num += 1 if (bouncy_num / num) * 100 >= percent: return num num += 1 if __name__ == "__main__": from doctest import testmod testmod() print(f"{solution(99)}")
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
# Minimum cut on Ford_Fulkerson algorithm. test_graph = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def BFS(graph, s, t, parent): # Return True if there is node that has not iterated. visited = [False] * len(graph) queue = [s] visited[s] = True while queue: u = queue.pop(0) for ind in range(len(graph[u])): if visited[ind] is False and graph[u][ind] > 0: queue.append(ind) visited[ind] = True parent[ind] = u return True if visited[t] else False def mincut(graph, source, sink): """This array is filled by BFS and to store path >>> mincut(test_graph, source=0, sink=5) [(1, 3), (4, 3), (4, 5)] """ parent = [-1] * (len(graph)) max_flow = 0 res = [] temp = [i[:] for i in graph] # Record original cut, copy. while BFS(graph, source, sink, parent): path_flow = float("Inf") s = sink while s != source: # Find the minimum value in select path path_flow = min(path_flow, graph[parent[s]][s]) s = parent[s] max_flow += path_flow v = sink while v != source: u = parent[v] graph[u][v] -= path_flow graph[v][u] += path_flow v = parent[v] for i in range(len(graph)): for j in range(len(graph[0])): if graph[i][j] == 0 and temp[i][j] > 0: res.append((i, j)) return res if __name__ == "__main__": print(mincut(test_graph, source=0, sink=5))
# Minimum cut on Ford_Fulkerson algorithm. test_graph = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def BFS(graph, s, t, parent): # Return True if there is node that has not iterated. visited = [False] * len(graph) queue = [s] visited[s] = True while queue: u = queue.pop(0) for ind in range(len(graph[u])): if visited[ind] is False and graph[u][ind] > 0: queue.append(ind) visited[ind] = True parent[ind] = u return True if visited[t] else False def mincut(graph, source, sink): """This array is filled by BFS and to store path >>> mincut(test_graph, source=0, sink=5) [(1, 3), (4, 3), (4, 5)] """ parent = [-1] * (len(graph)) max_flow = 0 res = [] temp = [i[:] for i in graph] # Record original cut, copy. while BFS(graph, source, sink, parent): path_flow = float("Inf") s = sink while s != source: # Find the minimum value in select path path_flow = min(path_flow, graph[parent[s]][s]) s = parent[s] max_flow += path_flow v = sink while v != source: u = parent[v] graph[u][v] -= path_flow graph[v][u] += path_flow v = parent[v] for i in range(len(graph)): for j in range(len(graph[0])): if graph[i][j] == 0 and temp[i][j] > 0: res.append((i, j)) return res if __name__ == "__main__": print(mincut(test_graph, source=0, sink=5))
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
anirudnits
"2021-03-14T09:36:53Z"
"2021-06-08T20:49:33Z"
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [x] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [x] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [x] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
#
#
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
# https://en.m.wikipedia.org/wiki/Electric_power from collections import namedtuple def electric_power(voltage: float, current: float, power: float) -> float: """ This function can calculate any one of the three (voltage, current, power), fundamental value of electrical system. examples are below: >>> electric_power(voltage=0, current=2, power=5) result(name='voltage', value=2.5) >>> electric_power(voltage=2, current=2, power=0) result(name='power', value=4.0) >>> electric_power(voltage=-2, current=3, power=0) result(name='power', value=6.0) >>> electric_power(voltage=2, current=4, power=2) Traceback (most recent call last): File "<stdin>", line 15, in <module> ValueError: Only one argument must be 0 >>> electric_power(voltage=0, current=0, power=2) Traceback (most recent call last): File "<stdin>", line 19, in <module> ValueError: Only one argument must be 0 >>> electric_power(voltage=0, current=2, power=-4) Traceback (most recent call last): File "<stdin>", line 23, in <modulei ValueError: Power cannot be negative in any electrical/electronics system >>> electric_power(voltage=2.2, current=2.2, power=0) result(name='power', value=4.84) """ result = namedtuple("result", "name value") if (voltage, current, power).count(0) != 1: raise ValueError("Only one argument must be 0") elif power < 0: raise ValueError( "Power cannot be negative in any electrical/electronics system" ) elif voltage == 0: return result("voltage", power / current) elif current == 0: return result("current", power / voltage) elif power == 0: return result("power", float(round(abs(voltage * current), 2))) if __name__ == "__main__": import doctest doctest.testmod()
# https://en.m.wikipedia.org/wiki/Electric_power from collections import namedtuple from typing import Tuple def electric_power(voltage: float, current: float, power: float) -> Tuple: """ This function can calculate any one of the three (voltage, current, power), fundamental value of electrical system. examples are below: >>> electric_power(voltage=0, current=2, power=5) result(name='voltage', value=2.5) >>> electric_power(voltage=2, current=2, power=0) result(name='power', value=4.0) >>> electric_power(voltage=-2, current=3, power=0) result(name='power', value=6.0) >>> electric_power(voltage=2, current=4, power=2) Traceback (most recent call last): File "<stdin>", line 15, in <module> ValueError: Only one argument must be 0 >>> electric_power(voltage=0, current=0, power=2) Traceback (most recent call last): File "<stdin>", line 19, in <module> ValueError: Only one argument must be 0 >>> electric_power(voltage=0, current=2, power=-4) Traceback (most recent call last): File "<stdin>", line 23, in <modulei ValueError: Power cannot be negative in any electrical/electronics system >>> electric_power(voltage=2.2, current=2.2, power=0) result(name='power', value=4.84) """ result = namedtuple("result", "name value") if (voltage, current, power).count(0) != 1: raise ValueError("Only one argument must be 0") elif power < 0: raise ValueError( "Power cannot be negative in any electrical/electronics system" ) elif voltage == 0: return result("voltage", power / current) elif current == 0: return result("current", power / voltage) elif power == 0: return result("power", float(round(abs(voltage * current), 2))) if __name__ == "__main__": import doctest doctest.testmod()
1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
# https://en.wikipedia.org/wiki/Ohm%27s_law def ohms_law(voltage: float, current: float, resistance: float) -> float: """ Apply Ohm's Law, on any two given electrical values, which can be voltage, current, and resistance, and then in a Python dict return name/value pair of the zero value. >>> ohms_law(voltage=10, resistance=5, current=0) {'current': 2.0} >>> ohms_law(voltage=0, current=0, resistance=10) Traceback (most recent call last): ... ValueError: One and only one argument must be 0 >>> ohms_law(voltage=0, current=1, resistance=-2) Traceback (most recent call last): ... ValueError: Resistance cannot be negative >>> ohms_law(resistance=0, voltage=-10, current=1) {'resistance': -10.0} >>> ohms_law(voltage=0, current=-1.5, resistance=2) {'voltage': -3.0} """ if (voltage, current, resistance).count(0) != 1: raise ValueError("One and only one argument must be 0") if resistance < 0: raise ValueError("Resistance cannot be negative") if voltage == 0: return {"voltage": float(current * resistance)} elif current == 0: return {"current": voltage / resistance} elif resistance == 0: return {"resistance": voltage / current} if __name__ == "__main__": import doctest doctest.testmod()
# https://en.wikipedia.org/wiki/Ohm%27s_law from typing import Dict def ohms_law(voltage: float, current: float, resistance: float) -> Dict[str, float]: """ Apply Ohm's Law, on any two given electrical values, which can be voltage, current, and resistance, and then in a Python dict return name/value pair of the zero value. >>> ohms_law(voltage=10, resistance=5, current=0) {'current': 2.0} >>> ohms_law(voltage=0, current=0, resistance=10) Traceback (most recent call last): ... ValueError: One and only one argument must be 0 >>> ohms_law(voltage=0, current=1, resistance=-2) Traceback (most recent call last): ... ValueError: Resistance cannot be negative >>> ohms_law(resistance=0, voltage=-10, current=1) {'resistance': -10.0} >>> ohms_law(voltage=0, current=-1.5, resistance=2) {'voltage': -3.0} """ if (voltage, current, resistance).count(0) != 1: raise ValueError("One and only one argument must be 0") if resistance < 0: raise ValueError("Resistance cannot be negative") if voltage == 0: return {"voltage": float(current * resistance)} elif current == 0: return {"current": voltage / resistance} elif resistance == 0: return {"resistance": voltage / current} if __name__ == "__main__": import doctest doctest.testmod()
1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
# Implementation of First Come First Served scheduling algorithm # In this Algorithm we just care about the order that the processes arrived # without carring about their duration time # https://en.wikipedia.org/wiki/Scheduling_(computing)#First_come,_first_served from typing import List def calculate_waiting_times(duration_times: List[int]) -> List[int]: """ This function calculates the waiting time of some processes that have a specified duration time. Return: The waiting time for each process. >>> calculate_waiting_times([5, 10, 15]) [0, 5, 15] >>> calculate_waiting_times([1, 2, 3, 4, 5]) [0, 1, 3, 6, 10] >>> calculate_waiting_times([10, 3]) [0, 10] """ waiting_times = [0] * len(duration_times) for i in range(1, len(duration_times)): waiting_times[i] = duration_times[i - 1] + waiting_times[i - 1] return waiting_times def calculate_turnaround_times( duration_times: List[int], waiting_times: List[int] ) -> List[int]: """ This function calculates the turnaround time of some processes. Return: The time difference between the completion time and the arrival time. Practically waiting_time + duration_time >>> calculate_turnaround_times([5, 10, 15], [0, 5, 15]) [5, 15, 30] >>> calculate_turnaround_times([1, 2, 3, 4, 5], [0, 1, 3, 6, 10]) [1, 3, 6, 10, 15] >>> calculate_turnaround_times([10, 3], [0, 10]) [10, 13] """ return [ duration_time + waiting_times[i] for i, duration_time in enumerate(duration_times) ] def calculate_average_turnaround_time(turnaround_times: List[int]) -> float: """ This function calculates the average of the turnaround times Return: The average of the turnaround times. >>> calculate_average_turnaround_time([0, 5, 16]) 7.0 >>> calculate_average_turnaround_time([1, 5, 8, 12]) 6.5 >>> calculate_average_turnaround_time([10, 24]) 17.0 """ return sum(turnaround_times) / len(turnaround_times) def calculate_average_waiting_time(waiting_times: List[int]) -> float: """ This function calculates the average of the waiting times Return: The average of the waiting times. >>> calculate_average_waiting_time([0, 5, 16]) 7.0 >>> calculate_average_waiting_time([1, 5, 8, 12]) 6.5 >>> calculate_average_waiting_time([10, 24]) 17.0 """ return sum(waiting_times) / len(waiting_times) if __name__ == "__main__": # process id's processes = [1, 2, 3] # ensure that we actually have processes if len(processes) == 0: print("Zero amount of processes") exit() # duration time of all processes duration_times = [19, 8, 9] # ensure we can match each id to a duration time if len(duration_times) != len(processes): print("Unable to match all id's with their duration time") exit() # get the waiting times and the turnaround times waiting_times = calculate_waiting_times(duration_times) turnaround_times = calculate_turnaround_times(duration_times, waiting_times) # get the average times average_waiting_time = calculate_average_waiting_time(waiting_times) average_turnaround_time = calculate_average_turnaround_time(turnaround_times) # print all the results print("Process ID\tDuration Time\tWaiting Time\tTurnaround Time") for i, process in enumerate(processes): print( f"{process}\t\t{duration_times[i]}\t\t{waiting_times[i]}\t\t" f"{turnaround_times[i]}" ) print(f"Average waiting time = {average_waiting_time}") print(f"Average turn around time = {average_turnaround_time}")
# Implementation of First Come First Served scheduling algorithm # In this Algorithm we just care about the order that the processes arrived # without carring about their duration time # https://en.wikipedia.org/wiki/Scheduling_(computing)#First_come,_first_served from typing import List def calculate_waiting_times(duration_times: List[int]) -> List[int]: """ This function calculates the waiting time of some processes that have a specified duration time. Return: The waiting time for each process. >>> calculate_waiting_times([5, 10, 15]) [0, 5, 15] >>> calculate_waiting_times([1, 2, 3, 4, 5]) [0, 1, 3, 6, 10] >>> calculate_waiting_times([10, 3]) [0, 10] """ waiting_times = [0] * len(duration_times) for i in range(1, len(duration_times)): waiting_times[i] = duration_times[i - 1] + waiting_times[i - 1] return waiting_times def calculate_turnaround_times( duration_times: List[int], waiting_times: List[int] ) -> List[int]: """ This function calculates the turnaround time of some processes. Return: The time difference between the completion time and the arrival time. Practically waiting_time + duration_time >>> calculate_turnaround_times([5, 10, 15], [0, 5, 15]) [5, 15, 30] >>> calculate_turnaround_times([1, 2, 3, 4, 5], [0, 1, 3, 6, 10]) [1, 3, 6, 10, 15] >>> calculate_turnaround_times([10, 3], [0, 10]) [10, 13] """ return [ duration_time + waiting_times[i] for i, duration_time in enumerate(duration_times) ] def calculate_average_turnaround_time(turnaround_times: List[int]) -> float: """ This function calculates the average of the turnaround times Return: The average of the turnaround times. >>> calculate_average_turnaround_time([0, 5, 16]) 7.0 >>> calculate_average_turnaround_time([1, 5, 8, 12]) 6.5 >>> calculate_average_turnaround_time([10, 24]) 17.0 """ return sum(turnaround_times) / len(turnaround_times) def calculate_average_waiting_time(waiting_times: List[int]) -> float: """ This function calculates the average of the waiting times Return: The average of the waiting times. >>> calculate_average_waiting_time([0, 5, 16]) 7.0 >>> calculate_average_waiting_time([1, 5, 8, 12]) 6.5 >>> calculate_average_waiting_time([10, 24]) 17.0 """ return sum(waiting_times) / len(waiting_times) if __name__ == "__main__": # process id's processes = [1, 2, 3] # ensure that we actually have processes if len(processes) == 0: print("Zero amount of processes") exit() # duration time of all processes duration_times = [19, 8, 9] # ensure we can match each id to a duration time if len(duration_times) != len(processes): print("Unable to match all id's with their duration time") exit() # get the waiting times and the turnaround times waiting_times = calculate_waiting_times(duration_times) turnaround_times = calculate_turnaround_times(duration_times, waiting_times) # get the average times average_waiting_time = calculate_average_waiting_time(waiting_times) average_turnaround_time = calculate_average_turnaround_time(turnaround_times) # print all the results print("Process ID\tDuration Time\tWaiting Time\tTurnaround Time") for i, process in enumerate(processes): print( f"{process}\t\t{duration_times[i]}\t\t{waiting_times[i]}\t\t" f"{turnaround_times[i]}" ) print(f"Average waiting time = {average_waiting_time}") print(f"Average turn around time = {average_turnaround_time}")
1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Round Robin is a scheduling algorithm. In Round Robin each process is assigned a fixed time slot in a cyclic way. https://en.wikipedia.org/wiki/Round-robin_scheduling """ from statistics import mean from typing import List def calculate_waiting_times(burst_times: List[int]) -> List[int]: """ Calculate the waiting times of a list of processes that have a specified duration. Return: The waiting time for each process. >>> calculate_waiting_times([10, 5, 8]) [13, 10, 13] >>> calculate_waiting_times([4, 6, 3, 1]) [5, 8, 9, 6] >>> calculate_waiting_times([12, 2, 10]) [12, 2, 12] """ quantum = 2 rem_burst_times = list(burst_times) waiting_times = [0] * len(burst_times) t = 0 while True: done = True for i, burst_time in enumerate(burst_times): if rem_burst_times[i] > 0: done = False if rem_burst_times[i] > quantum: t += quantum rem_burst_times[i] -= quantum else: t += rem_burst_times[i] waiting_times[i] = t - burst_time rem_burst_times[i] = 0 if done is True: return waiting_times def calculate_turn_around_times( burst_times: List[int], waiting_times: List[int] ) -> List[int]: """ >>> calculate_turn_around_times([1, 2, 3, 4], [0, 1, 3]) [1, 3, 6] >>> calculate_turn_around_times([10, 3, 7], [10, 6, 11]) [20, 9, 18] """ return [burst + waiting for burst, waiting in zip(burst_times, waiting_times)] if __name__ == "__main__": burst_times = [3, 5, 7] waiting_times = calculate_waiting_times(burst_times) turn_around_times = calculate_turn_around_times(burst_times, waiting_times) print("Process ID \tBurst Time \tWaiting Time \tTurnaround Time") for i, burst_time in enumerate(burst_times): print( f" {i + 1}\t\t {burst_time}\t\t {waiting_times[i]}\t\t " f"{turn_around_times[i]}" ) print(f"\nAverage waiting time = {mean(waiting_times):.5f}") print(f"Average turn around time = {mean(turn_around_times):.5f}")
""" Round Robin is a scheduling algorithm. In Round Robin each process is assigned a fixed time slot in a cyclic way. https://en.wikipedia.org/wiki/Round-robin_scheduling """ from statistics import mean from typing import List def calculate_waiting_times(burst_times: List[int]) -> List[int]: """ Calculate the waiting times of a list of processes that have a specified duration. Return: The waiting time for each process. >>> calculate_waiting_times([10, 5, 8]) [13, 10, 13] >>> calculate_waiting_times([4, 6, 3, 1]) [5, 8, 9, 6] >>> calculate_waiting_times([12, 2, 10]) [12, 2, 12] """ quantum = 2 rem_burst_times = list(burst_times) waiting_times = [0] * len(burst_times) t = 0 while True: done = True for i, burst_time in enumerate(burst_times): if rem_burst_times[i] > 0: done = False if rem_burst_times[i] > quantum: t += quantum rem_burst_times[i] -= quantum else: t += rem_burst_times[i] waiting_times[i] = t - burst_time rem_burst_times[i] = 0 if done is True: return waiting_times def calculate_turn_around_times( burst_times: List[int], waiting_times: List[int] ) -> List[int]: """ >>> calculate_turn_around_times([1, 2, 3, 4], [0, 1, 3]) [1, 3, 6] >>> calculate_turn_around_times([10, 3, 7], [10, 6, 11]) [20, 9, 18] """ return [burst + waiting for burst, waiting in zip(burst_times, waiting_times)] if __name__ == "__main__": burst_times = [3, 5, 7] waiting_times = calculate_waiting_times(burst_times) turn_around_times = calculate_turn_around_times(burst_times, waiting_times) print("Process ID \tBurst Time \tWaiting Time \tTurnaround Time") for i, burst_time in enumerate(burst_times): print( f" {i + 1}\t\t {burst_time}\t\t {waiting_times[i]}\t\t " f"{turn_around_times[i]}" ) print(f"\nAverage waiting time = {mean(waiting_times):.5f}") print(f"Average turn around time = {mean(turn_around_times):.5f}")
1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Shortest job remaining first Please note arrival time and burst Please use spaces to separate times entered. """ from typing import List import pandas as pd def calculate_waitingtime( arrival_time: List[int], burst_time: List[int], no_of_processes: int ) -> List[int]: """ Calculate the waiting time of each processes Return: List of waiting times. >>> calculate_waitingtime([1,2,3,4],[3,3,5,1],4) [0, 3, 5, 0] >>> calculate_waitingtime([1,2,3],[2,5,1],3) [0, 2, 0] >>> calculate_waitingtime([2,3],[5,1],2) [1, 0] """ remaining_time = [0] * no_of_processes waiting_time = [0] * no_of_processes # Copy the burst time into remaining_time[] for i in range(no_of_processes): remaining_time[i] = burst_time[i] complete = 0 increment_time = 0 minm = 999999999 short = 0 check = False # Process until all processes are completed while complete != no_of_processes: for j in range(no_of_processes): if arrival_time[j] <= increment_time: if remaining_time[j] > 0: if remaining_time[j] < minm: minm = remaining_time[j] short = j check = True if not check: increment_time += 1 continue remaining_time[short] -= 1 minm = remaining_time[short] if minm == 0: minm = 999999999 if remaining_time[short] == 0: complete += 1 check = False # Find finish time of current process finish_time = increment_time + 1 # Calculate waiting time finar = finish_time - arrival_time[short] waiting_time[short] = finar - burst_time[short] if waiting_time[short] < 0: waiting_time[short] = 0 # Increment time increment_time += 1 return waiting_time def calculate_turnaroundtime( burst_time: List[int], no_of_processes: int, waiting_time: List[int] ) -> List[int]: """ Calculate the turn around time of each Processes Return: list of turn around times. >>> calculate_turnaroundtime([3,3,5,1], 4, [0,3,5,0]) [3, 6, 10, 1] >>> calculate_turnaroundtime([3,3], 2, [0,3]) [3, 6] >>> calculate_turnaroundtime([8,10,1], 3, [1,0,3]) [9, 10, 4] """ turn_around_time = [0] * no_of_processes for i in range(no_of_processes): turn_around_time[i] = burst_time[i] + waiting_time[i] return turn_around_time def calculate_average_times( waiting_time: List[int], turn_around_time: List[int], no_of_processes: int ) -> None: """ This function calculates the average of the waiting & turnaround times Prints: Average Waiting time & Average Turn Around Time >>> calculate_average_times([0,3,5,0],[3,6,10,1],4) Average waiting time = 2.00000 Average turn around time = 5.0 >>> calculate_average_times([2,3],[3,6],2) Average waiting time = 2.50000 Average turn around time = 4.5 >>> calculate_average_times([10,4,3],[2,7,6],3) Average waiting time = 5.66667 Average turn around time = 5.0 """ total_waiting_time = 0 total_turn_around_time = 0 for i in range(no_of_processes): total_waiting_time = total_waiting_time + waiting_time[i] total_turn_around_time = total_turn_around_time + turn_around_time[i] print("Average waiting time = %.5f" % (total_waiting_time / no_of_processes)) print("Average turn around time =", total_turn_around_time / no_of_processes) if __name__ == "__main__": print("Enter how many process you want to analyze") no_of_processes = int(input()) burst_time = [0] * no_of_processes arrival_time = [0] * no_of_processes processes = list(range(1, no_of_processes + 1)) for i in range(no_of_processes): print("Enter the arrival time and brust time for process:--" + str(i + 1)) arrival_time[i], burst_time[i] = map(int, input().split()) waiting_time = calculate_waitingtime(arrival_time, burst_time, no_of_processes) bt = burst_time n = no_of_processes wt = waiting_time turn_around_time = calculate_turnaroundtime(bt, n, wt) calculate_average_times(waiting_time, turn_around_time, no_of_processes) fcfs = pd.DataFrame( list(zip(processes, burst_time, arrival_time, waiting_time, turn_around_time)), columns=[ "Process", "BurstTime", "ArrivalTime", "WaitingTime", "TurnAroundTime", ], ) # Printing the dataFrame pd.set_option("display.max_rows", fcfs.shape[0] + 1) print(fcfs)
""" Shortest job remaining first Please note arrival time and burst Please use spaces to separate times entered. """ from typing import List import pandas as pd def calculate_waitingtime( arrival_time: List[int], burst_time: List[int], no_of_processes: int ) -> List[int]: """ Calculate the waiting time of each processes Return: List of waiting times. >>> calculate_waitingtime([1,2,3,4],[3,3,5,1],4) [0, 3, 5, 0] >>> calculate_waitingtime([1,2,3],[2,5,1],3) [0, 2, 0] >>> calculate_waitingtime([2,3],[5,1],2) [1, 0] """ remaining_time = [0] * no_of_processes waiting_time = [0] * no_of_processes # Copy the burst time into remaining_time[] for i in range(no_of_processes): remaining_time[i] = burst_time[i] complete = 0 increment_time = 0 minm = 999999999 short = 0 check = False # Process until all processes are completed while complete != no_of_processes: for j in range(no_of_processes): if arrival_time[j] <= increment_time: if remaining_time[j] > 0: if remaining_time[j] < minm: minm = remaining_time[j] short = j check = True if not check: increment_time += 1 continue remaining_time[short] -= 1 minm = remaining_time[short] if minm == 0: minm = 999999999 if remaining_time[short] == 0: complete += 1 check = False # Find finish time of current process finish_time = increment_time + 1 # Calculate waiting time finar = finish_time - arrival_time[short] waiting_time[short] = finar - burst_time[short] if waiting_time[short] < 0: waiting_time[short] = 0 # Increment time increment_time += 1 return waiting_time def calculate_turnaroundtime( burst_time: List[int], no_of_processes: int, waiting_time: List[int] ) -> List[int]: """ Calculate the turn around time of each Processes Return: list of turn around times. >>> calculate_turnaroundtime([3,3,5,1], 4, [0,3,5,0]) [3, 6, 10, 1] >>> calculate_turnaroundtime([3,3], 2, [0,3]) [3, 6] >>> calculate_turnaroundtime([8,10,1], 3, [1,0,3]) [9, 10, 4] """ turn_around_time = [0] * no_of_processes for i in range(no_of_processes): turn_around_time[i] = burst_time[i] + waiting_time[i] return turn_around_time def calculate_average_times( waiting_time: List[int], turn_around_time: List[int], no_of_processes: int ) -> None: """ This function calculates the average of the waiting & turnaround times Prints: Average Waiting time & Average Turn Around Time >>> calculate_average_times([0,3,5,0],[3,6,10,1],4) Average waiting time = 2.00000 Average turn around time = 5.0 >>> calculate_average_times([2,3],[3,6],2) Average waiting time = 2.50000 Average turn around time = 4.5 >>> calculate_average_times([10,4,3],[2,7,6],3) Average waiting time = 5.66667 Average turn around time = 5.0 """ total_waiting_time = 0 total_turn_around_time = 0 for i in range(no_of_processes): total_waiting_time = total_waiting_time + waiting_time[i] total_turn_around_time = total_turn_around_time + turn_around_time[i] print("Average waiting time = %.5f" % (total_waiting_time / no_of_processes)) print("Average turn around time =", total_turn_around_time / no_of_processes) if __name__ == "__main__": print("Enter how many process you want to analyze") no_of_processes = int(input()) burst_time = [0] * no_of_processes arrival_time = [0] * no_of_processes processes = list(range(1, no_of_processes + 1)) for i in range(no_of_processes): print("Enter the arrival time and brust time for process:--" + str(i + 1)) arrival_time[i], burst_time[i] = map(int, input().split()) waiting_time = calculate_waitingtime(arrival_time, burst_time, no_of_processes) bt = burst_time n = no_of_processes wt = waiting_time turn_around_time = calculate_turnaroundtime(bt, n, wt) calculate_average_times(waiting_time, turn_around_time, no_of_processes) fcfs = pd.DataFrame( list(zip(processes, burst_time, arrival_time, waiting_time, turn_around_time)), columns=[ "Process", "BurstTime", "ArrivalTime", "WaitingTime", "TurnAroundTime", ], ) # Printing the dataFrame pd.set_option("display.max_rows", fcfs.shape[0] + 1) print(fcfs)
1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" A Queue using a linked list like structure """ from typing import Any class Node: def __init__(self, data: Any) -> None: self.data = data self.next = None def __str__(self) -> str: return f"{self.data}" class LinkedQueue: """ >>> queue = LinkedQueue() >>> queue.is_empty() True >>> queue.put(5) >>> queue.put(9) >>> queue.put('python') >>> queue.is_empty(); False >>> queue.get() 5 >>> queue.put('algorithms') >>> queue.get() 9 >>> queue.get() 'python' >>> queue.get() 'algorithms' >>> queue.is_empty() True >>> queue.get() Traceback (most recent call last): ... IndexError: dequeue from empty queue """ def __init__(self) -> None: self.front = self.rear = None def __iter__(self): node = self.front while node: yield node.data node = node.next def __len__(self) -> int: """ >>> queue = LinkedQueue() >>> for i in range(1, 6): ... queue.put(i) >>> len(queue) 5 >>> for i in range(1, 6): ... assert len(queue) == 6 - i ... _ = queue.get() >>> len(queue) 0 """ return len(tuple(iter(self))) def __str__(self) -> str: """ >>> queue = LinkedQueue() >>> for i in range(1, 4): ... queue.put(i) >>> queue.put("Python") >>> queue.put(3.14) >>> queue.put(True) >>> str(queue) '1 <- 2 <- 3 <- Python <- 3.14 <- True' """ return " <- ".join(str(item) for item in self) def is_empty(self) -> bool: """ >>> queue = LinkedQueue() >>> queue.is_empty() True >>> for i in range(1, 6): ... queue.put(i) >>> queue.is_empty() False """ return len(self) == 0 def put(self, item) -> None: """ >>> queue = LinkedQueue() >>> queue.get() Traceback (most recent call last): ... IndexError: dequeue from empty queue >>> for i in range(1, 6): ... queue.put(i) >>> str(queue) '1 <- 2 <- 3 <- 4 <- 5' """ node = Node(item) if self.is_empty(): self.front = self.rear = node else: assert isinstance(self.rear, Node) self.rear.next = node self.rear = node def get(self) -> Any: """ >>> queue = LinkedQueue() >>> queue.get() Traceback (most recent call last): ... IndexError: dequeue from empty queue >>> queue = LinkedQueue() >>> for i in range(1, 6): ... queue.put(i) >>> for i in range(1, 6): ... assert queue.get() == i >>> len(queue) 0 """ if self.is_empty(): raise IndexError("dequeue from empty queue") assert isinstance(self.front, Node) node = self.front self.front = self.front.next if self.front is None: self.rear = None return node.data def clear(self) -> None: """ >>> queue = LinkedQueue() >>> for i in range(1, 6): ... queue.put(i) >>> queue.clear() >>> len(queue) 0 >>> str(queue) '' """ self.front = self.rear = None if __name__ == "__main__": from doctest import testmod testmod()
""" A Queue using a linked list like structure """ from typing import Any class Node: def __init__(self, data: Any) -> None: self.data = data self.next = None def __str__(self) -> str: return f"{self.data}" class LinkedQueue: """ >>> queue = LinkedQueue() >>> queue.is_empty() True >>> queue.put(5) >>> queue.put(9) >>> queue.put('python') >>> queue.is_empty(); False >>> queue.get() 5 >>> queue.put('algorithms') >>> queue.get() 9 >>> queue.get() 'python' >>> queue.get() 'algorithms' >>> queue.is_empty() True >>> queue.get() Traceback (most recent call last): ... IndexError: dequeue from empty queue """ def __init__(self) -> None: self.front = self.rear = None def __iter__(self): node = self.front while node: yield node.data node = node.next def __len__(self) -> int: """ >>> queue = LinkedQueue() >>> for i in range(1, 6): ... queue.put(i) >>> len(queue) 5 >>> for i in range(1, 6): ... assert len(queue) == 6 - i ... _ = queue.get() >>> len(queue) 0 """ return len(tuple(iter(self))) def __str__(self) -> str: """ >>> queue = LinkedQueue() >>> for i in range(1, 4): ... queue.put(i) >>> queue.put("Python") >>> queue.put(3.14) >>> queue.put(True) >>> str(queue) '1 <- 2 <- 3 <- Python <- 3.14 <- True' """ return " <- ".join(str(item) for item in self) def is_empty(self) -> bool: """ >>> queue = LinkedQueue() >>> queue.is_empty() True >>> for i in range(1, 6): ... queue.put(i) >>> queue.is_empty() False """ return len(self) == 0 def put(self, item) -> None: """ >>> queue = LinkedQueue() >>> queue.get() Traceback (most recent call last): ... IndexError: dequeue from empty queue >>> for i in range(1, 6): ... queue.put(i) >>> str(queue) '1 <- 2 <- 3 <- 4 <- 5' """ node = Node(item) if self.is_empty(): self.front = self.rear = node else: assert isinstance(self.rear, Node) self.rear.next = node self.rear = node def get(self) -> Any: """ >>> queue = LinkedQueue() >>> queue.get() Traceback (most recent call last): ... IndexError: dequeue from empty queue >>> queue = LinkedQueue() >>> for i in range(1, 6): ... queue.put(i) >>> for i in range(1, 6): ... assert queue.get() == i >>> len(queue) 0 """ if self.is_empty(): raise IndexError("dequeue from empty queue") assert isinstance(self.front, Node) node = self.front self.front = self.front.next if self.front is None: self.rear = None return node.data def clear(self) -> None: """ >>> queue = LinkedQueue() >>> for i in range(1, 6): ... queue.put(i) >>> queue.clear() >>> len(queue) 0 >>> str(queue) '' """ self.front = self.rear = None if __name__ == "__main__": from doctest import testmod testmod()
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" developed by: markmelnic original repo: https://github.com/markmelnic/Scoring-Algorithm Analyse data using a range based percentual proximity algorithm and calculate the linear maximum likelihood estimation. The basic principle is that all values supplied will be broken down to a range from 0 to 1 and each column's score will be added up to get the total score. ========== Example for data of vehicles price|mileage|registration_year 20k |60k |2012 22k |50k |2011 23k |90k |2015 16k |210k |2010 We want the vehicle with the lowest price, lowest mileage but newest registration year. Thus the weights for each column are as follows: [0, 0, 1] >>> procentual_proximity([[20, 60, 2012],[23, 90, 2015],[22, 50, 2011]], [0, 0, 1]) [[20, 60, 2012, 2.0], [23, 90, 2015, 1.0], [22, 50, 2011, 1.3333333333333335]] """ def procentual_proximity(source_data: list, weights: list) -> list: """ weights - int list possible values - 0 / 1 0 if lower values have higher weight in the data set 1 if higher values have higher weight in the data set """ # getting data data_lists = [] for item in source_data: for i in range(len(item)): try: data_lists[i].append(float(item[i])) except IndexError: # generate corresponding number of lists data_lists.append([]) data_lists[i].append(float(item[i])) score_lists = [] # calculating each score for dlist, weight in zip(data_lists, weights): mind = min(dlist) maxd = max(dlist) score = [] # for weight 0 score is 1 - actual score if weight == 0: for item in dlist: try: score.append(1 - ((item - mind) / (maxd - mind))) except ZeroDivisionError: score.append(1) elif weight == 1: for item in dlist: try: score.append((item - mind) / (maxd - mind)) except ZeroDivisionError: score.append(0) # weight not 0 or 1 else: raise ValueError("Invalid weight of %f provided" % (weight)) score_lists.append(score) # initialize final scores final_scores = [0 for i in range(len(score_lists[0]))] # generate final scores for i, slist in enumerate(score_lists): for j, ele in enumerate(slist): final_scores[j] = final_scores[j] + ele # append scores to source data for i, ele in enumerate(final_scores): source_data[i].append(ele) return source_data
""" developed by: markmelnic original repo: https://github.com/markmelnic/Scoring-Algorithm Analyse data using a range based percentual proximity algorithm and calculate the linear maximum likelihood estimation. The basic principle is that all values supplied will be broken down to a range from 0 to 1 and each column's score will be added up to get the total score. ========== Example for data of vehicles price|mileage|registration_year 20k |60k |2012 22k |50k |2011 23k |90k |2015 16k |210k |2010 We want the vehicle with the lowest price, lowest mileage but newest registration year. Thus the weights for each column are as follows: [0, 0, 1] >>> procentual_proximity([[20, 60, 2012],[23, 90, 2015],[22, 50, 2011]], [0, 0, 1]) [[20, 60, 2012, 2.0], [23, 90, 2015, 1.0], [22, 50, 2011, 1.3333333333333335]] """ def procentual_proximity(source_data: list, weights: list) -> list: """ weights - int list possible values - 0 / 1 0 if lower values have higher weight in the data set 1 if higher values have higher weight in the data set """ # getting data data_lists = [] for item in source_data: for i in range(len(item)): try: data_lists[i].append(float(item[i])) except IndexError: # generate corresponding number of lists data_lists.append([]) data_lists[i].append(float(item[i])) score_lists = [] # calculating each score for dlist, weight in zip(data_lists, weights): mind = min(dlist) maxd = max(dlist) score = [] # for weight 0 score is 1 - actual score if weight == 0: for item in dlist: try: score.append(1 - ((item - mind) / (maxd - mind))) except ZeroDivisionError: score.append(1) elif weight == 1: for item in dlist: try: score.append((item - mind) / (maxd - mind)) except ZeroDivisionError: score.append(0) # weight not 0 or 1 else: raise ValueError("Invalid weight of %f provided" % (weight)) score_lists.append(score) # initialize final scores final_scores = [0 for i in range(len(score_lists[0]))] # generate final scores for i, slist in enumerate(score_lists): for j, ele in enumerate(slist): final_scores[j] = final_scores[j] + ele # append scores to source data for i, ele in enumerate(final_scores): source_data[i].append(ele) return source_data
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
#!/usr/bin/env python3 """ Build a simple bare-minimum quantum circuit that starts with a single qubit (by default, in state 0) and inverts it. Run the experiment 1000 times and print the total count of the states finally observed. Qiskit Docs: https://qiskit.org/documentation/getting_started.html """ import qiskit as q def single_qubit_measure(qubits: int, classical_bits: int) -> q.result.counts.Counts: """ >>> single_qubit_measure(2, 2) {'11': 1000} >>> single_qubit_measure(4, 4) {'0011': 1000} """ # Use Aer's qasm_simulator simulator = q.Aer.get_backend("qasm_simulator") # Create a Quantum Circuit acting on the q register circuit = q.QuantumCircuit(qubits, classical_bits) # Apply X (NOT) Gate to Qubits 0 & 1 circuit.x(0) circuit.x(1) # Map the quantum measurement to the classical bits circuit.measure([0, 1], [0, 1]) # Execute the circuit on the qasm simulator job = q.execute(circuit, simulator, shots=1000) # Return the histogram data of the results of the experiment. return job.result().get_counts(circuit) if __name__ == "__main__": counts = single_qubit_measure(2, 2) print(f"Total count for various states are: {counts}")
#!/usr/bin/env python3 """ Build a simple bare-minimum quantum circuit that starts with a single qubit (by default, in state 0) and inverts it. Run the experiment 1000 times and print the total count of the states finally observed. Qiskit Docs: https://qiskit.org/documentation/getting_started.html """ import qiskit as q def single_qubit_measure(qubits: int, classical_bits: int) -> q.result.counts.Counts: """ >>> single_qubit_measure(2, 2) {'11': 1000} >>> single_qubit_measure(4, 4) {'0011': 1000} """ # Use Aer's qasm_simulator simulator = q.Aer.get_backend("qasm_simulator") # Create a Quantum Circuit acting on the q register circuit = q.QuantumCircuit(qubits, classical_bits) # Apply X (NOT) Gate to Qubits 0 & 1 circuit.x(0) circuit.x(1) # Map the quantum measurement to the classical bits circuit.measure([0, 1], [0, 1]) # Execute the circuit on the qasm simulator job = q.execute(circuit, simulator, shots=1000) # Return the histogram data of the results of the experiment. return job.result().get_counts(circuit) if __name__ == "__main__": counts = single_qubit_measure(2, 2) print(f"Total count for various states are: {counts}")
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
import operator def strand_sort(arr: list, reverse: bool = False, solution: list = None) -> list: """ Strand sort implementation source: https://en.wikipedia.org/wiki/Strand_sort :param arr: Unordered input list :param reverse: Descent ordering flag :param solution: Ordered items container Examples: >>> strand_sort([4, 2, 5, 3, 0, 1]) [0, 1, 2, 3, 4, 5] >>> strand_sort([4, 2, 5, 3, 0, 1], reverse=True) [5, 4, 3, 2, 1, 0] """ _operator = operator.lt if reverse else operator.gt solution = solution or [] if not arr: return solution sublist = [arr.pop(0)] for i, item in enumerate(arr): if _operator(item, sublist[-1]): sublist.append(item) arr.pop(i) # merging sublist into solution list if not solution: solution.extend(sublist) else: while sublist: item = sublist.pop(0) for i, xx in enumerate(solution): if not _operator(item, xx): solution.insert(i, item) break else: solution.append(item) strand_sort(arr, reverse, solution) return solution if __name__ == "__main__": assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5] assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]
import operator def strand_sort(arr: list, reverse: bool = False, solution: list = None) -> list: """ Strand sort implementation source: https://en.wikipedia.org/wiki/Strand_sort :param arr: Unordered input list :param reverse: Descent ordering flag :param solution: Ordered items container Examples: >>> strand_sort([4, 2, 5, 3, 0, 1]) [0, 1, 2, 3, 4, 5] >>> strand_sort([4, 2, 5, 3, 0, 1], reverse=True) [5, 4, 3, 2, 1, 0] """ _operator = operator.lt if reverse else operator.gt solution = solution or [] if not arr: return solution sublist = [arr.pop(0)] for i, item in enumerate(arr): if _operator(item, sublist[-1]): sublist.append(item) arr.pop(i) # merging sublist into solution list if not solution: solution.extend(sublist) else: while sublist: item = sublist.pop(0) for i, xx in enumerate(solution): if not _operator(item, xx): solution.insert(i, item) break else: solution.append(item) strand_sort(arr, reverse, solution) return solution if __name__ == "__main__": assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5] assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Project Euler Problem 7: https://projecteuler.net/problem=7 10001st prime By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? References: - https://en.wikipedia.org/wiki/Prime_number """ def isprime(number: int) -> bool: """ Determines whether the given number is prime or not >>> isprime(2) True >>> isprime(15) False >>> isprime(29) True """ for i in range(2, int(number ** 0.5) + 1): if number % i == 0: return False return True def solution(nth: int = 10001) -> int: """ Returns the n-th prime number. >>> solution(6) 13 >>> solution(1) 2 >>> solution(3) 5 >>> solution(20) 71 >>> solution(50) 229 >>> solution(100) 541 >>> solution(3.4) 5 >>> solution(0) Traceback (most recent call last): ... ValueError: Parameter nth must be greater than or equal to one. >>> solution(-17) Traceback (most recent call last): ... ValueError: Parameter nth must be greater than or equal to one. >>> solution([]) Traceback (most recent call last): ... TypeError: Parameter nth must be int or castable to int. >>> solution("asd") Traceback (most recent call last): ... TypeError: Parameter nth must be int or castable to int. """ try: nth = int(nth) except (TypeError, ValueError): raise TypeError("Parameter nth must be int or castable to int.") from None if nth <= 0: raise ValueError("Parameter nth must be greater than or equal to one.") primes = [] num = 2 while len(primes) < nth: if isprime(num): primes.append(num) num += 1 else: num += 1 return primes[len(primes) - 1] if __name__ == "__main__": print(f"{solution() = }")
""" Project Euler Problem 7: https://projecteuler.net/problem=7 10001st prime By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? References: - https://en.wikipedia.org/wiki/Prime_number """ def isprime(number: int) -> bool: """ Determines whether the given number is prime or not >>> isprime(2) True >>> isprime(15) False >>> isprime(29) True """ for i in range(2, int(number ** 0.5) + 1): if number % i == 0: return False return True def solution(nth: int = 10001) -> int: """ Returns the n-th prime number. >>> solution(6) 13 >>> solution(1) 2 >>> solution(3) 5 >>> solution(20) 71 >>> solution(50) 229 >>> solution(100) 541 >>> solution(3.4) 5 >>> solution(0) Traceback (most recent call last): ... ValueError: Parameter nth must be greater than or equal to one. >>> solution(-17) Traceback (most recent call last): ... ValueError: Parameter nth must be greater than or equal to one. >>> solution([]) Traceback (most recent call last): ... TypeError: Parameter nth must be int or castable to int. >>> solution("asd") Traceback (most recent call last): ... TypeError: Parameter nth must be int or castable to int. """ try: nth = int(nth) except (TypeError, ValueError): raise TypeError("Parameter nth must be int or castable to int.") from None if nth <= 0: raise ValueError("Parameter nth must be greater than or equal to one.") primes = [] num = 2 while len(primes) < nth: if isprime(num): primes.append(num) num += 1 else: num += 1 return primes[len(primes) - 1] if __name__ == "__main__": print(f"{solution() = }")
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
# flake8: noqa """ This is pure Python implementation of tree traversal algorithms """ from __future__ import annotations import queue class TreeNode: def __init__(self, data): self.data = data self.right = None self.left = None def build_tree(): print("\n********Press N to stop entering at any point of time********\n") check = input("Enter the value of the root node: ").strip().lower() or "n" if check == "n": return None q: queue.Queue = queue.Queue() tree_node = TreeNode(int(check)) q.put(tree_node) while not q.empty(): node_found = q.get() msg = "Enter the left node of %s: " % node_found.data check = input(msg).strip().lower() or "n" if check == "n": return tree_node left_node = TreeNode(int(check)) node_found.left = left_node q.put(left_node) msg = "Enter the right node of %s: " % node_found.data check = input(msg).strip().lower() or "n" if check == "n": return tree_node right_node = TreeNode(int(check)) node_found.right = right_node q.put(right_node) def pre_order(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> pre_order(root) 1,2,4,5,3,6,7, """ if not isinstance(node, TreeNode) or not node: return print(node.data, end=",") pre_order(node.left) pre_order(node.right) def in_order(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> in_order(root) 4,2,5,1,6,3,7, """ if not isinstance(node, TreeNode) or not node: return in_order(node.left) print(node.data, end=",") in_order(node.right) def post_order(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> post_order(root) 4,5,2,6,7,3,1, """ if not isinstance(node, TreeNode) or not node: return post_order(node.left) post_order(node.right) print(node.data, end=",") def level_order(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> level_order(root) 1,2,3,4,5,6,7, """ if not isinstance(node, TreeNode) or not node: return q: queue.Queue = queue.Queue() q.put(node) while not q.empty(): node_dequeued = q.get() print(node_dequeued.data, end=",") if node_dequeued.left: q.put(node_dequeued.left) if node_dequeued.right: q.put(node_dequeued.right) def level_order_actual(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> level_order_actual(root) 1, 2,3, 4,5,6,7, """ if not isinstance(node, TreeNode) or not node: return q: queue.Queue = queue.Queue() q.put(node) while not q.empty(): list = [] while not q.empty(): node_dequeued = q.get() print(node_dequeued.data, end=",") if node_dequeued.left: list.append(node_dequeued.left) if node_dequeued.right: list.append(node_dequeued.right) print() for node in list: q.put(node) # iteration version def pre_order_iter(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> pre_order_iter(root) 1,2,4,5,3,6,7, """ if not isinstance(node, TreeNode) or not node: return stack: List[TreeNode] = [] n = node while n or stack: while n: # start from root node, find its left child print(n.data, end=",") stack.append(n) n = n.left # end of while means current node doesn't have left child n = stack.pop() # start to traverse its right child n = n.right def in_order_iter(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> in_order_iter(root) 4,2,5,1,6,3,7, """ if not isinstance(node, TreeNode) or not node: return stack: List[TreeNode] = [] n = node while n or stack: while n: stack.append(n) n = n.left n = stack.pop() print(n.data, end=",") n = n.right def post_order_iter(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> post_order_iter(root) 4,5,2,6,7,3,1, """ if not isinstance(node, TreeNode) or not node: return stack1, stack2 = [], [] n = node stack1.append(n) while stack1: # to find the reversed order of post order, store it in stack2 n = stack1.pop() if n.left: stack1.append(n.left) if n.right: stack1.append(n.right) stack2.append(n) while stack2: # pop up from stack2 will be the post order print(stack2.pop().data, end=",") def prompt(s: str = "", width=50, char="*") -> str: if not s: return "\n" + width * char left, extra = divmod(width - len(s) - 2, 2) return f"{left * char} {s} {(left + extra) * char}" if __name__ == "__main__": import doctest doctest.testmod() print(prompt("Binary Tree Traversals")) node = build_tree() print(prompt("Pre Order Traversal")) pre_order(node) print(prompt() + "\n") print(prompt("In Order Traversal")) in_order(node) print(prompt() + "\n") print(prompt("Post Order Traversal")) post_order(node) print(prompt() + "\n") print(prompt("Level Order Traversal")) level_order(node) print(prompt() + "\n") print(prompt("Actual Level Order Traversal")) level_order_actual(node) print("*" * 50 + "\n") print(prompt("Pre Order Traversal - Iteration Version")) pre_order_iter(node) print(prompt() + "\n") print(prompt("In Order Traversal - Iteration Version")) in_order_iter(node) print(prompt() + "\n") print(prompt("Post Order Traversal - Iteration Version")) post_order_iter(node) print(prompt())
# flake8: noqa """ This is pure Python implementation of tree traversal algorithms """ from __future__ import annotations import queue class TreeNode: def __init__(self, data): self.data = data self.right = None self.left = None def build_tree(): print("\n********Press N to stop entering at any point of time********\n") check = input("Enter the value of the root node: ").strip().lower() or "n" if check == "n": return None q: queue.Queue = queue.Queue() tree_node = TreeNode(int(check)) q.put(tree_node) while not q.empty(): node_found = q.get() msg = "Enter the left node of %s: " % node_found.data check = input(msg).strip().lower() or "n" if check == "n": return tree_node left_node = TreeNode(int(check)) node_found.left = left_node q.put(left_node) msg = "Enter the right node of %s: " % node_found.data check = input(msg).strip().lower() or "n" if check == "n": return tree_node right_node = TreeNode(int(check)) node_found.right = right_node q.put(right_node) def pre_order(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> pre_order(root) 1,2,4,5,3,6,7, """ if not isinstance(node, TreeNode) or not node: return print(node.data, end=",") pre_order(node.left) pre_order(node.right) def in_order(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> in_order(root) 4,2,5,1,6,3,7, """ if not isinstance(node, TreeNode) or not node: return in_order(node.left) print(node.data, end=",") in_order(node.right) def post_order(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> post_order(root) 4,5,2,6,7,3,1, """ if not isinstance(node, TreeNode) or not node: return post_order(node.left) post_order(node.right) print(node.data, end=",") def level_order(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> level_order(root) 1,2,3,4,5,6,7, """ if not isinstance(node, TreeNode) or not node: return q: queue.Queue = queue.Queue() q.put(node) while not q.empty(): node_dequeued = q.get() print(node_dequeued.data, end=",") if node_dequeued.left: q.put(node_dequeued.left) if node_dequeued.right: q.put(node_dequeued.right) def level_order_actual(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> level_order_actual(root) 1, 2,3, 4,5,6,7, """ if not isinstance(node, TreeNode) or not node: return q: queue.Queue = queue.Queue() q.put(node) while not q.empty(): list = [] while not q.empty(): node_dequeued = q.get() print(node_dequeued.data, end=",") if node_dequeued.left: list.append(node_dequeued.left) if node_dequeued.right: list.append(node_dequeued.right) print() for node in list: q.put(node) # iteration version def pre_order_iter(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> pre_order_iter(root) 1,2,4,5,3,6,7, """ if not isinstance(node, TreeNode) or not node: return stack: List[TreeNode] = [] n = node while n or stack: while n: # start from root node, find its left child print(n.data, end=",") stack.append(n) n = n.left # end of while means current node doesn't have left child n = stack.pop() # start to traverse its right child n = n.right def in_order_iter(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> in_order_iter(root) 4,2,5,1,6,3,7, """ if not isinstance(node, TreeNode) or not node: return stack: List[TreeNode] = [] n = node while n or stack: while n: stack.append(n) n = n.left n = stack.pop() print(n.data, end=",") n = n.right def post_order_iter(node: TreeNode) -> None: """ >>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = TreeNode(5) >>> tree_node6 = TreeNode(6) >>> tree_node7 = TreeNode(7) >>> root.left, root.right = tree_node2, tree_node3 >>> tree_node2.left, tree_node2.right = tree_node4 , tree_node5 >>> tree_node3.left, tree_node3.right = tree_node6 , tree_node7 >>> post_order_iter(root) 4,5,2,6,7,3,1, """ if not isinstance(node, TreeNode) or not node: return stack1, stack2 = [], [] n = node stack1.append(n) while stack1: # to find the reversed order of post order, store it in stack2 n = stack1.pop() if n.left: stack1.append(n.left) if n.right: stack1.append(n.right) stack2.append(n) while stack2: # pop up from stack2 will be the post order print(stack2.pop().data, end=",") def prompt(s: str = "", width=50, char="*") -> str: if not s: return "\n" + width * char left, extra = divmod(width - len(s) - 2, 2) return f"{left * char} {s} {(left + extra) * char}" if __name__ == "__main__": import doctest doctest.testmod() print(prompt("Binary Tree Traversals")) node = build_tree() print(prompt("Pre Order Traversal")) pre_order(node) print(prompt() + "\n") print(prompt("In Order Traversal")) in_order(node) print(prompt() + "\n") print(prompt("Post Order Traversal")) post_order(node) print(prompt() + "\n") print(prompt("Level Order Traversal")) level_order(node) print(prompt() + "\n") print(prompt("Actual Level Order Traversal")) level_order_actual(node) print("*" * 50 + "\n") print(prompt("Pre Order Traversal - Iteration Version")) pre_order_iter(node) print(prompt() + "\n") print(prompt("In Order Traversal - Iteration Version")) in_order_iter(node) print(prompt() + "\n") print(prompt("Post Order Traversal - Iteration Version")) post_order_iter(node) print(prompt())
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance def lamberts_ellipsoidal_distance( lat1: float, lon1: float, lat2: float, lon2: float ) -> float: """ Calculate the shortest distance along the surface of an ellipsoid between two points on the surface of earth given longitudes and latitudes https://en.wikipedia.org/wiki/Geographical_distance#Lambert's_formula_for_long_lines NOTE: This algorithm uses geodesy/haversine_distance.py to compute central angle, sigma Representing the earth as an ellipsoid allows us to approximate distances between points on the surface much better than a sphere. Ellipsoidal formulas treat the Earth as an oblate ellipsoid which means accounting for the flattening that happens at the North and South poles. Lambert's formulae provide accuracy on the order of 10 meteres over thousands of kilometeres. Other methods can provide millimeter-level accuracy but this is a simpler method to calculate long range distances without increasing computational intensity. Args: lat1, lon1: latitude and longitude of coordinate 1 lat2, lon2: latitude and longitude of coordinate 2 Returns: geographical distance between two points in metres >>> from collections import namedtuple >>> point_2d = namedtuple("point_2d", "lat lon") >>> SAN_FRANCISCO = point_2d(37.774856, -122.424227) >>> YOSEMITE = point_2d(37.864742, -119.537521) >>> NEW_YORK = point_2d(40.713019, -74.012647) >>> VENICE = point_2d(45.443012, 12.313071) >>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *YOSEMITE):0,.0f} meters" '254,351 meters' >>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *NEW_YORK):0,.0f} meters" '4,138,992 meters' >>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *VENICE):0,.0f} meters" '9,737,326 meters' """ # CONSTANTS per WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System # Distance in metres(m) AXIS_A = 6378137.0 AXIS_B = 6356752.314245 EQUATORIAL_RADIUS = 6378137 # Equation Parameters # https://en.wikipedia.org/wiki/Geographical_distance#Lambert's_formula_for_long_lines flattening = (AXIS_A - AXIS_B) / AXIS_A # Parametric latitudes # https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude b_lat1 = atan((1 - flattening) * tan(radians(lat1))) b_lat2 = atan((1 - flattening) * tan(radians(lat2))) # Compute central angle between two points # using haversine theta. sigma = haversine_distance / equatorial radius sigma = haversine_distance(lat1, lon1, lat2, lon2) / EQUATORIAL_RADIUS # Intermediate P and Q values P_value = (b_lat1 + b_lat2) / 2 Q_value = (b_lat2 - b_lat1) / 2 # Intermediate X value # X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2) X_numerator = (sin(P_value) ** 2) * (cos(Q_value) ** 2) X_demonimator = cos(sigma / 2) ** 2 X_value = (sigma - sin(sigma)) * (X_numerator / X_demonimator) # Intermediate Y value # Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2) Y_numerator = (cos(P_value) ** 2) * (sin(Q_value) ** 2) Y_denominator = sin(sigma / 2) ** 2 Y_value = (sigma + sin(sigma)) * (Y_numerator / Y_denominator) return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (X_value + Y_value))) if __name__ == "__main__": import doctest doctest.testmod()
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance def lamberts_ellipsoidal_distance( lat1: float, lon1: float, lat2: float, lon2: float ) -> float: """ Calculate the shortest distance along the surface of an ellipsoid between two points on the surface of earth given longitudes and latitudes https://en.wikipedia.org/wiki/Geographical_distance#Lambert's_formula_for_long_lines NOTE: This algorithm uses geodesy/haversine_distance.py to compute central angle, sigma Representing the earth as an ellipsoid allows us to approximate distances between points on the surface much better than a sphere. Ellipsoidal formulas treat the Earth as an oblate ellipsoid which means accounting for the flattening that happens at the North and South poles. Lambert's formulae provide accuracy on the order of 10 meteres over thousands of kilometeres. Other methods can provide millimeter-level accuracy but this is a simpler method to calculate long range distances without increasing computational intensity. Args: lat1, lon1: latitude and longitude of coordinate 1 lat2, lon2: latitude and longitude of coordinate 2 Returns: geographical distance between two points in metres >>> from collections import namedtuple >>> point_2d = namedtuple("point_2d", "lat lon") >>> SAN_FRANCISCO = point_2d(37.774856, -122.424227) >>> YOSEMITE = point_2d(37.864742, -119.537521) >>> NEW_YORK = point_2d(40.713019, -74.012647) >>> VENICE = point_2d(45.443012, 12.313071) >>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *YOSEMITE):0,.0f} meters" '254,351 meters' >>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *NEW_YORK):0,.0f} meters" '4,138,992 meters' >>> f"{lamberts_ellipsoidal_distance(*SAN_FRANCISCO, *VENICE):0,.0f} meters" '9,737,326 meters' """ # CONSTANTS per WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System # Distance in metres(m) AXIS_A = 6378137.0 AXIS_B = 6356752.314245 EQUATORIAL_RADIUS = 6378137 # Equation Parameters # https://en.wikipedia.org/wiki/Geographical_distance#Lambert's_formula_for_long_lines flattening = (AXIS_A - AXIS_B) / AXIS_A # Parametric latitudes # https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude b_lat1 = atan((1 - flattening) * tan(radians(lat1))) b_lat2 = atan((1 - flattening) * tan(radians(lat2))) # Compute central angle between two points # using haversine theta. sigma = haversine_distance / equatorial radius sigma = haversine_distance(lat1, lon1, lat2, lon2) / EQUATORIAL_RADIUS # Intermediate P and Q values P_value = (b_lat1 + b_lat2) / 2 Q_value = (b_lat2 - b_lat1) / 2 # Intermediate X value # X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2) X_numerator = (sin(P_value) ** 2) * (cos(Q_value) ** 2) X_demonimator = cos(sigma / 2) ** 2 X_value = (sigma - sin(sigma)) * (X_numerator / X_demonimator) # Intermediate Y value # Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2) Y_numerator = (cos(P_value) ** 2) * (sin(Q_value) ** 2) Y_denominator = sin(sigma / 2) ** 2 Y_value = (sigma + sin(sigma)) * (Y_numerator / Y_denominator) return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (X_value + Y_value))) if __name__ == "__main__": import doctest doctest.testmod()
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Output: Enter an Infix Equation = a + b ^c Symbol | Stack | Postfix ---------------------------- c | | c ^ | ^ | c b | ^ | cb + | + | cb^ a | + | cb^a | | cb^a+ a+b^c (Infix) -> +a^bc (Prefix) """ def infix_2_postfix(Infix): Stack = [] Postfix = [] priority = { "^": 3, "*": 2, "/": 2, "%": 2, "+": 1, "-": 1, } # Priority of each operator print_width = len(Infix) if (len(Infix) > 7) else 7 # Print table header for output print( "Symbol".center(8), "Stack".center(print_width), "Postfix".center(print_width), sep=" | ", ) print("-" * (print_width * 3 + 7)) for x in Infix: if x.isalpha() or x.isdigit(): Postfix.append(x) # if x is Alphabet / Digit, add it to Postfix elif x == "(": Stack.append(x) # if x is "(" push to Stack elif x == ")": # if x is ")" pop stack until "(" is encountered while Stack[-1] != "(": Postfix.append(Stack.pop()) # Pop stack & add the content to Postfix Stack.pop() else: if len(Stack) == 0: Stack.append(x) # If stack is empty, push x to stack else: # while priority of x is not > priority of element in the stack while len(Stack) > 0 and priority[x] <= priority[Stack[-1]]: Postfix.append(Stack.pop()) # pop stack & add to Postfix Stack.append(x) # push x to stack print( x.center(8), ("".join(Stack)).ljust(print_width), ("".join(Postfix)).ljust(print_width), sep=" | ", ) # Output in tabular format while len(Stack) > 0: # while stack is not empty Postfix.append(Stack.pop()) # pop stack & add to Postfix print( " ".center(8), ("".join(Stack)).ljust(print_width), ("".join(Postfix)).ljust(print_width), sep=" | ", ) # Output in tabular format return "".join(Postfix) # return Postfix as str def infix_2_prefix(Infix): Infix = list(Infix[::-1]) # reverse the infix equation for i in range(len(Infix)): if Infix[i] == "(": Infix[i] = ")" # change "(" to ")" elif Infix[i] == ")": Infix[i] = "(" # change ")" to "(" return (infix_2_postfix("".join(Infix)))[ ::-1 ] # call infix_2_postfix on Infix, return reverse of Postfix if __name__ == "__main__": Infix = input("\nEnter an Infix Equation = ") # Input an Infix equation Infix = "".join(Infix.split()) # Remove spaces from the input print("\n\t", Infix, "(Infix) -> ", infix_2_prefix(Infix), "(Prefix)")
""" Output: Enter an Infix Equation = a + b ^c Symbol | Stack | Postfix ---------------------------- c | | c ^ | ^ | c b | ^ | cb + | + | cb^ a | + | cb^a | | cb^a+ a+b^c (Infix) -> +a^bc (Prefix) """ def infix_2_postfix(Infix): Stack = [] Postfix = [] priority = { "^": 3, "*": 2, "/": 2, "%": 2, "+": 1, "-": 1, } # Priority of each operator print_width = len(Infix) if (len(Infix) > 7) else 7 # Print table header for output print( "Symbol".center(8), "Stack".center(print_width), "Postfix".center(print_width), sep=" | ", ) print("-" * (print_width * 3 + 7)) for x in Infix: if x.isalpha() or x.isdigit(): Postfix.append(x) # if x is Alphabet / Digit, add it to Postfix elif x == "(": Stack.append(x) # if x is "(" push to Stack elif x == ")": # if x is ")" pop stack until "(" is encountered while Stack[-1] != "(": Postfix.append(Stack.pop()) # Pop stack & add the content to Postfix Stack.pop() else: if len(Stack) == 0: Stack.append(x) # If stack is empty, push x to stack else: # while priority of x is not > priority of element in the stack while len(Stack) > 0 and priority[x] <= priority[Stack[-1]]: Postfix.append(Stack.pop()) # pop stack & add to Postfix Stack.append(x) # push x to stack print( x.center(8), ("".join(Stack)).ljust(print_width), ("".join(Postfix)).ljust(print_width), sep=" | ", ) # Output in tabular format while len(Stack) > 0: # while stack is not empty Postfix.append(Stack.pop()) # pop stack & add to Postfix print( " ".center(8), ("".join(Stack)).ljust(print_width), ("".join(Postfix)).ljust(print_width), sep=" | ", ) # Output in tabular format return "".join(Postfix) # return Postfix as str def infix_2_prefix(Infix): Infix = list(Infix[::-1]) # reverse the infix equation for i in range(len(Infix)): if Infix[i] == "(": Infix[i] = ")" # change "(" to ")" elif Infix[i] == ")": Infix[i] = "(" # change ")" to "(" return (infix_2_postfix("".join(Infix)))[ ::-1 ] # call infix_2_postfix on Infix, return reverse of Postfix if __name__ == "__main__": Infix = input("\nEnter an Infix Equation = ") # Input an Infix equation Infix = "".join(Infix.split()) # Remove spaces from the input print("\n\t", Infix, "(Infix) -> ", infix_2_prefix(Infix), "(Prefix)")
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Project Euler Problem 3: https://projecteuler.net/problem=3 Largest prime factor The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? References: - https://en.wikipedia.org/wiki/Prime_number#Unique_factorization """ import math def isprime(num: int) -> bool: """ Returns boolean representing primality of given number num. >>> isprime(2) True >>> isprime(3) True >>> isprime(27) False >>> isprime(2999) True >>> isprime(0) Traceback (most recent call last): ... ValueError: Parameter num must be greater than or equal to two. >>> isprime(1) Traceback (most recent call last): ... ValueError: Parameter num must be greater than or equal to two. """ if num <= 1: raise ValueError("Parameter num must be greater than or equal to two.") if num == 2: return True elif num % 2 == 0: return False for i in range(3, int(math.sqrt(num)) + 1, 2): if num % i == 0: return False return True def solution(n: int = 600851475143) -> int: """ Returns the largest prime factor of a given number n. >>> solution(13195) 29 >>> solution(10) 5 >>> solution(17) 17 >>> solution(3.4) 3 >>> solution(0) Traceback (most recent call last): ... ValueError: Parameter n must be greater than or equal to one. >>> solution(-17) Traceback (most recent call last): ... ValueError: Parameter n must be greater than or equal to one. >>> solution([]) Traceback (most recent call last): ... TypeError: Parameter n must be int or castable to int. >>> solution("asd") Traceback (most recent call last): ... TypeError: Parameter n must be int or castable to int. """ try: n = int(n) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int.") if n <= 0: raise ValueError("Parameter n must be greater than or equal to one.") max_number = 0 if isprime(n): return n while n % 2 == 0: n //= 2 if isprime(n): return n for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: if isprime(n / i): max_number = n / i break elif isprime(i): max_number = i return max_number if __name__ == "__main__": print(f"{solution() = }")
""" Project Euler Problem 3: https://projecteuler.net/problem=3 Largest prime factor The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? References: - https://en.wikipedia.org/wiki/Prime_number#Unique_factorization """ import math def isprime(num: int) -> bool: """ Returns boolean representing primality of given number num. >>> isprime(2) True >>> isprime(3) True >>> isprime(27) False >>> isprime(2999) True >>> isprime(0) Traceback (most recent call last): ... ValueError: Parameter num must be greater than or equal to two. >>> isprime(1) Traceback (most recent call last): ... ValueError: Parameter num must be greater than or equal to two. """ if num <= 1: raise ValueError("Parameter num must be greater than or equal to two.") if num == 2: return True elif num % 2 == 0: return False for i in range(3, int(math.sqrt(num)) + 1, 2): if num % i == 0: return False return True def solution(n: int = 600851475143) -> int: """ Returns the largest prime factor of a given number n. >>> solution(13195) 29 >>> solution(10) 5 >>> solution(17) 17 >>> solution(3.4) 3 >>> solution(0) Traceback (most recent call last): ... ValueError: Parameter n must be greater than or equal to one. >>> solution(-17) Traceback (most recent call last): ... ValueError: Parameter n must be greater than or equal to one. >>> solution([]) Traceback (most recent call last): ... TypeError: Parameter n must be int or castable to int. >>> solution("asd") Traceback (most recent call last): ... TypeError: Parameter n must be int or castable to int. """ try: n = int(n) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int.") if n <= 0: raise ValueError("Parameter n must be greater than or equal to one.") max_number = 0 if isprime(n): return n while n % 2 == 0: n //= 2 if isprime(n): return n for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: if isprime(n / i): max_number = n / i break elif isprime(i): max_number = i return max_number if __name__ == "__main__": print(f"{solution() = }")
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
def search(list_data: list, key: int, left: int = 0, right: int = 0) -> int: """ Iterate through the array to find the index of key using recursion. :param list_data: the list to be searched :param key: the key to be searched :param left: the index of first element :param right: the index of last element :return: the index of key value if found, -1 otherwise. >>> search(list(range(0, 11)), 5) 5 >>> search([1, 2, 4, 5, 3], 4) 2 >>> search([1, 2, 4, 5, 3], 6) -1 >>> search([5], 5) 0 >>> search([], 1) -1 """ right = right or len(list_data) - 1 if left > right: return -1 elif list_data[left] == key: return left elif list_data[right] == key: return right else: return search(list_data, key, left + 1, right - 1) if __name__ == "__main__": import doctest doctest.testmod()
def search(list_data: list, key: int, left: int = 0, right: int = 0) -> int: """ Iterate through the array to find the index of key using recursion. :param list_data: the list to be searched :param key: the key to be searched :param left: the index of first element :param right: the index of last element :return: the index of key value if found, -1 otherwise. >>> search(list(range(0, 11)), 5) 5 >>> search([1, 2, 4, 5, 3], 4) 2 >>> search([1, 2, 4, 5, 3], 6) -1 >>> search([5], 5) 0 >>> search([], 1) -1 """ right = right or len(list_data) - 1 if left > right: return -1 elif list_data[left] == key: return left elif list_data[right] == key: return right else: return search(list_data, key, left + 1, right - 1) if __name__ == "__main__": import doctest doctest.testmod()
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Author : Yvonne This is a pure Python implementation of Dynamic Programming solution to the longest_sub_array problem. The problem is : Given an array, to find the longest and continuous sub array and get the max sum of the sub array in the given array. """ class SubArray: def __init__(self, arr): # we need a list not a string, so do something to change the type self.array = arr.split(",") print(("the input array is:", self.array)) def solve_sub_array(self): rear = [int(self.array[0])] * len(self.array) sum_value = [int(self.array[0])] * len(self.array) for i in range(1, len(self.array)): sum_value[i] = max( int(self.array[i]) + sum_value[i - 1], int(self.array[i]) ) rear[i] = max(sum_value[i], rear[i - 1]) return rear[len(self.array) - 1] if __name__ == "__main__": whole_array = input("please input some numbers:") array = SubArray(whole_array) re = array.solve_sub_array() print(("the results is:", re))
""" Author : Yvonne This is a pure Python implementation of Dynamic Programming solution to the longest_sub_array problem. The problem is : Given an array, to find the longest and continuous sub array and get the max sum of the sub array in the given array. """ class SubArray: def __init__(self, arr): # we need a list not a string, so do something to change the type self.array = arr.split(",") print(("the input array is:", self.array)) def solve_sub_array(self): rear = [int(self.array[0])] * len(self.array) sum_value = [int(self.array[0])] * len(self.array) for i in range(1, len(self.array)): sum_value[i] = max( int(self.array[i]) + sum_value[i - 1], int(self.array[i]) ) rear[i] = max(sum_value[i], rear[i - 1]) return rear[len(self.array) - 1] if __name__ == "__main__": whole_array = input("please input some numbers:") array = SubArray(whole_array) re = array.solve_sub_array() print(("the results is:", re))
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
#!/usr/bin/env python3 import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths filepaths = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" upper_files = [file for file in filepaths if file != file.lower()] if upper_files: print(f"{len(upper_files)} files contain uppercase characters:") print("\n".join(upper_files) + "\n") space_files = [file for file in filepaths if " " in file] if space_files: print(f"{len(space_files)} files contain space characters:") print("\n".join(space_files) + "\n") hyphen_files = [file for file in filepaths if "-" in file] if hyphen_files: print(f"{len(hyphen_files)} files contain hyphen characters:") print("\n".join(hyphen_files) + "\n") nodir_files = [file for file in filepaths if os.sep not in file] if nodir_files: print(f"{len(nodir_files)} files are not in a directory:") print("\n".join(nodir_files) + "\n") bad_files = len(upper_files + space_files + hyphen_files + nodir_files) if bad_files: import sys sys.exit(bad_files)
#!/usr/bin/env python3 import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths filepaths = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" upper_files = [file for file in filepaths if file != file.lower()] if upper_files: print(f"{len(upper_files)} files contain uppercase characters:") print("\n".join(upper_files) + "\n") space_files = [file for file in filepaths if " " in file] if space_files: print(f"{len(space_files)} files contain space characters:") print("\n".join(space_files) + "\n") hyphen_files = [file for file in filepaths if "-" in file] if hyphen_files: print(f"{len(hyphen_files)} files contain hyphen characters:") print("\n".join(hyphen_files) + "\n") nodir_files = [file for file in filepaths if os.sep not in file] if nodir_files: print(f"{len(nodir_files)} files are not in a directory:") print("\n".join(nodir_files) + "\n") bad_files = len(upper_files + space_files + hyphen_files + nodir_files) if bad_files: import sys sys.exit(bad_files)
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" https://en.wikipedia.org/wiki/Doubly_linked_list """ class Node: def __init__(self, data): self.data = data self.previous = None self.next = None def __str__(self): return f"{self.data}" class DoublyLinkedList: def __init__(self): self.head = None self.tail = None def __iter__(self): """ >>> linked_list = DoublyLinkedList() >>> linked_list.insert_at_head('b') >>> linked_list.insert_at_head('a') >>> linked_list.insert_at_tail('c') >>> tuple(linked_list) ('a', 'b', 'c') """ node = self.head while node: yield node.data node = node.next def __str__(self): """ >>> linked_list = DoublyLinkedList() >>> linked_list.insert_at_tail('a') >>> linked_list.insert_at_tail('b') >>> linked_list.insert_at_tail('c') >>> str(linked_list) 'a->b->c' """ return "->".join([str(item) for item in self]) def __len__(self): """ >>> linked_list = DoublyLinkedList() >>> for i in range(0, 5): ... linked_list.insert_at_nth(i, i + 1) >>> len(linked_list) == 5 True """ return len(tuple(iter(self))) def insert_at_head(self, data): self.insert_at_nth(0, data) def insert_at_tail(self, data): self.insert_at_nth(len(self), data) def insert_at_nth(self, index: int, data): """ >>> linked_list = DoublyLinkedList() >>> linked_list.insert_at_nth(-1, 666) Traceback (most recent call last): .... IndexError: list index out of range >>> linked_list.insert_at_nth(1, 666) Traceback (most recent call last): .... IndexError: list index out of range >>> linked_list.insert_at_nth(0, 2) >>> linked_list.insert_at_nth(0, 1) >>> linked_list.insert_at_nth(2, 4) >>> linked_list.insert_at_nth(2, 3) >>> str(linked_list) '1->2->3->4' >>> linked_list.insert_at_nth(5, 5) Traceback (most recent call last): .... IndexError: list index out of range """ if not 0 <= index <= len(self): raise IndexError("list index out of range") new_node = Node(data) if self.head is None: self.head = self.tail = new_node elif index == 0: self.head.previous = new_node new_node.next = self.head self.head = new_node elif index == len(self): self.tail.next = new_node new_node.previous = self.tail self.tail = new_node else: temp = self.head for i in range(0, index): temp = temp.next temp.previous.next = new_node new_node.previous = temp.previous new_node.next = temp temp.previous = new_node def delete_head(self): return self.delete_at_nth(0) def delete_tail(self): return self.delete_at_nth(len(self) - 1) def delete_at_nth(self, index: int): """ >>> linked_list = DoublyLinkedList() >>> linked_list.delete_at_nth(0) Traceback (most recent call last): .... IndexError: list index out of range >>> for i in range(0, 5): ... linked_list.insert_at_nth(i, i + 1) >>> linked_list.delete_at_nth(0) == 1 True >>> linked_list.delete_at_nth(3) == 5 True >>> linked_list.delete_at_nth(1) == 3 True >>> str(linked_list) '2->4' >>> linked_list.delete_at_nth(2) Traceback (most recent call last): .... IndexError: list index out of range """ if not 0 <= index <= len(self) - 1: raise IndexError("list index out of range") delete_node = self.head # default first node if len(self) == 1: self.head = self.tail = None elif index == 0: self.head = self.head.next self.head.previous = None elif index == len(self) - 1: delete_node = self.tail self.tail = self.tail.previous self.tail.next = None else: temp = self.head for i in range(0, index): temp = temp.next delete_node = temp temp.next.previous = temp.previous temp.previous.next = temp.next return delete_node.data def delete(self, data) -> str: current = self.head while current.data != data: # Find the position to delete if current.next: current = current.next else: # We have reached the end an no value matches return "No data matching given value" if current == self.head: self.delete_head() elif current == self.tail: self.delete_tail() else: # Before: 1 <--> 2(current) <--> 3 current.previous.next = current.next # 1 --> 3 current.next.previous = current.previous # 1 <--> 3 return data def is_empty(self): """ >>> linked_list = DoublyLinkedList() >>> linked_list.is_empty() True >>> linked_list.insert_at_tail(1) >>> linked_list.is_empty() False """ return len(self) == 0 def test_doubly_linked_list() -> None: """ >>> test_doubly_linked_list() """ linked_list = DoublyLinkedList() assert linked_list.is_empty() is True assert str(linked_list) == "" try: linked_list.delete_head() assert False # This should not happen. except IndexError: assert True # This should happen. try: linked_list.delete_tail() assert False # This should not happen. except IndexError: assert True # This should happen. for i in range(10): assert len(linked_list) == i linked_list.insert_at_nth(i, i + 1) assert str(linked_list) == "->".join(str(i) for i in range(1, 11)) linked_list.insert_at_head(0) linked_list.insert_at_tail(11) assert str(linked_list) == "->".join(str(i) for i in range(0, 12)) assert linked_list.delete_head() == 0 assert linked_list.delete_at_nth(9) == 10 assert linked_list.delete_tail() == 11 assert len(linked_list) == 9 assert str(linked_list) == "->".join(str(i) for i in range(1, 10)) if __name__ == "__main__": from doctest import testmod testmod()
""" https://en.wikipedia.org/wiki/Doubly_linked_list """ class Node: def __init__(self, data): self.data = data self.previous = None self.next = None def __str__(self): return f"{self.data}" class DoublyLinkedList: def __init__(self): self.head = None self.tail = None def __iter__(self): """ >>> linked_list = DoublyLinkedList() >>> linked_list.insert_at_head('b') >>> linked_list.insert_at_head('a') >>> linked_list.insert_at_tail('c') >>> tuple(linked_list) ('a', 'b', 'c') """ node = self.head while node: yield node.data node = node.next def __str__(self): """ >>> linked_list = DoublyLinkedList() >>> linked_list.insert_at_tail('a') >>> linked_list.insert_at_tail('b') >>> linked_list.insert_at_tail('c') >>> str(linked_list) 'a->b->c' """ return "->".join([str(item) for item in self]) def __len__(self): """ >>> linked_list = DoublyLinkedList() >>> for i in range(0, 5): ... linked_list.insert_at_nth(i, i + 1) >>> len(linked_list) == 5 True """ return len(tuple(iter(self))) def insert_at_head(self, data): self.insert_at_nth(0, data) def insert_at_tail(self, data): self.insert_at_nth(len(self), data) def insert_at_nth(self, index: int, data): """ >>> linked_list = DoublyLinkedList() >>> linked_list.insert_at_nth(-1, 666) Traceback (most recent call last): .... IndexError: list index out of range >>> linked_list.insert_at_nth(1, 666) Traceback (most recent call last): .... IndexError: list index out of range >>> linked_list.insert_at_nth(0, 2) >>> linked_list.insert_at_nth(0, 1) >>> linked_list.insert_at_nth(2, 4) >>> linked_list.insert_at_nth(2, 3) >>> str(linked_list) '1->2->3->4' >>> linked_list.insert_at_nth(5, 5) Traceback (most recent call last): .... IndexError: list index out of range """ if not 0 <= index <= len(self): raise IndexError("list index out of range") new_node = Node(data) if self.head is None: self.head = self.tail = new_node elif index == 0: self.head.previous = new_node new_node.next = self.head self.head = new_node elif index == len(self): self.tail.next = new_node new_node.previous = self.tail self.tail = new_node else: temp = self.head for i in range(0, index): temp = temp.next temp.previous.next = new_node new_node.previous = temp.previous new_node.next = temp temp.previous = new_node def delete_head(self): return self.delete_at_nth(0) def delete_tail(self): return self.delete_at_nth(len(self) - 1) def delete_at_nth(self, index: int): """ >>> linked_list = DoublyLinkedList() >>> linked_list.delete_at_nth(0) Traceback (most recent call last): .... IndexError: list index out of range >>> for i in range(0, 5): ... linked_list.insert_at_nth(i, i + 1) >>> linked_list.delete_at_nth(0) == 1 True >>> linked_list.delete_at_nth(3) == 5 True >>> linked_list.delete_at_nth(1) == 3 True >>> str(linked_list) '2->4' >>> linked_list.delete_at_nth(2) Traceback (most recent call last): .... IndexError: list index out of range """ if not 0 <= index <= len(self) - 1: raise IndexError("list index out of range") delete_node = self.head # default first node if len(self) == 1: self.head = self.tail = None elif index == 0: self.head = self.head.next self.head.previous = None elif index == len(self) - 1: delete_node = self.tail self.tail = self.tail.previous self.tail.next = None else: temp = self.head for i in range(0, index): temp = temp.next delete_node = temp temp.next.previous = temp.previous temp.previous.next = temp.next return delete_node.data def delete(self, data) -> str: current = self.head while current.data != data: # Find the position to delete if current.next: current = current.next else: # We have reached the end an no value matches return "No data matching given value" if current == self.head: self.delete_head() elif current == self.tail: self.delete_tail() else: # Before: 1 <--> 2(current) <--> 3 current.previous.next = current.next # 1 --> 3 current.next.previous = current.previous # 1 <--> 3 return data def is_empty(self): """ >>> linked_list = DoublyLinkedList() >>> linked_list.is_empty() True >>> linked_list.insert_at_tail(1) >>> linked_list.is_empty() False """ return len(self) == 0 def test_doubly_linked_list() -> None: """ >>> test_doubly_linked_list() """ linked_list = DoublyLinkedList() assert linked_list.is_empty() is True assert str(linked_list) == "" try: linked_list.delete_head() assert False # This should not happen. except IndexError: assert True # This should happen. try: linked_list.delete_tail() assert False # This should not happen. except IndexError: assert True # This should happen. for i in range(10): assert len(linked_list) == i linked_list.insert_at_nth(i, i + 1) assert str(linked_list) == "->".join(str(i) for i in range(1, 11)) linked_list.insert_at_head(0) linked_list.insert_at_tail(11) assert str(linked_list) == "->".join(str(i) for i in range(0, 12)) assert linked_list.delete_head() == 0 assert linked_list.delete_at_nth(9) == 10 assert linked_list.delete_tail() == 11 assert len(linked_list) == 9 assert str(linked_list) == "->".join(str(i) for i in range(1, 10)) if __name__ == "__main__": from doctest import testmod testmod()
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Problem 16: https://projecteuler.net/problem=16 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? """ def solution(power: int = 1000) -> int: """Returns the sum of the digits of the number 2^power. >>> solution(1000) 1366 >>> solution(50) 76 >>> solution(20) 31 >>> solution(15) 26 """ n = 2 ** power r = 0 while n: r, n = r + n % 10, n // 10 return r if __name__ == "__main__": print(solution(int(str(input()).strip())))
""" Problem 16: https://projecteuler.net/problem=16 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? """ def solution(power: int = 1000) -> int: """Returns the sum of the digits of the number 2^power. >>> solution(1000) 1366 >>> solution(50) 76 >>> solution(20) 31 >>> solution(15) 26 """ n = 2 ** power r = 0 while n: r, n = r + n % 10, n // 10 return r if __name__ == "__main__": print(solution(int(str(input()).strip())))
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Project Euler Problem 8: https://projecteuler.net/problem=8 Largest product in a series The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749 30358907296290491560440772390713810515859307960866 70172427121883998797908792274921901699720888093776 65727333001053367881220235421809751254540594752243 52584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482 83972241375657056057490261407972968652414535100474 82166370484403199890008895243450658541227588666881 16427171479924442928230863465674813919123162824586 17866458359124566529476545682848912883142607690042 24219022671055626321111109370544217506941658960408 07198403850962455444362981230987879927244284909188 84580156166097919133875499200524063689912560717606 05886116467109405077541002256983155200055935729725 71636269561882670428252483600823257530420752963450 Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product? """ from functools import reduce N = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950445244523161731856403098711121722383113" "62229893423380308135336276614282806444486645238749" "30358907296290491560440772390713810515859307960866" "70172427121883998797908792274921901699720888093776" "65727333001053367881220235421809751254540594752243" "52584907711670556013604839586446706324415722155397" "53697817977846174064955149290862569321978468622482" "83972241375657056057490261407972968652414535100474" "82166370484403199890008895243450658541227588666881" "16427171479924442928230863465674813919123162824586" "17866458359124566529476545682848912883142607690042" "24219022671055626321111109370544217506941658960408" "07198403850962455444362981230987879927244284909188" "84580156166097919133875499200524063689912560717606" "05886116467109405077541002256983155200055935729725" "71636269561882670428252483600823257530420752963450" ) def solution(n: str = N) -> int: """ Find the thirteen adjacent digits in the 1000-digit number n that have the greatest product and returns it. >>> solution("13978431290823798458352374") 609638400 >>> solution("13978431295823798458352374") 2612736000 >>> solution("1397843129582379841238352374") 209018880 """ return max( [ reduce(lambda x, y: int(x) * int(y), n[i : i + 13]) for i in range(len(n) - 12) ] ) if __name__ == "__main__": print(f"{solution() = }")
""" Project Euler Problem 8: https://projecteuler.net/problem=8 Largest product in a series The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749 30358907296290491560440772390713810515859307960866 70172427121883998797908792274921901699720888093776 65727333001053367881220235421809751254540594752243 52584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482 83972241375657056057490261407972968652414535100474 82166370484403199890008895243450658541227588666881 16427171479924442928230863465674813919123162824586 17866458359124566529476545682848912883142607690042 24219022671055626321111109370544217506941658960408 07198403850962455444362981230987879927244284909188 84580156166097919133875499200524063689912560717606 05886116467109405077541002256983155200055935729725 71636269561882670428252483600823257530420752963450 Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product? """ from functools import reduce N = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950445244523161731856403098711121722383113" "62229893423380308135336276614282806444486645238749" "30358907296290491560440772390713810515859307960866" "70172427121883998797908792274921901699720888093776" "65727333001053367881220235421809751254540594752243" "52584907711670556013604839586446706324415722155397" "53697817977846174064955149290862569321978468622482" "83972241375657056057490261407972968652414535100474" "82166370484403199890008895243450658541227588666881" "16427171479924442928230863465674813919123162824586" "17866458359124566529476545682848912883142607690042" "24219022671055626321111109370544217506941658960408" "07198403850962455444362981230987879927244284909188" "84580156166097919133875499200524063689912560717606" "05886116467109405077541002256983155200055935729725" "71636269561882670428252483600823257530420752963450" ) def solution(n: str = N) -> int: """ Find the thirteen adjacent digits in the 1000-digit number n that have the greatest product and returns it. >>> solution("13978431290823798458352374") 609638400 >>> solution("13978431295823798458352374") 2612736000 >>> solution("1397843129582379841238352374") 209018880 """ return max( [ reduce(lambda x, y: int(x) * int(y), n[i : i + 13]) for i in range(len(n) - 12) ] ) if __name__ == "__main__": print(f"{solution() = }")
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
from typing import Optional class Node: """ A Node has data variable and pointers to Nodes to its left and right. """ def __init__(self, data: int) -> None: self.data = data self.left: Optional[Node] = None self.right: Optional[Node] = None def display(tree: Optional[Node]) -> None: # In Order traversal of the tree """ >>> root = Node(1) >>> root.left = Node(0) >>> root.right = Node(2) >>> display(root) 0 1 2 >>> display(root.right) 2 """ if tree: display(tree.left) print(tree.data) display(tree.right) def depth_of_tree(tree: Optional[Node]) -> int: """ Recursive function that returns the depth of a binary tree. >>> root = Node(0) >>> depth_of_tree(root) 1 >>> root.left = Node(0) >>> depth_of_tree(root) 2 >>> root.right = Node(0) >>> depth_of_tree(root) 2 >>> root.left.right = Node(0) >>> depth_of_tree(root) 3 >>> depth_of_tree(root.left) 2 """ return 1 + max(depth_of_tree(tree.left), depth_of_tree(tree.right)) if tree else 0 def is_full_binary_tree(tree: Node) -> bool: """ Returns True if this is a full binary tree >>> root = Node(0) >>> is_full_binary_tree(root) True >>> root.left = Node(0) >>> is_full_binary_tree(root) False >>> root.right = Node(0) >>> is_full_binary_tree(root) True >>> root.left.left = Node(0) >>> is_full_binary_tree(root) False >>> root.right.right = Node(0) >>> is_full_binary_tree(root) False """ if not tree: return True if tree.left and tree.right: return is_full_binary_tree(tree.left) and is_full_binary_tree(tree.right) else: return not tree.left and not tree.right def main() -> None: # Main function for testing. tree = Node(1) tree.left = Node(2) tree.right = Node(3) tree.left.left = Node(4) tree.left.right = Node(5) tree.left.right.left = Node(6) tree.right.left = Node(7) tree.right.left.left = Node(8) tree.right.left.left.right = Node(9) print(is_full_binary_tree(tree)) print(depth_of_tree(tree)) print("Tree is: ") display(tree) if __name__ == "__main__": main()
from typing import Optional class Node: """ A Node has data variable and pointers to Nodes to its left and right. """ def __init__(self, data: int) -> None: self.data = data self.left: Optional[Node] = None self.right: Optional[Node] = None def display(tree: Optional[Node]) -> None: # In Order traversal of the tree """ >>> root = Node(1) >>> root.left = Node(0) >>> root.right = Node(2) >>> display(root) 0 1 2 >>> display(root.right) 2 """ if tree: display(tree.left) print(tree.data) display(tree.right) def depth_of_tree(tree: Optional[Node]) -> int: """ Recursive function that returns the depth of a binary tree. >>> root = Node(0) >>> depth_of_tree(root) 1 >>> root.left = Node(0) >>> depth_of_tree(root) 2 >>> root.right = Node(0) >>> depth_of_tree(root) 2 >>> root.left.right = Node(0) >>> depth_of_tree(root) 3 >>> depth_of_tree(root.left) 2 """ return 1 + max(depth_of_tree(tree.left), depth_of_tree(tree.right)) if tree else 0 def is_full_binary_tree(tree: Node) -> bool: """ Returns True if this is a full binary tree >>> root = Node(0) >>> is_full_binary_tree(root) True >>> root.left = Node(0) >>> is_full_binary_tree(root) False >>> root.right = Node(0) >>> is_full_binary_tree(root) True >>> root.left.left = Node(0) >>> is_full_binary_tree(root) False >>> root.right.right = Node(0) >>> is_full_binary_tree(root) False """ if not tree: return True if tree.left and tree.right: return is_full_binary_tree(tree.left) and is_full_binary_tree(tree.right) else: return not tree.left and not tree.right def main() -> None: # Main function for testing. tree = Node(1) tree.left = Node(2) tree.right = Node(3) tree.left.left = Node(4) tree.left.right = Node(5) tree.left.right.left = Node(6) tree.right.left = Node(7) tree.right.left.left = Node(8) tree.right.left.left.right = Node(9) print(is_full_binary_tree(tree)) print(depth_of_tree(tree)) print("Tree is: ") display(tree) if __name__ == "__main__": main()
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. Note that only the integer weights 0-1 knapsack problem is solvable using dynamic programming. """ def MF_knapsack(i, wt, val, j): """ This code involves the concept of memory functions. Here we solve the subproblems which are needed unlike the below example F is a 2D array with -1s filled up """ global F # a global dp table for knapsack if F[i][j] < 0: if j < wt[i - 1]: val = MF_knapsack(i - 1, wt, val, j) else: val = max( MF_knapsack(i - 1, wt, val, j), MF_knapsack(i - 1, wt, val, j - wt[i - 1]) + val[i - 1], ) F[i][j] = val return F[i][j] def knapsack(W, wt, val, n): dp = [[0 for i in range(W + 1)] for j in range(n + 1)] for i in range(1, n + 1): for w in range(1, W + 1): if wt[i - 1] <= w: dp[i][w] = max(val[i - 1] + dp[i - 1][w - wt[i - 1]], dp[i - 1][w]) else: dp[i][w] = dp[i - 1][w] return dp[n][W], dp def knapsack_with_example_solution(W: int, wt: list, val: list): """ Solves the integer weights knapsack problem returns one of the several possible optimal subsets. Parameters --------- W: int, the total maximum weight for the given knapsack problem. wt: list, the vector of weights for all items where wt[i] is the weight of the i-th item. val: list, the vector of values for all items where val[i] is the value of the i-th item Returns ------- optimal_val: float, the optimal value for the given knapsack problem example_optional_set: set, the indices of one of the optimal subsets which gave rise to the optimal value. Examples ------- >>> knapsack_with_example_solution(10, [1, 3, 5, 2], [10, 20, 100, 22]) (142, {2, 3, 4}) >>> knapsack_with_example_solution(6, [4, 3, 2, 3], [3, 2, 4, 4]) (8, {3, 4}) >>> knapsack_with_example_solution(6, [4, 3, 2, 3], [3, 2, 4]) Traceback (most recent call last): ... ValueError: The number of weights must be the same as the number of values. But got 4 weights and 3 values """ if not (isinstance(wt, (list, tuple)) and isinstance(val, (list, tuple))): raise ValueError( "Both the weights and values vectors must be either lists or tuples" ) num_items = len(wt) if num_items != len(val): raise ValueError( "The number of weights must be the " "same as the number of values.\nBut " f"got {num_items} weights and {len(val)} values" ) for i in range(num_items): if not isinstance(wt[i], int): raise TypeError( "All weights must be integers but " f"got weight of type {type(wt[i])} at index {i}" ) optimal_val, dp_table = knapsack(W, wt, val, num_items) example_optional_set = set() _construct_solution(dp_table, wt, num_items, W, example_optional_set) return optimal_val, example_optional_set def _construct_solution(dp: list, wt: list, i: int, j: int, optimal_set: set): """ Recursively reconstructs one of the optimal subsets given a filled DP table and the vector of weights Parameters --------- dp: list of list, the table of a solved integer weight dynamic programming problem wt: list or tuple, the vector of weights of the items i: int, the index of the item under consideration j: int, the current possible maximum weight optimal_set: set, the optimal subset so far. This gets modified by the function. Returns ------- None """ # for the current item i at a maximum weight j to be part of an optimal subset, # the optimal value at (i, j) must be greater than the optimal value at (i-1, j). # where i - 1 means considering only the previous items at the given maximum weight if i > 0 and j > 0: if dp[i - 1][j] == dp[i][j]: _construct_solution(dp, wt, i - 1, j, optimal_set) else: optimal_set.add(i) _construct_solution(dp, wt, i - 1, j - wt[i - 1], optimal_set) if __name__ == "__main__": """ Adding test case for knapsack """ val = [3, 2, 4, 4] wt = [4, 3, 2, 3] n = 4 w = 6 F = [[0] * (w + 1)] + [[0] + [-1 for i in range(w + 1)] for j in range(n + 1)] optimal_solution, _ = knapsack(w, wt, val, n) print(optimal_solution) print(MF_knapsack(n, wt, val, w)) # switched the n and w # testing the dynamic programming problem with example # the optimal subset for the above example are items 3 and 4 optimal_solution, optimal_subset = knapsack_with_example_solution(w, wt, val) assert optimal_solution == 8 assert optimal_subset == {3, 4} print("optimal_value = ", optimal_solution) print("An optimal subset corresponding to the optimal value", optimal_subset)
""" Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. Note that only the integer weights 0-1 knapsack problem is solvable using dynamic programming. """ def MF_knapsack(i, wt, val, j): """ This code involves the concept of memory functions. Here we solve the subproblems which are needed unlike the below example F is a 2D array with -1s filled up """ global F # a global dp table for knapsack if F[i][j] < 0: if j < wt[i - 1]: val = MF_knapsack(i - 1, wt, val, j) else: val = max( MF_knapsack(i - 1, wt, val, j), MF_knapsack(i - 1, wt, val, j - wt[i - 1]) + val[i - 1], ) F[i][j] = val return F[i][j] def knapsack(W, wt, val, n): dp = [[0 for i in range(W + 1)] for j in range(n + 1)] for i in range(1, n + 1): for w in range(1, W + 1): if wt[i - 1] <= w: dp[i][w] = max(val[i - 1] + dp[i - 1][w - wt[i - 1]], dp[i - 1][w]) else: dp[i][w] = dp[i - 1][w] return dp[n][W], dp def knapsack_with_example_solution(W: int, wt: list, val: list): """ Solves the integer weights knapsack problem returns one of the several possible optimal subsets. Parameters --------- W: int, the total maximum weight for the given knapsack problem. wt: list, the vector of weights for all items where wt[i] is the weight of the i-th item. val: list, the vector of values for all items where val[i] is the value of the i-th item Returns ------- optimal_val: float, the optimal value for the given knapsack problem example_optional_set: set, the indices of one of the optimal subsets which gave rise to the optimal value. Examples ------- >>> knapsack_with_example_solution(10, [1, 3, 5, 2], [10, 20, 100, 22]) (142, {2, 3, 4}) >>> knapsack_with_example_solution(6, [4, 3, 2, 3], [3, 2, 4, 4]) (8, {3, 4}) >>> knapsack_with_example_solution(6, [4, 3, 2, 3], [3, 2, 4]) Traceback (most recent call last): ... ValueError: The number of weights must be the same as the number of values. But got 4 weights and 3 values """ if not (isinstance(wt, (list, tuple)) and isinstance(val, (list, tuple))): raise ValueError( "Both the weights and values vectors must be either lists or tuples" ) num_items = len(wt) if num_items != len(val): raise ValueError( "The number of weights must be the " "same as the number of values.\nBut " f"got {num_items} weights and {len(val)} values" ) for i in range(num_items): if not isinstance(wt[i], int): raise TypeError( "All weights must be integers but " f"got weight of type {type(wt[i])} at index {i}" ) optimal_val, dp_table = knapsack(W, wt, val, num_items) example_optional_set = set() _construct_solution(dp_table, wt, num_items, W, example_optional_set) return optimal_val, example_optional_set def _construct_solution(dp: list, wt: list, i: int, j: int, optimal_set: set): """ Recursively reconstructs one of the optimal subsets given a filled DP table and the vector of weights Parameters --------- dp: list of list, the table of a solved integer weight dynamic programming problem wt: list or tuple, the vector of weights of the items i: int, the index of the item under consideration j: int, the current possible maximum weight optimal_set: set, the optimal subset so far. This gets modified by the function. Returns ------- None """ # for the current item i at a maximum weight j to be part of an optimal subset, # the optimal value at (i, j) must be greater than the optimal value at (i-1, j). # where i - 1 means considering only the previous items at the given maximum weight if i > 0 and j > 0: if dp[i - 1][j] == dp[i][j]: _construct_solution(dp, wt, i - 1, j, optimal_set) else: optimal_set.add(i) _construct_solution(dp, wt, i - 1, j - wt[i - 1], optimal_set) if __name__ == "__main__": """ Adding test case for knapsack """ val = [3, 2, 4, 4] wt = [4, 3, 2, 3] n = 4 w = 6 F = [[0] * (w + 1)] + [[0] + [-1 for i in range(w + 1)] for j in range(n + 1)] optimal_solution, _ = knapsack(w, wt, val, n) print(optimal_solution) print(MF_knapsack(n, wt, val, w)) # switched the n and w # testing the dynamic programming problem with example # the optimal subset for the above example are items 3 and 4 optimal_solution, optimal_subset = knapsack_with_example_solution(w, wt, val) assert optimal_solution == 8 assert optimal_subset == {3, 4} print("optimal_value = ", optimal_solution) print("An optimal subset corresponding to the optimal value", optimal_subset)
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" This is a pure Python implementation of the merge-insertion sort algorithm Source: https://en.wikipedia.org/wiki/Graham_scan For doctests run following command: python3 -m doctest -v graham_scan.py """ from __future__ import annotations from collections import deque from enum import Enum from math import atan2, degrees from sys import maxsize def graham_scan(points: list[list[int, int]]) -> list[list[int, int]]: """Pure implementation of graham scan algorithm in Python :param points: The unique points on coordinates. :return: The points on convex hell. Examples: >>> graham_scan([(9, 6), (3, 1), (0, 0), (5, 5), (5, 2), (7, 0), (3, 3), (1, 4)]) [(0, 0), (7, 0), (9, 6), (5, 5), (1, 4)] >>> graham_scan([(0, 0), (1, 0), (1, 1), (0, 1)]) [(0, 0), (1, 0), (1, 1), (0, 1)] >>> graham_scan([(0, 0), (1, 1), (2, 2), (3, 3), (-1, 2)]) [(0, 0), (1, 1), (2, 2), (3, 3), (-1, 2)] >>> graham_scan([(-100, 20), (99, 3), (1, 10000001), (5133186, -25), (-66, -4)]) [(5133186, -25), (1, 10000001), (-100, 20), (-66, -4)] """ if len(points) <= 2: # There is no convex hull raise ValueError("graham_scan: argument must contain more than 3 points.") if len(points) == 3: return points # find the lowest and the most left point minidx = 0 miny, minx = maxsize, maxsize for i, point in enumerate(points): x = point[0] y = point[1] if y < miny: miny = y minx = x minidx = i if y == miny: if x < minx: minx = x minidx = i # remove the lowest and the most left point from points for preparing for sort points.pop(minidx) def angle_comparer(point: list[int, int], minx: int, miny: int) -> float: """Return the angle toward to point from (minx, miny) :param point: The target point minx: The starting point's x miny: The starting point's y :return: the angle Examples: >>> angle_comparer([1,1], 0, 0) 45.0 >>> angle_comparer([100,1], 10, 10) -5.710593137499642 >>> angle_comparer([5,5], 2, 3) 33.690067525979785 """ # sort the points accorgind to the angle from the lowest and the most left point x = point[0] y = point[1] angle = degrees(atan2(y - miny, x - minx)) return angle sorted_points = sorted(points, key=lambda point: angle_comparer(point, minx, miny)) # This insert actually costs complexity, # and you should insteadly add (minx, miny) into stack later. # I'm using insert just for easy understanding. sorted_points.insert(0, (minx, miny)) # traversal from the lowest and the most left point in anti-clockwise direction # if direction gets right, the previous point is not the convex hull. class Direction(Enum): left = 1 straight = 2 right = 3 def check_direction( starting: list[int, int], via: list[int, int], target: list[int, int] ) -> Direction: """Return the direction toward to the line from via to target from starting :param starting: The starting point via: The via point target: The target point :return: the Direction Examples: >>> check_direction([1,1], [2,2], [3,3]) Direction.straight >>> check_direction([60,1], [-50,199], [30,2]) Direction.left >>> check_direction([0,0], [5,5], [10,0]) Direction.right """ x0, y0 = starting x1, y1 = via x2, y2 = target via_angle = degrees(atan2(y1 - y0, x1 - x0)) if via_angle < 0: via_angle += 360 target_angle = degrees(atan2(y2 - y0, x2 - x0)) if target_angle < 0: target_angle += 360 # t- # \ \ # \ v # \| # s # via_angle is always lower than target_angle, if direction is left. # If they are same, it means they are on a same line of convex hull. if target_angle > via_angle: return Direction.left if target_angle == via_angle: return Direction.straight if target_angle < via_angle: return Direction.right stack = deque() stack.append(sorted_points[0]) stack.append(sorted_points[1]) stack.append(sorted_points[2]) # In any ways, the first 3 points line are towards left. # Because we sort them the angle from minx, miny. current_direction = Direction.left for i in range(3, len(sorted_points)): while True: starting = stack[-2] via = stack[-1] target = sorted_points[i] next_direction = check_direction(starting, via, target) if next_direction == Direction.left: current_direction = Direction.left break if next_direction == Direction.straight: if current_direction == Direction.left: # We keep current_direction as left. # Because if the straight line keeps as straight, # we want to know if this straight line is towards left. break elif current_direction == Direction.right: # If the straight line is towards right, # every previous points on those straigh line is not convex hull. stack.pop() if next_direction == Direction.right: stack.pop() stack.append(sorted_points[i]) return list(stack)
""" This is a pure Python implementation of the merge-insertion sort algorithm Source: https://en.wikipedia.org/wiki/Graham_scan For doctests run following command: python3 -m doctest -v graham_scan.py """ from __future__ import annotations from collections import deque from enum import Enum from math import atan2, degrees from sys import maxsize def graham_scan(points: list[list[int, int]]) -> list[list[int, int]]: """Pure implementation of graham scan algorithm in Python :param points: The unique points on coordinates. :return: The points on convex hell. Examples: >>> graham_scan([(9, 6), (3, 1), (0, 0), (5, 5), (5, 2), (7, 0), (3, 3), (1, 4)]) [(0, 0), (7, 0), (9, 6), (5, 5), (1, 4)] >>> graham_scan([(0, 0), (1, 0), (1, 1), (0, 1)]) [(0, 0), (1, 0), (1, 1), (0, 1)] >>> graham_scan([(0, 0), (1, 1), (2, 2), (3, 3), (-1, 2)]) [(0, 0), (1, 1), (2, 2), (3, 3), (-1, 2)] >>> graham_scan([(-100, 20), (99, 3), (1, 10000001), (5133186, -25), (-66, -4)]) [(5133186, -25), (1, 10000001), (-100, 20), (-66, -4)] """ if len(points) <= 2: # There is no convex hull raise ValueError("graham_scan: argument must contain more than 3 points.") if len(points) == 3: return points # find the lowest and the most left point minidx = 0 miny, minx = maxsize, maxsize for i, point in enumerate(points): x = point[0] y = point[1] if y < miny: miny = y minx = x minidx = i if y == miny: if x < minx: minx = x minidx = i # remove the lowest and the most left point from points for preparing for sort points.pop(minidx) def angle_comparer(point: list[int, int], minx: int, miny: int) -> float: """Return the angle toward to point from (minx, miny) :param point: The target point minx: The starting point's x miny: The starting point's y :return: the angle Examples: >>> angle_comparer([1,1], 0, 0) 45.0 >>> angle_comparer([100,1], 10, 10) -5.710593137499642 >>> angle_comparer([5,5], 2, 3) 33.690067525979785 """ # sort the points accorgind to the angle from the lowest and the most left point x = point[0] y = point[1] angle = degrees(atan2(y - miny, x - minx)) return angle sorted_points = sorted(points, key=lambda point: angle_comparer(point, minx, miny)) # This insert actually costs complexity, # and you should insteadly add (minx, miny) into stack later. # I'm using insert just for easy understanding. sorted_points.insert(0, (minx, miny)) # traversal from the lowest and the most left point in anti-clockwise direction # if direction gets right, the previous point is not the convex hull. class Direction(Enum): left = 1 straight = 2 right = 3 def check_direction( starting: list[int, int], via: list[int, int], target: list[int, int] ) -> Direction: """Return the direction toward to the line from via to target from starting :param starting: The starting point via: The via point target: The target point :return: the Direction Examples: >>> check_direction([1,1], [2,2], [3,3]) Direction.straight >>> check_direction([60,1], [-50,199], [30,2]) Direction.left >>> check_direction([0,0], [5,5], [10,0]) Direction.right """ x0, y0 = starting x1, y1 = via x2, y2 = target via_angle = degrees(atan2(y1 - y0, x1 - x0)) if via_angle < 0: via_angle += 360 target_angle = degrees(atan2(y2 - y0, x2 - x0)) if target_angle < 0: target_angle += 360 # t- # \ \ # \ v # \| # s # via_angle is always lower than target_angle, if direction is left. # If they are same, it means they are on a same line of convex hull. if target_angle > via_angle: return Direction.left if target_angle == via_angle: return Direction.straight if target_angle < via_angle: return Direction.right stack = deque() stack.append(sorted_points[0]) stack.append(sorted_points[1]) stack.append(sorted_points[2]) # In any ways, the first 3 points line are towards left. # Because we sort them the angle from minx, miny. current_direction = Direction.left for i in range(3, len(sorted_points)): while True: starting = stack[-2] via = stack[-1] target = sorted_points[i] next_direction = check_direction(starting, via, target) if next_direction == Direction.left: current_direction = Direction.left break if next_direction == Direction.straight: if current_direction == Direction.left: # We keep current_direction as left. # Because if the straight line keeps as straight, # we want to know if this straight line is towards left. break elif current_direction == Direction.right: # If the straight line is towards right, # every previous points on those straigh line is not convex hull. stack.pop() if next_direction == Direction.right: stack.pop() stack.append(sorted_points[i]) return list(stack)
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
"""Implementation of GradientBoostingRegressor in sklearn using the boston dataset which is very popular for regression problem to predict house price. """ import matplotlib.pyplot as plt import pandas as pd from sklearn.datasets import load_boston from sklearn.ensemble import GradientBoostingRegressor from sklearn.metrics import mean_squared_error, r2_score from sklearn.model_selection import train_test_split def main(): # loading the dataset from the sklearn df = load_boston() print(df.keys()) # now let construct a data frame df_boston = pd.DataFrame(df.data, columns=df.feature_names) # let add the target to the dataframe df_boston["Price"] = df.target # print the first five rows using the head function print(df_boston.head()) # Summary statistics print(df_boston.describe().T) # Feature selection X = df_boston.iloc[:, :-1] y = df_boston.iloc[:, -1] # target variable # split the data with 75% train and 25% test sets. X_train, X_test, y_train, y_test = train_test_split( X, y, random_state=0, test_size=0.25 ) model = GradientBoostingRegressor( n_estimators=500, max_depth=5, min_samples_split=4, learning_rate=0.01 ) # training the model model.fit(X_train, y_train) # to see how good the model fit the data training_score = model.score(X_train, y_train).round(3) test_score = model.score(X_test, y_test).round(3) print("Training score of GradientBoosting is :", training_score) print("The test score of GradientBoosting is :", test_score) # Let us evaluation the model by finding the errors y_pred = model.predict(X_test) # The mean squared error print("Mean squared error: %.2f" % mean_squared_error(y_test, y_pred)) # Explained variance score: 1 is perfect prediction print("Test Variance score: %.2f" % r2_score(y_test, y_pred)) # So let's run the model against the test data fig, ax = plt.subplots() ax.scatter(y_test, y_pred, edgecolors=(0, 0, 0)) ax.plot([y_test.min(), y_test.max()], [y_test.min(), y_test.max()], "k--", lw=4) ax.set_xlabel("Actual") ax.set_ylabel("Predicted") ax.set_title("Truth vs Predicted") # this show function will display the plotting plt.show() if __name__ == "__main__": main()
"""Implementation of GradientBoostingRegressor in sklearn using the boston dataset which is very popular for regression problem to predict house price. """ import matplotlib.pyplot as plt import pandas as pd from sklearn.datasets import load_boston from sklearn.ensemble import GradientBoostingRegressor from sklearn.metrics import mean_squared_error, r2_score from sklearn.model_selection import train_test_split def main(): # loading the dataset from the sklearn df = load_boston() print(df.keys()) # now let construct a data frame df_boston = pd.DataFrame(df.data, columns=df.feature_names) # let add the target to the dataframe df_boston["Price"] = df.target # print the first five rows using the head function print(df_boston.head()) # Summary statistics print(df_boston.describe().T) # Feature selection X = df_boston.iloc[:, :-1] y = df_boston.iloc[:, -1] # target variable # split the data with 75% train and 25% test sets. X_train, X_test, y_train, y_test = train_test_split( X, y, random_state=0, test_size=0.25 ) model = GradientBoostingRegressor( n_estimators=500, max_depth=5, min_samples_split=4, learning_rate=0.01 ) # training the model model.fit(X_train, y_train) # to see how good the model fit the data training_score = model.score(X_train, y_train).round(3) test_score = model.score(X_test, y_test).round(3) print("Training score of GradientBoosting is :", training_score) print("The test score of GradientBoosting is :", test_score) # Let us evaluation the model by finding the errors y_pred = model.predict(X_test) # The mean squared error print("Mean squared error: %.2f" % mean_squared_error(y_test, y_pred)) # Explained variance score: 1 is perfect prediction print("Test Variance score: %.2f" % r2_score(y_test, y_pred)) # So let's run the model against the test data fig, ax = plt.subplots() ax.scatter(y_test, y_pred, edgecolors=(0, 0, 0)) ax.plot([y_test.min(), y_test.max()], [y_test.min(), y_test.max()], "k--", lw=4) ax.set_xlabel("Actual") ax.set_ylabel("Predicted") ax.set_title("Truth vs Predicted") # this show function will display the plotting plt.show() if __name__ == "__main__": main()
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" https://en.wikipedia.org/wiki/Atbash """ import string def atbash_slow(sequence: str) -> str: """ >>> atbash_slow("ABCDEFG") 'ZYXWVUT' >>> atbash_slow("aW;;123BX") 'zD;;123YC' """ output = "" for i in sequence: extract = ord(i) if 65 <= extract <= 90: output += chr(155 - extract) elif 97 <= extract <= 122: output += chr(219 - extract) else: output += i return output def atbash(sequence: str) -> str: """ >>> atbash("ABCDEFG") 'ZYXWVUT' >>> atbash("aW;;123BX") 'zD;;123YC' """ letters = string.ascii_letters letters_reversed = string.ascii_lowercase[::-1] + string.ascii_uppercase[::-1] return "".join( letters_reversed[letters.index(c)] if c in letters else c for c in sequence ) def benchmark() -> None: """Let's benchmark them side-by-side...""" from timeit import timeit print("Running performance benchmarks...") print( "> atbash_slow()", timeit( "atbash_slow(printable)", setup="from string import printable ; from __main__ import atbash_slow", ), "seconds", ) print( "> atbash()", timeit( "atbash(printable)", setup="from string import printable ; from __main__ import atbash", ), "seconds", ) if __name__ == "__main__": for sequence in ("ABCDEFGH", "123GGjj", "testStringtest", "with space"): print(f"{sequence} encrypted in atbash: {atbash(sequence)}") benchmark()
""" https://en.wikipedia.org/wiki/Atbash """ import string def atbash_slow(sequence: str) -> str: """ >>> atbash_slow("ABCDEFG") 'ZYXWVUT' >>> atbash_slow("aW;;123BX") 'zD;;123YC' """ output = "" for i in sequence: extract = ord(i) if 65 <= extract <= 90: output += chr(155 - extract) elif 97 <= extract <= 122: output += chr(219 - extract) else: output += i return output def atbash(sequence: str) -> str: """ >>> atbash("ABCDEFG") 'ZYXWVUT' >>> atbash("aW;;123BX") 'zD;;123YC' """ letters = string.ascii_letters letters_reversed = string.ascii_lowercase[::-1] + string.ascii_uppercase[::-1] return "".join( letters_reversed[letters.index(c)] if c in letters else c for c in sequence ) def benchmark() -> None: """Let's benchmark them side-by-side...""" from timeit import timeit print("Running performance benchmarks...") print( "> atbash_slow()", timeit( "atbash_slow(printable)", setup="from string import printable ; from __main__ import atbash_slow", ), "seconds", ) print( "> atbash()", timeit( "atbash(printable)", setup="from string import printable ; from __main__ import atbash", ), "seconds", ) if __name__ == "__main__": for sequence in ("ABCDEFGH", "123GGjj", "testStringtest", "with space"): print(f"{sequence} encrypted in atbash: {atbash(sequence)}") benchmark()
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum exceeds n. As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of two abundant numbers is 24. By mathematical analysis, it can be shown that all integers greater than 28123 can be written as the sum of two abundant numbers. However, this upper limit cannot be reduced any further by analysis even though it is known that the greatest number that cannot be expressed as the sum of two abundant numbers is less than this limit. Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers. """ def solution(limit=28123): """ Finds the sum of all the positive integers which cannot be written as the sum of two abundant numbers as described by the statement above. >>> solution() 4179871 """ sumDivs = [1] * (limit + 1) for i in range(2, int(limit ** 0.5) + 1): sumDivs[i * i] += i for k in range(i + 1, limit // i + 1): sumDivs[k * i] += k + i abundants = set() res = 0 for n in range(1, limit + 1): if sumDivs[n] > n: abundants.add(n) if not any((n - a in abundants) for a in abundants): res += n return res if __name__ == "__main__": print(solution())
""" A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum exceeds n. As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of two abundant numbers is 24. By mathematical analysis, it can be shown that all integers greater than 28123 can be written as the sum of two abundant numbers. However, this upper limit cannot be reduced any further by analysis even though it is known that the greatest number that cannot be expressed as the sum of two abundant numbers is less than this limit. Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers. """ def solution(limit=28123): """ Finds the sum of all the positive integers which cannot be written as the sum of two abundant numbers as described by the statement above. >>> solution() 4179871 """ sumDivs = [1] * (limit + 1) for i in range(2, int(limit ** 0.5) + 1): sumDivs[i * i] += i for k in range(i + 1, limit // i + 1): sumDivs[k * i] += k + i abundants = set() res = 0 for n in range(1, limit + 1): if sumDivs[n] > n: abundants.add(n) if not any((n - a in abundants) for a in abundants): res += n return res if __name__ == "__main__": print(solution())
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
from collections import deque def tarjan(g): """ Tarjan's algo for finding strongly connected components in a directed graph Uses two main attributes of each node to track reachability, the index of that node within a component(index), and the lowest index reachable from that node(lowlink). We then perform a dfs of the each component making sure to update these parameters for each node and saving the nodes we visit on the way. If ever we find that the lowest reachable node from a current node is equal to the index of the current node then it must be the root of a strongly connected component and so we save it and it's equireachable vertices as a strongly connected component. Complexity: strong_connect() is called at most once for each node and has a complexity of O(|E|) as it is DFS. Therefore this has complexity O(|V| + |E|) for a graph G = (V, E) """ n = len(g) stack = deque() on_stack = [False for _ in range(n)] index_of = [-1 for _ in range(n)] lowlink_of = index_of[:] def strong_connect(v, index, components): index_of[v] = index # the number when this node is seen lowlink_of[v] = index # lowest rank node reachable from here index += 1 stack.append(v) on_stack[v] = True for w in g[v]: if index_of[w] == -1: index = strong_connect(w, index, components) lowlink_of[v] = ( lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v] ) elif on_stack[w]: lowlink_of[v] = ( lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v] ) if lowlink_of[v] == index_of[v]: component = [] w = stack.pop() on_stack[w] = False component.append(w) while w != v: w = stack.pop() on_stack[w] = False component.append(w) components.append(component) return index components = [] for v in range(n): if index_of[v] == -1: strong_connect(v, 0, components) return components def create_graph(n, edges): g = [[] for _ in range(n)] for u, v in edges: g[u].append(v) return g if __name__ == "__main__": # Test n_vertices = 7 source = [0, 0, 1, 2, 3, 3, 4, 4, 6] target = [1, 3, 2, 0, 1, 4, 5, 6, 5] edges = [(u, v) for u, v in zip(source, target)] g = create_graph(n_vertices, edges) assert [[5], [6], [4], [3, 2, 1, 0]] == tarjan(g)
from collections import deque def tarjan(g): """ Tarjan's algo for finding strongly connected components in a directed graph Uses two main attributes of each node to track reachability, the index of that node within a component(index), and the lowest index reachable from that node(lowlink). We then perform a dfs of the each component making sure to update these parameters for each node and saving the nodes we visit on the way. If ever we find that the lowest reachable node from a current node is equal to the index of the current node then it must be the root of a strongly connected component and so we save it and it's equireachable vertices as a strongly connected component. Complexity: strong_connect() is called at most once for each node and has a complexity of O(|E|) as it is DFS. Therefore this has complexity O(|V| + |E|) for a graph G = (V, E) """ n = len(g) stack = deque() on_stack = [False for _ in range(n)] index_of = [-1 for _ in range(n)] lowlink_of = index_of[:] def strong_connect(v, index, components): index_of[v] = index # the number when this node is seen lowlink_of[v] = index # lowest rank node reachable from here index += 1 stack.append(v) on_stack[v] = True for w in g[v]: if index_of[w] == -1: index = strong_connect(w, index, components) lowlink_of[v] = ( lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v] ) elif on_stack[w]: lowlink_of[v] = ( lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v] ) if lowlink_of[v] == index_of[v]: component = [] w = stack.pop() on_stack[w] = False component.append(w) while w != v: w = stack.pop() on_stack[w] = False component.append(w) components.append(component) return index components = [] for v in range(n): if index_of[v] == -1: strong_connect(v, 0, components) return components def create_graph(n, edges): g = [[] for _ in range(n)] for u, v in edges: g[u].append(v) return g if __name__ == "__main__": # Test n_vertices = 7 source = [0, 0, 1, 2, 3, 3, 4, 4, 6] target = [1, 3, 2, 0, 1, 4, 5, 6, 5] edges = [(u, v) for u, v in zip(source, target)] g = create_graph(n_vertices, edges) assert [[5], [6], [4], [3, 2, 1, 0]] == tarjan(g)
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
# @Author : lightXu # @File : convolve.py # @Time : 2019/7/8 0008 下午 16:13 from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import array, dot, pad, ravel, uint8, zeros def im2col(image, block_size): rows, cols = image.shape dst_height = cols - block_size[1] + 1 dst_width = rows - block_size[0] + 1 image_array = zeros((dst_height * dst_width, block_size[1] * block_size[0])) row = 0 for i in range(0, dst_height): for j in range(0, dst_width): window = ravel(image[i : i + block_size[0], j : j + block_size[1]]) image_array[row, :] = window row += 1 return image_array def img_convolve(image, filter_kernel): height, width = image.shape[0], image.shape[1] k_size = filter_kernel.shape[0] pad_size = k_size // 2 # Pads image with the edge values of array. image_tmp = pad(image, pad_size, mode="edge") # im2col, turn the k_size*k_size pixels into a row and np.vstack all rows image_array = im2col(image_tmp, (k_size, k_size)) # turn the kernel into shape(k*k, 1) kernel_array = ravel(filter_kernel) # reshape and get the dst image dst = dot(image_array, kernel_array).reshape(height, width) return dst if __name__ == "__main__": # read original image img = imread(r"../image_data/lena.jpg") # turn image in gray scale value gray = cvtColor(img, COLOR_BGR2GRAY) # Laplace operator Laplace_kernel = array([[0, 1, 0], [1, -4, 1], [0, 1, 0]]) out = img_convolve(gray, Laplace_kernel).astype(uint8) imshow("Laplacian", out) waitKey(0)
# @Author : lightXu # @File : convolve.py # @Time : 2019/7/8 0008 下午 16:13 from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import array, dot, pad, ravel, uint8, zeros def im2col(image, block_size): rows, cols = image.shape dst_height = cols - block_size[1] + 1 dst_width = rows - block_size[0] + 1 image_array = zeros((dst_height * dst_width, block_size[1] * block_size[0])) row = 0 for i in range(0, dst_height): for j in range(0, dst_width): window = ravel(image[i : i + block_size[0], j : j + block_size[1]]) image_array[row, :] = window row += 1 return image_array def img_convolve(image, filter_kernel): height, width = image.shape[0], image.shape[1] k_size = filter_kernel.shape[0] pad_size = k_size // 2 # Pads image with the edge values of array. image_tmp = pad(image, pad_size, mode="edge") # im2col, turn the k_size*k_size pixels into a row and np.vstack all rows image_array = im2col(image_tmp, (k_size, k_size)) # turn the kernel into shape(k*k, 1) kernel_array = ravel(filter_kernel) # reshape and get the dst image dst = dot(image_array, kernel_array).reshape(height, width) return dst if __name__ == "__main__": # read original image img = imread(r"../image_data/lena.jpg") # turn image in gray scale value gray = cvtColor(img, COLOR_BGR2GRAY) # Laplace operator Laplace_kernel = array([[0, 1, 0], [1, -4, 1], [0, 1, 0]]) out = img_convolve(gray, Laplace_kernel).astype(uint8) imshow("Laplacian", out) waitKey(0)
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Project Euler Problem 91: https://projecteuler.net/problem=91 The points P (x1, y1) and Q (x2, y2) are plotted at integer coordinates and are joined to the origin, O(0,0), to form ΔOPQ.  There are exactly fourteen triangles containing a right angle that can be formed when each coordinate lies between 0 and 2 inclusive; that is, 0 ≤ x1, y1, x2, y2 ≤ 2.  Given that 0 ≤ x1, y1, x2, y2 ≤ 50, how many right triangles can be formed? """ from itertools import combinations, product def is_right(x1: int, y1: int, x2: int, y2: int) -> bool: """ Check if the triangle described by P(x1,y1), Q(x2,y2) and O(0,0) is right-angled. Note: this doesn't check if P and Q are equal, but that's handled by the use of itertools.combinations in the solution function. >>> is_right(0, 1, 2, 0) True >>> is_right(1, 0, 2, 2) False """ if x1 == y1 == 0 or x2 == y2 == 0: return False a_square = x1 * x1 + y1 * y1 b_square = x2 * x2 + y2 * y2 c_square = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) return ( a_square + b_square == c_square or a_square + c_square == b_square or b_square + c_square == a_square ) def solution(limit: int = 50) -> int: """ Return the number of right triangles OPQ that can be formed by two points P, Q which have both x- and y- coordinates between 0 and limit inclusive. >>> solution(2) 14 >>> solution(10) 448 """ return sum( 1 for pt1, pt2 in combinations(product(range(limit + 1), repeat=2), 2) if is_right(*pt1, *pt2) ) if __name__ == "__main__": print(f"{solution() = }")
""" Project Euler Problem 91: https://projecteuler.net/problem=91 The points P (x1, y1) and Q (x2, y2) are plotted at integer coordinates and are joined to the origin, O(0,0), to form ΔOPQ.  There are exactly fourteen triangles containing a right angle that can be formed when each coordinate lies between 0 and 2 inclusive; that is, 0 ≤ x1, y1, x2, y2 ≤ 2.  Given that 0 ≤ x1, y1, x2, y2 ≤ 50, how many right triangles can be formed? """ from itertools import combinations, product def is_right(x1: int, y1: int, x2: int, y2: int) -> bool: """ Check if the triangle described by P(x1,y1), Q(x2,y2) and O(0,0) is right-angled. Note: this doesn't check if P and Q are equal, but that's handled by the use of itertools.combinations in the solution function. >>> is_right(0, 1, 2, 0) True >>> is_right(1, 0, 2, 2) False """ if x1 == y1 == 0 or x2 == y2 == 0: return False a_square = x1 * x1 + y1 * y1 b_square = x2 * x2 + y2 * y2 c_square = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) return ( a_square + b_square == c_square or a_square + c_square == b_square or b_square + c_square == a_square ) def solution(limit: int = 50) -> int: """ Return the number of right triangles OPQ that can be formed by two points P, Q which have both x- and y- coordinates between 0 and limit inclusive. >>> solution(2) 14 >>> solution(10) 448 """ return sum( 1 for pt1, pt2 in combinations(product(range(limit + 1), repeat=2), 2) if is_right(*pt1, *pt2) ) if __name__ == "__main__": print(f"{solution() = }")
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
# Author: Abhijeeth S import math def res(x, y): if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.log10(x) else: if x == 0: # 0 raised to any number is 0 return 0 elif y == 0: return 1 # any number raised to 0 is 1 if __name__ == "__main__": # Main function # Read two numbers from input and typecast them to int using map function. # Here x is the base and y is the power. prompt = "Enter the base and the power separated by a comma: " x1, y1 = map(int, input(prompt).split(",")) x2, y2 = map(int, input(prompt).split(",")) # We find the log of each number, using the function res(), which takes two # arguments. res1 = res(x1, y1) res2 = res(x2, y2) # We check for the largest number if res1 > res2: print("Largest number is", x1, "^", y1) elif res2 > res1: print("Largest number is", x2, "^", y2) else: print("Both are equal")
# Author: Abhijeeth S import math def res(x, y): if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.log10(x) else: if x == 0: # 0 raised to any number is 0 return 0 elif y == 0: return 1 # any number raised to 0 is 1 if __name__ == "__main__": # Main function # Read two numbers from input and typecast them to int using map function. # Here x is the base and y is the power. prompt = "Enter the base and the power separated by a comma: " x1, y1 = map(int, input(prompt).split(",")) x2, y2 = map(int, input(prompt).split(",")) # We find the log of each number, using the function res(), which takes two # arguments. res1 = res(x1, y1) res2 = res(x2, y2) # We check for the largest number if res1 > res2: print("Largest number is", x1, "^", y1) elif res2 > res1: print("Largest number is", x2, "^", y2) else: print("Both are equal")
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" https://en.wikipedia.org/wiki/Lucas_number """ def recursive_lucas_number(n_th_number: int) -> int: """ Returns the nth lucas number >>> recursive_lucas_number(1) 1 >>> recursive_lucas_number(20) 15127 >>> recursive_lucas_number(0) 2 >>> recursive_lucas_number(25) 167761 >>> recursive_lucas_number(-1.5) Traceback (most recent call last): ... TypeError: recursive_lucas_number accepts only integer arguments. """ if not isinstance(n_th_number, int): raise TypeError("recursive_lucas_number accepts only integer arguments.") if n_th_number == 0: return 2 if n_th_number == 1: return 1 return recursive_lucas_number(n_th_number - 1) + recursive_lucas_number( n_th_number - 2 ) def dynamic_lucas_number(n_th_number: int) -> int: """ Returns the nth lucas number >>> dynamic_lucas_number(1) 1 >>> dynamic_lucas_number(20) 15127 >>> dynamic_lucas_number(0) 2 >>> dynamic_lucas_number(25) 167761 >>> dynamic_lucas_number(-1.5) Traceback (most recent call last): ... TypeError: dynamic_lucas_number accepts only integer arguments. """ if not isinstance(n_th_number, int): raise TypeError("dynamic_lucas_number accepts only integer arguments.") a, b = 2, 1 for i in range(n_th_number): a, b = b, a + b return a if __name__ == "__main__": from doctest import testmod testmod() n = int(input("Enter the number of terms in lucas series:\n").strip()) print("Using recursive function to calculate lucas series:") print(" ".join(str(recursive_lucas_number(i)) for i in range(n))) print("\nUsing dynamic function to calculate lucas series:") print(" ".join(str(dynamic_lucas_number(i)) for i in range(n)))
""" https://en.wikipedia.org/wiki/Lucas_number """ def recursive_lucas_number(n_th_number: int) -> int: """ Returns the nth lucas number >>> recursive_lucas_number(1) 1 >>> recursive_lucas_number(20) 15127 >>> recursive_lucas_number(0) 2 >>> recursive_lucas_number(25) 167761 >>> recursive_lucas_number(-1.5) Traceback (most recent call last): ... TypeError: recursive_lucas_number accepts only integer arguments. """ if not isinstance(n_th_number, int): raise TypeError("recursive_lucas_number accepts only integer arguments.") if n_th_number == 0: return 2 if n_th_number == 1: return 1 return recursive_lucas_number(n_th_number - 1) + recursive_lucas_number( n_th_number - 2 ) def dynamic_lucas_number(n_th_number: int) -> int: """ Returns the nth lucas number >>> dynamic_lucas_number(1) 1 >>> dynamic_lucas_number(20) 15127 >>> dynamic_lucas_number(0) 2 >>> dynamic_lucas_number(25) 167761 >>> dynamic_lucas_number(-1.5) Traceback (most recent call last): ... TypeError: dynamic_lucas_number accepts only integer arguments. """ if not isinstance(n_th_number, int): raise TypeError("dynamic_lucas_number accepts only integer arguments.") a, b = 2, 1 for i in range(n_th_number): a, b = b, a + b return a if __name__ == "__main__": from doctest import testmod testmod() n = int(input("Enter the number of terms in lucas series:\n").strip()) print("Using recursive function to calculate lucas series:") print(" ".join(str(recursive_lucas_number(i)) for i in range(n))) print("\nUsing dynamic function to calculate lucas series:") print(" ".join(str(dynamic_lucas_number(i)) for i in range(n)))
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Functions for downloading and reading MNIST data (deprecated). This module and all its submodules are deprecated. """ import collections import gzip import os import numpy from six.moves import urllib from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python.framework import dtypes from tensorflow.python.framework import random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated _Datasets = collections.namedtuple("_Datasets", ["train", "validation", "test"]) # CVDF mirror of http://yann.lecun.com/exdb/mnist/ DEFAULT_SOURCE_URL = "https://storage.googleapis.com/cvdf-datasets/mnist/" def _read32(bytestream): dt = numpy.dtype(numpy.uint32).newbyteorder(">") return numpy.frombuffer(bytestream.read(4), dtype=dt)[0] @deprecated(None, "Please use tf.data to implement this functionality.") def _extract_images(f): """Extract the images into a 4D uint8 numpy array [index, y, x, depth]. Args: f: A file object that can be passed into a gzip reader. Returns: data: A 4D uint8 numpy array [index, y, x, depth]. Raises: ValueError: If the bytestream does not start with 2051. """ print("Extracting", f.name) with gzip.GzipFile(fileobj=f) as bytestream: magic = _read32(bytestream) if magic != 2051: raise ValueError( "Invalid magic number %d in MNIST image file: %s" % (magic, f.name) ) num_images = _read32(bytestream) rows = _read32(bytestream) cols = _read32(bytestream) buf = bytestream.read(rows * cols * num_images) data = numpy.frombuffer(buf, dtype=numpy.uint8) data = data.reshape(num_images, rows, cols, 1) return data @deprecated(None, "Please use tf.one_hot on tensors.") def _dense_to_one_hot(labels_dense, num_classes): """Convert class labels from scalars to one-hot vectors.""" num_labels = labels_dense.shape[0] index_offset = numpy.arange(num_labels) * num_classes labels_one_hot = numpy.zeros((num_labels, num_classes)) labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1 return labels_one_hot @deprecated(None, "Please use tf.data to implement this functionality.") def _extract_labels(f, one_hot=False, num_classes=10): """Extract the labels into a 1D uint8 numpy array [index]. Args: f: A file object that can be passed into a gzip reader. one_hot: Does one hot encoding for the result. num_classes: Number of classes for the one hot encoding. Returns: labels: a 1D uint8 numpy array. Raises: ValueError: If the bystream doesn't start with 2049. """ print("Extracting", f.name) with gzip.GzipFile(fileobj=f) as bytestream: magic = _read32(bytestream) if magic != 2049: raise ValueError( "Invalid magic number %d in MNIST label file: %s" % (magic, f.name) ) num_items = _read32(bytestream) buf = bytestream.read(num_items) labels = numpy.frombuffer(buf, dtype=numpy.uint8) if one_hot: return _dense_to_one_hot(labels, num_classes) return labels class _DataSet: """Container class for a _DataSet (deprecated). THIS CLASS IS DEPRECATED. """ @deprecated( None, "Please use alternatives such as official/mnist/_DataSet.py" " from tensorflow/models.", ) def __init__( self, images, labels, fake_data=False, one_hot=False, dtype=dtypes.float32, reshape=True, seed=None, ): """Construct a _DataSet. one_hot arg is used only if fake_data is true. `dtype` can be either `uint8` to leave the input as `[0, 255]`, or `float32` to rescale into `[0, 1]`. Seed arg provides for convenient deterministic testing. Args: images: The images labels: The labels fake_data: Ignore inages and labels, use fake data. one_hot: Bool, return the labels as one hot vectors (if True) or ints (if False). dtype: Output image dtype. One of [uint8, float32]. `uint8` output has range [0,255]. float32 output has range [0,1]. reshape: Bool. If True returned images are returned flattened to vectors. seed: The random seed to use. """ seed1, seed2 = random_seed.get_seed(seed) # If op level seed is not set, use whatever graph level seed is returned numpy.random.seed(seed1 if seed is None else seed2) dtype = dtypes.as_dtype(dtype).base_dtype if dtype not in (dtypes.uint8, dtypes.float32): raise TypeError("Invalid image dtype %r, expected uint8 or float32" % dtype) if fake_data: self._num_examples = 10000 self.one_hot = one_hot else: assert ( images.shape[0] == labels.shape[0] ), f"images.shape: {images.shape} labels.shape: {labels.shape}" self._num_examples = images.shape[0] # Convert shape from [num examples, rows, columns, depth] # to [num examples, rows*columns] (assuming depth == 1) if reshape: assert images.shape[3] == 1 images = images.reshape( images.shape[0], images.shape[1] * images.shape[2] ) if dtype == dtypes.float32: # Convert from [0, 255] -> [0.0, 1.0]. images = images.astype(numpy.float32) images = numpy.multiply(images, 1.0 / 255.0) self._images = images self._labels = labels self._epochs_completed = 0 self._index_in_epoch = 0 @property def images(self): return self._images @property def labels(self): return self._labels @property def num_examples(self): return self._num_examples @property def epochs_completed(self): return self._epochs_completed def next_batch(self, batch_size, fake_data=False, shuffle=True): """Return the next `batch_size` examples from this data set.""" if fake_data: fake_image = [1] * 784 if self.one_hot: fake_label = [1] + [0] * 9 else: fake_label = 0 return ( [fake_image for _ in xrange(batch_size)], [fake_label for _ in xrange(batch_size)], ) start = self._index_in_epoch # Shuffle for the first epoch if self._epochs_completed == 0 and start == 0 and shuffle: perm0 = numpy.arange(self._num_examples) numpy.random.shuffle(perm0) self._images = self.images[perm0] self._labels = self.labels[perm0] # Go to the next epoch if start + batch_size > self._num_examples: # Finished epoch self._epochs_completed += 1 # Get the rest examples in this epoch rest_num_examples = self._num_examples - start images_rest_part = self._images[start : self._num_examples] labels_rest_part = self._labels[start : self._num_examples] # Shuffle the data if shuffle: perm = numpy.arange(self._num_examples) numpy.random.shuffle(perm) self._images = self.images[perm] self._labels = self.labels[perm] # Start next epoch start = 0 self._index_in_epoch = batch_size - rest_num_examples end = self._index_in_epoch images_new_part = self._images[start:end] labels_new_part = self._labels[start:end] return ( numpy.concatenate((images_rest_part, images_new_part), axis=0), numpy.concatenate((labels_rest_part, labels_new_part), axis=0), ) else: self._index_in_epoch += batch_size end = self._index_in_epoch return self._images[start:end], self._labels[start:end] @deprecated(None, "Please write your own downloading logic.") def _maybe_download(filename, work_directory, source_url): """Download the data from source url, unless it's already here. Args: filename: string, name of the file in the directory. work_directory: string, path to working directory. source_url: url to download from if file doesn't exist. Returns: Path to resulting file. """ if not gfile.Exists(work_directory): gfile.MakeDirs(work_directory) filepath = os.path.join(work_directory, filename) if not gfile.Exists(filepath): urllib.request.urlretrieve(source_url, filepath) with gfile.GFile(filepath) as f: size = f.size() print("Successfully downloaded", filename, size, "bytes.") return filepath @deprecated( None, "Please use alternatives such as:" " tensorflow_datasets.load('mnist')" ) def read_data_sets( train_dir, fake_data=False, one_hot=False, dtype=dtypes.float32, reshape=True, validation_size=5000, seed=None, source_url=DEFAULT_SOURCE_URL, ): if fake_data: def fake(): return _DataSet( [], [], fake_data=True, one_hot=one_hot, dtype=dtype, seed=seed ) train = fake() validation = fake() test = fake() return _Datasets(train=train, validation=validation, test=test) if not source_url: # empty string check source_url = DEFAULT_SOURCE_URL train_images_file = "train-images-idx3-ubyte.gz" train_labels_file = "train-labels-idx1-ubyte.gz" test_images_file = "t10k-images-idx3-ubyte.gz" test_labels_file = "t10k-labels-idx1-ubyte.gz" local_file = _maybe_download( train_images_file, train_dir, source_url + train_images_file ) with gfile.Open(local_file, "rb") as f: train_images = _extract_images(f) local_file = _maybe_download( train_labels_file, train_dir, source_url + train_labels_file ) with gfile.Open(local_file, "rb") as f: train_labels = _extract_labels(f, one_hot=one_hot) local_file = _maybe_download( test_images_file, train_dir, source_url + test_images_file ) with gfile.Open(local_file, "rb") as f: test_images = _extract_images(f) local_file = _maybe_download( test_labels_file, train_dir, source_url + test_labels_file ) with gfile.Open(local_file, "rb") as f: test_labels = _extract_labels(f, one_hot=one_hot) if not 0 <= validation_size <= len(train_images): raise ValueError( f"Validation size should be between 0 and {len(train_images)}. Received: {validation_size}." ) validation_images = train_images[:validation_size] validation_labels = train_labels[:validation_size] train_images = train_images[validation_size:] train_labels = train_labels[validation_size:] options = dict(dtype=dtype, reshape=reshape, seed=seed) train = _DataSet(train_images, train_labels, **options) validation = _DataSet(validation_images, validation_labels, **options) test = _DataSet(test_images, test_labels, **options) return _Datasets(train=train, validation=validation, test=test)
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Functions for downloading and reading MNIST data (deprecated). This module and all its submodules are deprecated. """ import collections import gzip import os import numpy from six.moves import urllib from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python.framework import dtypes from tensorflow.python.framework import random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated _Datasets = collections.namedtuple("_Datasets", ["train", "validation", "test"]) # CVDF mirror of http://yann.lecun.com/exdb/mnist/ DEFAULT_SOURCE_URL = "https://storage.googleapis.com/cvdf-datasets/mnist/" def _read32(bytestream): dt = numpy.dtype(numpy.uint32).newbyteorder(">") return numpy.frombuffer(bytestream.read(4), dtype=dt)[0] @deprecated(None, "Please use tf.data to implement this functionality.") def _extract_images(f): """Extract the images into a 4D uint8 numpy array [index, y, x, depth]. Args: f: A file object that can be passed into a gzip reader. Returns: data: A 4D uint8 numpy array [index, y, x, depth]. Raises: ValueError: If the bytestream does not start with 2051. """ print("Extracting", f.name) with gzip.GzipFile(fileobj=f) as bytestream: magic = _read32(bytestream) if magic != 2051: raise ValueError( "Invalid magic number %d in MNIST image file: %s" % (magic, f.name) ) num_images = _read32(bytestream) rows = _read32(bytestream) cols = _read32(bytestream) buf = bytestream.read(rows * cols * num_images) data = numpy.frombuffer(buf, dtype=numpy.uint8) data = data.reshape(num_images, rows, cols, 1) return data @deprecated(None, "Please use tf.one_hot on tensors.") def _dense_to_one_hot(labels_dense, num_classes): """Convert class labels from scalars to one-hot vectors.""" num_labels = labels_dense.shape[0] index_offset = numpy.arange(num_labels) * num_classes labels_one_hot = numpy.zeros((num_labels, num_classes)) labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1 return labels_one_hot @deprecated(None, "Please use tf.data to implement this functionality.") def _extract_labels(f, one_hot=False, num_classes=10): """Extract the labels into a 1D uint8 numpy array [index]. Args: f: A file object that can be passed into a gzip reader. one_hot: Does one hot encoding for the result. num_classes: Number of classes for the one hot encoding. Returns: labels: a 1D uint8 numpy array. Raises: ValueError: If the bystream doesn't start with 2049. """ print("Extracting", f.name) with gzip.GzipFile(fileobj=f) as bytestream: magic = _read32(bytestream) if magic != 2049: raise ValueError( "Invalid magic number %d in MNIST label file: %s" % (magic, f.name) ) num_items = _read32(bytestream) buf = bytestream.read(num_items) labels = numpy.frombuffer(buf, dtype=numpy.uint8) if one_hot: return _dense_to_one_hot(labels, num_classes) return labels class _DataSet: """Container class for a _DataSet (deprecated). THIS CLASS IS DEPRECATED. """ @deprecated( None, "Please use alternatives such as official/mnist/_DataSet.py" " from tensorflow/models.", ) def __init__( self, images, labels, fake_data=False, one_hot=False, dtype=dtypes.float32, reshape=True, seed=None, ): """Construct a _DataSet. one_hot arg is used only if fake_data is true. `dtype` can be either `uint8` to leave the input as `[0, 255]`, or `float32` to rescale into `[0, 1]`. Seed arg provides for convenient deterministic testing. Args: images: The images labels: The labels fake_data: Ignore inages and labels, use fake data. one_hot: Bool, return the labels as one hot vectors (if True) or ints (if False). dtype: Output image dtype. One of [uint8, float32]. `uint8` output has range [0,255]. float32 output has range [0,1]. reshape: Bool. If True returned images are returned flattened to vectors. seed: The random seed to use. """ seed1, seed2 = random_seed.get_seed(seed) # If op level seed is not set, use whatever graph level seed is returned numpy.random.seed(seed1 if seed is None else seed2) dtype = dtypes.as_dtype(dtype).base_dtype if dtype not in (dtypes.uint8, dtypes.float32): raise TypeError("Invalid image dtype %r, expected uint8 or float32" % dtype) if fake_data: self._num_examples = 10000 self.one_hot = one_hot else: assert ( images.shape[0] == labels.shape[0] ), f"images.shape: {images.shape} labels.shape: {labels.shape}" self._num_examples = images.shape[0] # Convert shape from [num examples, rows, columns, depth] # to [num examples, rows*columns] (assuming depth == 1) if reshape: assert images.shape[3] == 1 images = images.reshape( images.shape[0], images.shape[1] * images.shape[2] ) if dtype == dtypes.float32: # Convert from [0, 255] -> [0.0, 1.0]. images = images.astype(numpy.float32) images = numpy.multiply(images, 1.0 / 255.0) self._images = images self._labels = labels self._epochs_completed = 0 self._index_in_epoch = 0 @property def images(self): return self._images @property def labels(self): return self._labels @property def num_examples(self): return self._num_examples @property def epochs_completed(self): return self._epochs_completed def next_batch(self, batch_size, fake_data=False, shuffle=True): """Return the next `batch_size` examples from this data set.""" if fake_data: fake_image = [1] * 784 if self.one_hot: fake_label = [1] + [0] * 9 else: fake_label = 0 return ( [fake_image for _ in xrange(batch_size)], [fake_label for _ in xrange(batch_size)], ) start = self._index_in_epoch # Shuffle for the first epoch if self._epochs_completed == 0 and start == 0 and shuffle: perm0 = numpy.arange(self._num_examples) numpy.random.shuffle(perm0) self._images = self.images[perm0] self._labels = self.labels[perm0] # Go to the next epoch if start + batch_size > self._num_examples: # Finished epoch self._epochs_completed += 1 # Get the rest examples in this epoch rest_num_examples = self._num_examples - start images_rest_part = self._images[start : self._num_examples] labels_rest_part = self._labels[start : self._num_examples] # Shuffle the data if shuffle: perm = numpy.arange(self._num_examples) numpy.random.shuffle(perm) self._images = self.images[perm] self._labels = self.labels[perm] # Start next epoch start = 0 self._index_in_epoch = batch_size - rest_num_examples end = self._index_in_epoch images_new_part = self._images[start:end] labels_new_part = self._labels[start:end] return ( numpy.concatenate((images_rest_part, images_new_part), axis=0), numpy.concatenate((labels_rest_part, labels_new_part), axis=0), ) else: self._index_in_epoch += batch_size end = self._index_in_epoch return self._images[start:end], self._labels[start:end] @deprecated(None, "Please write your own downloading logic.") def _maybe_download(filename, work_directory, source_url): """Download the data from source url, unless it's already here. Args: filename: string, name of the file in the directory. work_directory: string, path to working directory. source_url: url to download from if file doesn't exist. Returns: Path to resulting file. """ if not gfile.Exists(work_directory): gfile.MakeDirs(work_directory) filepath = os.path.join(work_directory, filename) if not gfile.Exists(filepath): urllib.request.urlretrieve(source_url, filepath) with gfile.GFile(filepath) as f: size = f.size() print("Successfully downloaded", filename, size, "bytes.") return filepath @deprecated( None, "Please use alternatives such as:" " tensorflow_datasets.load('mnist')" ) def read_data_sets( train_dir, fake_data=False, one_hot=False, dtype=dtypes.float32, reshape=True, validation_size=5000, seed=None, source_url=DEFAULT_SOURCE_URL, ): if fake_data: def fake(): return _DataSet( [], [], fake_data=True, one_hot=one_hot, dtype=dtype, seed=seed ) train = fake() validation = fake() test = fake() return _Datasets(train=train, validation=validation, test=test) if not source_url: # empty string check source_url = DEFAULT_SOURCE_URL train_images_file = "train-images-idx3-ubyte.gz" train_labels_file = "train-labels-idx1-ubyte.gz" test_images_file = "t10k-images-idx3-ubyte.gz" test_labels_file = "t10k-labels-idx1-ubyte.gz" local_file = _maybe_download( train_images_file, train_dir, source_url + train_images_file ) with gfile.Open(local_file, "rb") as f: train_images = _extract_images(f) local_file = _maybe_download( train_labels_file, train_dir, source_url + train_labels_file ) with gfile.Open(local_file, "rb") as f: train_labels = _extract_labels(f, one_hot=one_hot) local_file = _maybe_download( test_images_file, train_dir, source_url + test_images_file ) with gfile.Open(local_file, "rb") as f: test_images = _extract_images(f) local_file = _maybe_download( test_labels_file, train_dir, source_url + test_labels_file ) with gfile.Open(local_file, "rb") as f: test_labels = _extract_labels(f, one_hot=one_hot) if not 0 <= validation_size <= len(train_images): raise ValueError( f"Validation size should be between 0 and {len(train_images)}. Received: {validation_size}." ) validation_images = train_images[:validation_size] validation_labels = train_labels[:validation_size] train_images = train_images[validation_size:] train_labels = train_labels[validation_size:] options = dict(dtype=dtype, reshape=reshape, seed=seed) train = _DataSet(train_images, train_labels, **options) validation = _DataSet(validation_images, validation_labels, **options) test = _DataSet(test_images, test_labels, **options) return _Datasets(train=train, validation=validation, test=test)
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
#!/usr/bin/env python # # Sort large text files in a minimum amount of memory # import argparse import os class FileSplitter: BLOCK_FILENAME_FORMAT = "block_{0}.dat" def __init__(self, filename): self.filename = filename self.block_filenames = [] def write_block(self, data, block_number): filename = self.BLOCK_FILENAME_FORMAT.format(block_number) with open(filename, "w") as file: file.write(data) self.block_filenames.append(filename) def get_block_filenames(self): return self.block_filenames def split(self, block_size, sort_key=None): i = 0 with open(self.filename) as file: while True: lines = file.readlines(block_size) if lines == []: break if sort_key is None: lines.sort() else: lines.sort(key=sort_key) self.write_block("".join(lines), i) i += 1 def cleanup(self): map(lambda f: os.remove(f), self.block_filenames) class NWayMerge: def select(self, choices): min_index = -1 min_str = None for i in range(len(choices)): if min_str is None or choices[i] < min_str: min_index = i return min_index class FilesArray: def __init__(self, files): self.files = files self.empty = set() self.num_buffers = len(files) self.buffers = {i: None for i in range(self.num_buffers)} def get_dict(self): return { i: self.buffers[i] for i in range(self.num_buffers) if i not in self.empty } def refresh(self): for i in range(self.num_buffers): if self.buffers[i] is None and i not in self.empty: self.buffers[i] = self.files[i].readline() if self.buffers[i] == "": self.empty.add(i) self.files[i].close() if len(self.empty) == self.num_buffers: return False return True def unshift(self, index): value = self.buffers[index] self.buffers[index] = None return value class FileMerger: def __init__(self, merge_strategy): self.merge_strategy = merge_strategy def merge(self, filenames, outfilename, buffer_size): buffers = FilesArray(self.get_file_handles(filenames, buffer_size)) with open(outfilename, "w", buffer_size) as outfile: while buffers.refresh(): min_index = self.merge_strategy.select(buffers.get_dict()) outfile.write(buffers.unshift(min_index)) def get_file_handles(self, filenames, buffer_size): files = {} for i in range(len(filenames)): files[i] = open(filenames[i], "r", buffer_size) return files class ExternalSort: def __init__(self, block_size): self.block_size = block_size def sort(self, filename, sort_key=None): num_blocks = self.get_number_blocks(filename, self.block_size) splitter = FileSplitter(filename) splitter.split(self.block_size, sort_key) merger = FileMerger(NWayMerge()) buffer_size = self.block_size / (num_blocks + 1) merger.merge(splitter.get_block_filenames(), filename + ".out", buffer_size) splitter.cleanup() def get_number_blocks(self, filename, block_size): return (os.stat(filename).st_size / block_size) + 1 def parse_memory(string): if string[-1].lower() == "k": return int(string[:-1]) * 1024 elif string[-1].lower() == "m": return int(string[:-1]) * 1024 * 1024 elif string[-1].lower() == "g": return int(string[:-1]) * 1024 * 1024 * 1024 else: return int(string) def main(): parser = argparse.ArgumentParser() parser.add_argument( "-m", "--mem", help="amount of memory to use for sorting", default="100M" ) parser.add_argument( "filename", metavar="<filename>", nargs=1, help="name of file to sort" ) args = parser.parse_args() sorter = ExternalSort(parse_memory(args.mem)) sorter.sort(args.filename[0]) if __name__ == "__main__": main()
#!/usr/bin/env python # # Sort large text files in a minimum amount of memory # import argparse import os class FileSplitter: BLOCK_FILENAME_FORMAT = "block_{0}.dat" def __init__(self, filename): self.filename = filename self.block_filenames = [] def write_block(self, data, block_number): filename = self.BLOCK_FILENAME_FORMAT.format(block_number) with open(filename, "w") as file: file.write(data) self.block_filenames.append(filename) def get_block_filenames(self): return self.block_filenames def split(self, block_size, sort_key=None): i = 0 with open(self.filename) as file: while True: lines = file.readlines(block_size) if lines == []: break if sort_key is None: lines.sort() else: lines.sort(key=sort_key) self.write_block("".join(lines), i) i += 1 def cleanup(self): map(lambda f: os.remove(f), self.block_filenames) class NWayMerge: def select(self, choices): min_index = -1 min_str = None for i in range(len(choices)): if min_str is None or choices[i] < min_str: min_index = i return min_index class FilesArray: def __init__(self, files): self.files = files self.empty = set() self.num_buffers = len(files) self.buffers = {i: None for i in range(self.num_buffers)} def get_dict(self): return { i: self.buffers[i] for i in range(self.num_buffers) if i not in self.empty } def refresh(self): for i in range(self.num_buffers): if self.buffers[i] is None and i not in self.empty: self.buffers[i] = self.files[i].readline() if self.buffers[i] == "": self.empty.add(i) self.files[i].close() if len(self.empty) == self.num_buffers: return False return True def unshift(self, index): value = self.buffers[index] self.buffers[index] = None return value class FileMerger: def __init__(self, merge_strategy): self.merge_strategy = merge_strategy def merge(self, filenames, outfilename, buffer_size): buffers = FilesArray(self.get_file_handles(filenames, buffer_size)) with open(outfilename, "w", buffer_size) as outfile: while buffers.refresh(): min_index = self.merge_strategy.select(buffers.get_dict()) outfile.write(buffers.unshift(min_index)) def get_file_handles(self, filenames, buffer_size): files = {} for i in range(len(filenames)): files[i] = open(filenames[i], "r", buffer_size) return files class ExternalSort: def __init__(self, block_size): self.block_size = block_size def sort(self, filename, sort_key=None): num_blocks = self.get_number_blocks(filename, self.block_size) splitter = FileSplitter(filename) splitter.split(self.block_size, sort_key) merger = FileMerger(NWayMerge()) buffer_size = self.block_size / (num_blocks + 1) merger.merge(splitter.get_block_filenames(), filename + ".out", buffer_size) splitter.cleanup() def get_number_blocks(self, filename, block_size): return (os.stat(filename).st_size / block_size) + 1 def parse_memory(string): if string[-1].lower() == "k": return int(string[:-1]) * 1024 elif string[-1].lower() == "m": return int(string[:-1]) * 1024 * 1024 elif string[-1].lower() == "g": return int(string[:-1]) * 1024 * 1024 * 1024 else: return int(string) def main(): parser = argparse.ArgumentParser() parser.add_argument( "-m", "--mem", help="amount of memory to use for sorting", default="100M" ) parser.add_argument( "filename", metavar="<filename>", nargs=1, help="name of file to sort" ) args = parser.parse_args() sorter = ExternalSort(parse_memory(args.mem)) sorter.sort(args.filename[0]) if __name__ == "__main__": main()
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
* text=auto
* text=auto
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" A pure Python implementation of the quick sort algorithm For doctests run following command: python3 -m doctest -v quick_sort.py For manual testing run: python3 quick_sort.py """ from typing import List def quick_sort(collection: list) -> list: """A pure Python implementation of quick sort algorithm :param collection: a mutable collection of comparable items :return: the same collection ordered by ascending Examples: >>> quick_sort([0, 5, 3, 2, 2]) [0, 2, 2, 3, 5] >>> quick_sort([]) [] >>> quick_sort([-2, 5, 0, -45]) [-45, -2, 0, 5] """ if len(collection) < 2: return collection pivot = collection.pop() # Use the last element as the first pivot greater: List[int] = [] # All elements greater than pivot lesser: List[int] = [] # All elements less than or equal to pivot for element in collection: (greater if element > pivot else lesser).append(element) return quick_sort(lesser) + [pivot] + quick_sort(greater) if __name__ == "__main__": user_input = input("Enter numbers separated by a comma:\n").strip() unsorted = [int(item) for item in user_input.split(",")] print(quick_sort(unsorted))
""" A pure Python implementation of the quick sort algorithm For doctests run following command: python3 -m doctest -v quick_sort.py For manual testing run: python3 quick_sort.py """ from typing import List def quick_sort(collection: list) -> list: """A pure Python implementation of quick sort algorithm :param collection: a mutable collection of comparable items :return: the same collection ordered by ascending Examples: >>> quick_sort([0, 5, 3, 2, 2]) [0, 2, 2, 3, 5] >>> quick_sort([]) [] >>> quick_sort([-2, 5, 0, -45]) [-45, -2, 0, 5] """ if len(collection) < 2: return collection pivot = collection.pop() # Use the last element as the first pivot greater: List[int] = [] # All elements greater than pivot lesser: List[int] = [] # All elements less than or equal to pivot for element in collection: (greater if element > pivot else lesser).append(element) return quick_sort(lesser) + [pivot] + quick_sort(greater) if __name__ == "__main__": user_input = input("Enter numbers separated by a comma:\n").strip() unsorted = [int(item) for item in user_input.split(",")] print(quick_sort(unsorted))
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
DIRCeu Seu S\R(!+NG #ʸ .coveragerceZ3deZ3d\G jERrgk k#.gitattributeseu Seu S\IG& LL1o쟓o .github/CODEOWNERSevev\K>|(o\ITH3)v .github/pull_request_template.mder`8er`8\P 6V&k&g:d5 +.github/stale.ymlexQ0bexQ0b\EBъގ{!.github/workflows/build.ymleuL feuL f\SOT&@Pe3,[w$&.github/workflows/directory_writer.ymlexQ0bexQ0b\YY\Υܲ͜mu+ .github/workflows/pre-commit.ymleuL feuL f\TgR8e~ا~U#.github/workflows/project_euler.ymleu"&jeu"&j\VWL1(6+a"h}~ .gitignoreeZ3deZ3d\W4Yu郍nO8 E .gitpod.ymlexQ0bexQ0b\5(^ﱴ m Ђ.pre-commit-config.yamlexQ0bexQ0b\D)A^͘ Bn$*[CONTRIBUTING.mdexQ0bexQ0b\F;m߶sި)OKa">%.vR DIRECTORY.mdeuIeuI\]4…| ) LICENSE.mdexQ0bexQ0b\Nj1>TU*Rئ qF README.mdeo Peo P\⛲CK)wZSarithmetic_analysis/__init__.pyeuIeuI\\yg4;5_i : arithmetic_analysis/bisection.pyexQ0bexQ0b\c [Q v*4ٕQ'J+arithmetic_analysis/gaussian_elimination.pyeo Peo P\倈ddûr^7 .arithmetic_analysis/image_data/2D_problems.jpgeo Peo P\ jE6  =PC20arithmetic_analysis/image_data/2D_problems_1.jpgeo Peo P\ ⛲CK)wZS*arithmetic_analysis/image_data/__init__.pyexQ0bexQ0b\ 2(P= :-7d`/H,arithmetic_analysis/in_static_equilibrium.pyeu$eu$\e Mة5Do[;1#arithmetic_analysis/intersection.pyew9mew9m\7ѷM4()'arithmetic_analysis/lu_decomposition.pyew^ ew^ \f<O,[Cg_SD:3arithmetic_analysis/newton_forward_interpolation.pyeu$eu$\ᩩCrgpB Ñ$arithmetic_analysis/newton_method.pyew^ ew^ \skZߍI%L}6%arithmetic_analysis/newton_raphson.pyew9mew9m\D~ݏ\ka: $arithmetic_analysis/secant_method.pyeZ3deZ3d\i⛲CK)wZSbacktracking/__init__.pyew^ ew^ \jvF(75PUTu % backtracking/all_combinations.pyew^ ew^ \k,\z[gDp; backtracking/all_permutations.pyew^ ew^ \lNeڠ0P:_' backtracking/all_subsequences.pyew^ ew^ \m 9Vz㙡 rw`backtracking/coloring.pyew^ ew^ \q{5 |-"\c4>J!backtracking/hamiltonian_cycle.pyew^ ew^ \r if}x94g =<Qbacktracking/knight_tour.pyew^ ew^ \tIݢGDQ-F backtracking/minimax.pyew^ ew^ \u .);Ijbacktracking/n_queens.pyew^ ew^ \vBe\6.s YBbacktracking/n_queens_math.pyew^ ew^ \x *AڨO"Nbbacktracking/rat_in_maze.pyew9mew9m\y;o)O9.r<`}lbacktracking/sudoku.pyew^ ew^ \z%oĵzu3sbacktracking/sum_of_subsets.pyewWewW\`.f$⦃Й6bit_manipulation/README.mdeZ<ceZ<c\~⛲CK)wZSbit_manipulation/__init__.pyewWewW\bD0Q]5m 'bit_manipulation/binary_and_operator.pyeZ<ceZ<c\V<iE3M f~-1t(bit_manipulation/binary_count_setbits.pyeZ<ceZ<c\īfD9BHƊ/bit_manipulation/binary_count_trailing_zeros.pyewWewW\ڿ[ ]n+b<&bit_manipulation/binary_or_operator.pyexQ0bexQ0b\ |bX3 H.+!bit_manipulation/binary_shifts.pyenf/enf/\&a,NB׌ޓXGd*bit_manipulation/binary_twos_complement.pyewWewW\ob*pOÃ'bit_manipulation/binary_xor_operator.pyeu Seu S\Q+cQu9]I,bit_manipulation/count_number_of_one_bits.pyeqSeqS\ U`)H7:Z}^ bit_manipulation/reverse_bits.pyexQ0bexQ0b\@(f7h&EcT4Y6bit_manipulation/single_bit_manipulation_operations.pyeZ<ceZ<c\⛲CK)wZSblockchain/__init__.pyew^ ew^ \)ߵGNyi)¿a'blockchain/chinese_remainder_theorem.pyew^ ew^ \ }t8ErC(\I"blockchain/diophantine_equation.pyew^ ew^ \H iOP*бTo1WaFƎblockchain/modular_division.pyeZ<ceZ<c\⛲CK)wZSboolean_algebra/__init__.pyew^ ew^ \{pZpr#g]S Q4#boolean_algebra/quine_mc_cluskey.pyeu8ieu8i\ݴ'!81cellular_automata/README.mdeZ<ceZ<c\⛲CK)wZScellular_automata/__init__.pyexQ0bexQ0b\ 4z?"<{dk8)cellular_automata/conways_game_of_life.pyexQ0bexQ0b\ P]ŹB\WfLJ$cellular_automata/one_dimensional.pyeZ<ceZ<c\⛲CK)wZSciphers/__init__.pyexQ0bexQ0b\JqKP/w^ɶEciphers/a1z26.pyexQ0bexQ0b\M ό _LC3;Cfͮ,ciphers/affine_cipher.pyexQ0bexQ0b\D}4zR%epM ciphers/atbash.pyew Kew K\_!~bT=p>WC<ciphers/base16.pyexQ0bexQ0b\W[Mօ#rb Sciphers/base32.pyew Kew K\cJs<^" k)_ciphers/base64_encoding.pyexQ0bexQ0b\W3ZV>E'Uciphers/base85.pyexQ0bexQ0b\ȅ@t ASo>ciphers/beaufort_cipher.pyexQ0bexQ0b\re$TkQ K$ciphers/brute_force_caesar_cipher.pyew^ ew^ \K/vsņX_\kciphers/caesar_cipher.pyexQ0bexQ0b\tads袔<5ɣciphers/cryptomath_module.pyexQ0bexQ0b\a"A+S 2#-JF *ciphers/decrypt_caesar_with_chi_squared.pyeu$eu$\X~lXS' n-%ciphers/deterministic_miller_rabin.pyexQ0bexQ0b\D+F` ciphers/diffie.pyexQ0bexQ0b\L15{H>a}2%пciphers/diffie_hellman.pyexQ0bexQ0b\RiAcңi? ciphers/elgamal_key_generator.pyexQ0bexQ0b\!`CDVxOaAFUciphers/enigma_machine2.pyexQ0bexQ0b\7]- "iA,a31ciphers/hill_cipher.pyexQ0bexQ0b\/Y)1 c򅧻Fciphers/mixed_keyword_cypher.pyexQ0bexQ0b\ )D(ղc{"ciphers/mono_alphabetic_ciphers.pyexQ0bexQ0b\K.(2j?ffv$ciphers/morse_code_implementation.pyexQ0bexQ0b\Q+M1B憝fX,ciphers/onepad_cipher.pyexQ0bexQ0b\ !7DSB9%oɃs&ciphers/playfair_cipher.pyexQ0bexQ0b\L)<L|~_ۂciphers/porta_cipher.pyeq$$eq$$\n$RS:5}aciphers/prehistoric_men.txteu$eu$\ ebN^}[ciphers/rabin_miller.pyexQ0bexQ0b\ 8%ARj9K⳾jciphers/rail_fence_cipher.pyexQ0bexQ0b\A!ژ̨B79(ciphers/rot13.pyexQ0bexQ0b\ }n3av;]iciphers/rsa_cipher.pyexQ0bexQ0b\`-39z&yciphers/rsa_factorization.pyexQ0bexQ0b\+VPrPVKMo4rciphers/rsa_key_generator.pyexQ0bexQ0b\"b<P6=粐M ciphers/shuffled_shift_cipher.pyexQ0bexQ0b\ q>s]i Xph ciphers/simple_keyword_cypher.pyexQ0bexQ0b\dnI"K4%%ciphers/simple_substitution_cipher.pyexQ0bexQ0b\ 2wDB$ܺ2ciphers/trafid_cipher.pyexQ0bexQ0b\j " _<J|1jhciphers/transposition_cipher.pyexQ0bexQ0b\prEV4㏠84ciphers/transposition_cipher_encrypt_decrypt_file.pyexQ0bexQ0b\R=|%g!j ;ciphers/vigenere_cipher.pyexQ0bexQ0b\2PVzys '1]ciphers/xor_cipher.pyeZ5EbeZ5Eb\⛲CK)wZScompression/__init__.pyew Kew K\O}pZB [!w7{?compression/burrows_wheeler.pyew9mew9m\d :<zv+u6tcompression/huffman.pyeZ5EbeZ5Eb\DſE |#f|,compression/image_data/PSNR-example-base.pngeZrNbeZrNb\7mwMf?G/compression/image_data/PSNR-example-comp-10.jpgeZrNbeZrNb\⛲CK)wZS"compression/image_data/__init__.pyeZrNbeZrNb\h<u!ǵy쮹V+compression/image_data/compressed_image.pngeZrNbeZrNb\u":X:3 Dי)C#(compression/image_data/example_image.jpgeZrNbeZrNb\nE>VQjHTN 2compression/image_data/example_wikipedia_image.jpgeZrNbeZrNb\G oޛjqt+4Wj)compression/image_data/original_image.pngexQ0bexQ0b\f-{448]yVLcompression/lempel_ziv.pyeu Seu S\ 8M<, ,O}8婚B:5$compression/lempel_ziv_decompress.pyew Kew K\llL8*;\.qsv)compression/peak_signal_to_noise_ratio.pyeu8ieu8i\I0 {O YS2 "computer_vision/README.mdeZrNbeZrNb\⛲CK)wZScomputer_vision/__init__.pyexQ0bexQ0b\Vxs0/d'computer_vision/harriscorner.pyexQ0bexQ0b\ vey3֩'w |s computer_vision/meanthreshold.pyeZWaeZWa\⛲CK)wZSconversions/__init__.pyeu Seu S\b^G[ܗ+ufgo conversions/binary_to_decimal.pyexQ0bexQ0b\YH~ɕ&}+~\}conversions/binary_to_octal.pyeu Seu S\ <rs*c50$<conversions/decimal_to_any.pyexQ0bexQ0b\~jc*f%. conversions/decimal_to_binary.pyeu Seu S\IY/jg^!s m+h*conversions/decimal_to_binary_recursion.pyexQ0bexQ0b\nC?xfͩCC1x%conversions/decimal_to_hexadecimal.pyexQ9aexQ9a\H0B*A conversions/decimal_to_octal.pyeu Seu S\徱~d=db|I^%conversions/hexadecimal_to_decimal.pyew^ ew^ \ hEeMr<4`"conversions/molecular_chemistry.pyeuL feuL f\Zss.ԱulԽ/Oconversions/octal_to_decimal.pyexQ9aexQ9a\ D nݻv-!conversions/prefix_conversions.pyeu Seu S\3槊M2N } y0conversions/roman_numerals.pyeu Seu S\-"|G'=ٺ|Džj&conversions/temperature_conversions.pyexQ9aexQ9a\$Q_/o*"R conversions/weight_conversion.pyeZWaeZWa\%⛲CK)wZSdata_structures/__init__.pyeZWaeZWa\5⛲CK)wZS'data_structures/binary_tree/__init__.pyew^ ew^ \%8ݖiehS$'data_structures/binary_tree/avl_tree.pyew^ ew^ \W[~h -ҡu}.$0data_structures/binary_tree/basic_binary_tree.pyexQ9aexQ9a\EÓ?| /P#oFM~*j1data_structures/binary_tree/binary_search_tree.pyew^ ew^ \@|^(T"pNG.;data_structures/binary_tree/binary_search_tree_recursive.pyewWewW\e{7N)Ew 2~ 1data_structures/binary_tree/binary_tree_mirror.pyexQ9aexQ9a\f|ۼ*_9BC.IK l5data_structures/binary_tree/binary_tree_traversals.pyeu"&jeu"&j\"Tzƍ \4o +data_structures/binary_tree/fenwick_tree.pyew^ ew^ \f)F j:*0data_structures/binary_tree/lazy_segment_tree.pyev4ev4\h /?ϙ_.Bٙ k}5data_structures/binary_tree/lowest_common_ancestor.pyew^ ew^ \k *<6w|Ћ55data_structures/binary_tree/merge_two_binary_trees.pyev4ev4\ ۧ(?JSw9data_structures/binary_tree/non_recursive_segment_tree.pyeu Seu S\ TBIm9O3U>data_structures/binary_tree/number_of_possible_binary_trees.pyew^ ew^ \U`ޗq/'U1 l-data_structures/binary_tree/red_black_tree.pyeu Seu S\  8E拲pSAˉ]+data_structures/binary_tree/segment_tree.pyeses\/)ʋqOtxiDã1data_structures/binary_tree/segment_tree_other.pyew^ ew^ \ O̒C373PXe$data_structures/binary_tree/treap.pyeZWaeZWa\V⛲CK)wZS(data_structures/disjoint_set/__init__.pyeZWaeZWa\WQ3[ ްI kdO6data_structures/disjoint_set/alternate_disjoint_set.pyew^ ew^ \٩;bJm醷iHK^~,data_structures/disjoint_set/disjoint_set.pyeZWaeZWa\Z⛲CK)wZS#data_structures/hashing/__init__.pyeuL feuL f\XWGpIݟ +%پ&data_structures/hashing/double_hash.pyew^ ew^ \  nL6>ET%data_structures/hashing/hash_table.pyew^ ew^ \_Ph|m_Io'36data_structures/hashing/hash_table_with_linked_list.pyeZWaeZWa\a⛲CK)wZS1data_structures/hashing/number_theory/__init__.pyeuQg#euQg#\M@upxyw?6data_structures/hashing/number_theory/prime_numbers.pyeo WYeo WY\c 04 4F ozc {R,data_structures/hashing/quadratic_probing.pyeZWaeZWa\g⛲CK)wZS data_structures/heap/__init__.pyeu Seu S\ 13KDNv__'X|l%data_structures/heap/binomial_heap.pyexQ9aexQ9a\M6,#^4;n;5CRdata_structures/heap/heap.pyeu Seu S\U<E8W$3Լla$data_structures/heap/heap_generic.pyexQ9aexQ9a\ *,uY9ۊ?5 data_structures/heap/max_heap.pyeu Seu S\eă6)UT3< data_structures/heap/min_heap.pyew^ ew^ \A "r'zax?'data_structures/heap/randomized_heap.pyew^ ew^ \JAz8?s>$i|4!data_structures/heap/skew_heap.pyew^ ew^ \xS{O˰'0ş`'data_structures/linked_list/__init__.pyew^ ew^ \c|,!:+Fh(c??L3data_structures/linked_list/circular_linked_list.pyexQ9aexQ9a\ɮ=zSKU|-+data_structures/linked_list/deque_doubly.pyeu Seu S\>6r)1data_structures/linked_list/doubly_linked_list.pyeu Seu S\Kifj^{'ힿ ;5data_structures/linked_list/doubly_linked_list_two.pyeZWaeZWa\vДOd4%uȷ,data_structures/linked_list/from_sequence.pyew^ ew^ \p@^~'Ȫnd e|'data_structures/linked_list/has_loop.pyeu Seu S\1|'+tvX[36,data_structures/linked_list/is_palindrome.pyew^ ew^ \kRAtiYZ.data_structures/linked_list/merge_two_lists.pyew^ ew^ \\L˻ ]uomb<data_structures/linked_list/middle_element_of_linked_list.pyew^ ew^ \ o"r`yB(9 Kb,data_structures/linked_list/print_reverse.pyewWewW\,Z! So|T01data_structures/linked_list/singly_linked_list.pyew^ ew^ \1-=R[8tӝtM(data_structures/linked_list/skip_list.pyeq$$eq$$\&?WVGP!l `d)data_structures/linked_list/swap_nodes.pyeZWaeZWa\⛲CK)wZS!data_structures/queue/__init__.pyeZWaeZWa\ \|)bj~",0'data_structures/queue/circular_queue.pyew Kew K\;|y^O<~YW+data_structures/queue/double_ended_queue.pyew Kew K\ ޅ&1SSIr~%data_structures/queue/linked_queue.pyeu Seu S\A&C?4C'/߉-y2data_structures/queue/priority_queue_using_list.pyeu Seu S\H\{rI:ԛaC-&data_structures/queue/queue_on_list.pyeu Seu S\!%f3?w .data_structures/queue/queue_on_pseudo_stack.pyeZWaeZWa\⛲CK)wZS"data_structures/stacks/__init__.pyew Kew K\#gO~6PD}.data_structures/stacks/balanced_parentheses.pyew Kew K\ >Fh99薙UД37data_structures/stacks/dijkstras_two_stack_algorithm.pyexQ9aexQ9a\2ؠ<; ^2O4data_structures/stacks/evaluate_postfix_notations.pyew Kew K\ۨGȦd% KAƙ5data_structures/stacks/infix_to_postfix_conversion.pyeu Seu S\ &ܞ>s*L{I4data_structures/stacks/infix_to_prefix_conversion.pyexQ9aexQ9a\>@-|7y@7U&data_structures/stacks/linked_stack.pyeu}eu}\} -1{~Ĝ*f~fͳ.data_structures/stacks/next_greater_element.pyeu Seu S\-WJCW1!xQ$,data_structures/stacks/postfix_evaluation.pyer, er, \d,crmJNj)Bt4+data_structures/stacks/prefix_evaluation.pyexQ9aexQ9a\ 8е/`O/data_structures/stacks/stack.pyew Kew K\ u d WM13)data_structures/stacks/stack_using_dll.pyeu Seu S\80*l!CXI< :z,data_structures/stacks/stock_span_problem.pyeZ``eZ``\⛲CK)wZS data_structures/trie/__init__.pyew Kew K\* e$ LQ"kϧdata_structures/trie/trie.pyeZ``eZ``\⛲CK)wZS$digital_image_processing/__init__.pyeZ``eZ``\I?9nF!Pc=-digital_image_processing/change_brightness.pyer`8er`8\Gj$nYN὿z+digital_image_processing/change_contrast.pyeZ``eZ``\}A8<(ʬ)-(E3/digital_image_processing/convert_to_negative.pyeZ``eZ``\⛲CK)wZS.digital_image_processing/dithering/__init__.pyeqSeqS\: +2% ~¹@||y}w,digital_image_processing/dithering/burkes.pyeZ``eZ``\⛲CK)wZS3digital_image_processing/edge_detection/__init__.pyeu Seu S\<Z)[M\ Rי0digital_image_processing/edge_detection/canny.pyeZ``eZ``\⛲CK)wZS,digital_image_processing/filters/__init__.pyeu Seu S\@ ;vMEO cg4digital_image_processing/filters/bilateral_filter.pyeqK9OeqK9O\c) <cHfV ,digital_image_processing/filters/convolve.pyeZ``eZ``\އge<q=={_־3digital_image_processing/filters/gaussian_filter.pyeZ``eZ``\@VbfmepӶbgy1digital_image_processing/filters/median_filter.pyeZ``eZ``\3(J2$t䈷y[0digital_image_processing/filters/sobel_filter.pyeZ``eZ``\⛲CK)wZS;digital_image_processing/histogram_equalization/__init__.pyeu Seu S\SfӨI;p!0Ddigital_image_processing/histogram_equalization/histogram_stretch.pyeZ``eZ``\⛲CK)wZSFdigital_image_processing/histogram_equalization/image_data/__init__.pyeZ``eZ``\H=F$YP)wDdigital_image_processing/histogram_equalization/image_data/input.jpgeZ``eZ``\⛲CK)wZSGdigital_image_processing/histogram_equalization/output_data/__init__.pyeZ``eZ``\οH } W7OUcFdigital_image_processing/histogram_equalization/output_data/output.jpgeZ``eZ``\⛲CK)wZS/digital_image_processing/image_data/__init__.pyeZ``eZ``\vN孝JSxs,digital_image_processing/image_data/lena.jpgeZ``eZ``\;QD\yœ$2-2digital_image_processing/image_data/lena_small.jpgeu$eu$\LCP`3?1E=|I-digital_image_processing/index_calculation.pyeZ``eZ``\⛲CK)wZS+digital_image_processing/resize/__init__.pyeZ``eZ``\H6RX?GPt)digital_image_processing/resize/resize.pyeZ``eZ``\⛲CK)wZS-digital_image_processing/rotation/__init__.pyexQ9aexQ9a\f)Q :qp҉r-digital_image_processing/rotation/rotation.pyexQ9aexQ9a\?ߵv^w+%4.|!digital_image_processing/sepia.pyeu"&jeu"&j\' @;mqLZ3`:9digital_image_processing/test_digital_image_processing.pyeZ``eZ``\⛲CK)wZSdivide_and_conquer/__init__.pyeZ``eZ``\ y{$"1 ,divide_and_conquer/closest_pair_of_points.pyew^ ew^ \Z? ogKr6'Į`!divide_and_conquer/convex_hull.pyeZ``eZ``\0fAlNsk<#%divide_and_conquer/heaps_algorithm.pyeZ``eZ``\LMA96!=:-/divide_and_conquer/heaps_algorithm_iterative.pyew^ ew^ \)V"!.!] divide_and_conquer/inversions.pyew^ ew^ \0kg 3j)divide_and_conquer/kth_order_statistic.pyexQ9aexQ9a\Cv174? (+̽6d)divide_and_conquer/max_difference_pair.pyeu Seu S\CxӒ-Ûbu6'&divide_and_conquer/max_subarray_sum.pyew^ ew^ \ FiAʳ|jc )R @divide_and_conquer/mergesort.pyew^ ew^ \O?Ň4a Fdivide_and_conquer/peak.pyeZ``eZ``\#6$g_ԭ tw'divide_and_conquer/power.pyexQ9aexQ9a\Iz)tx2QY3GL4divide_and_conquer/strassen_matrix_multiplication.pyeZ``eZ``\⛲CK)wZSdynamic_programming/__init__.pyeZ``eZ``\Qu/ ھz.~#dynamic_programming/abbreviation.pyeu Seu S\s $)[^筤|Bdynamic_programming/bitmask.pyeu Seu S\[WѾgJr)nHm&dynamic_programming/climbing_stairs.pyeu Seu S\ V~ P;ib$^]$dynamic_programming/edit_distance.pyeZ``eZ``\IZw´]PMD dynamic_programming/factorial.pyeZ``eZ``\`􁆣L%0J^FRNy%dynamic_programming/fast_fibonacci.pyev4ev4\Gʱ5ޡ'1L dynamic_programming/fibonacci.pyeu Seu S\tƨ%h58*1 ?%dynamic_programming/floyd_warshall.pyeu Seu S\ FJŎOh$>Dz*dynamic_programming/fractional_knapsack.pyewd ewd \ w81.= y/eU,dynamic_programming/fractional_knapsack_2.pyewd ewd \1%NcH΄`I>*?(dynamic_programming/integer_partition.pyer, er, \!MNU_2M:C31dynamic_programming/iterating_through_submasks.pyerPqerPq\ 4uO܄T՚s/7dynamic_programming/k_means_clustering_tensorflow.py_tfewd ewd \QiLNyubn udynamic_programming/knapsack.pyeu Seu S\3xjCRQBԽ l1dynamic_programming/longest_common_subsequence.pyewd ewd \ʊ+\܃VޮقI5dynamic_programming/longest_increasing_subsequence.pyeu Seu S\ESoȡ'XMX">dynamic_programming/longest_increasing_subsequence_o(nlogn).pyeu Seu S\ V.0ˏ^Υ}fg-(dynamic_programming/longest_sub_array.pyeu Seu S\֔pO1/[ 4s)dynamic_programming/matrix_chain_order.pyeu Seu S\vSb,]w,l)8+dynamic_programming/max_non_adjacent_sum.pyeu Seu S\ x R0`Ɲݮ L/PS$dynamic_programming/max_sub_array.pyeqeq\ Œ7 ]uY/ oSI5dynamic_programming/max_sum_contiguous_subsequence.pyeu Seu S\D(i{1d`D%*dynamic_programming/minimum_coin_change.pyeZ``eZ``\:KU(-4LN#JC(dynamic_programming/minimum_cost_path.pyeu eu \4N/ ةeXc(dynamic_programming/minimum_partition.pyeqSeqS\=-p3 C[H+dynamic_programming/minimum_steps_to_one.pyeu eu \" 9fgD Xp!1dynamic_programming/optimal_binary_search_tree.pyeuQg#euQg#\RD*9NV2 N"dynamic_programming/rod_cutting.pyeu eu \BG;2x+a(dynamic_programming/subset_generation.pyeu eu \e!w|t*t8: t$dynamic_programming/sum_of_subset.pyexQ9aexQ9a\Lv=\r2ò =+9>electronics/electric_power.pyexQ9aexQ9a\0@{cSU#Belectronics/ohms_law.pyeZ)i_eZ)i_\ ⛲CK)wZSfile_transfer/__init__.pyeZ)i_eZ)i_\ CTϧfǃ2ptF,."hnfile_transfer/mytext.txtexQ9aexQ9a\NϺn؄>1bB)5qfile_transfer/receive_file.pyexQ9aexQ9a\O[SGP<Ghם<file_transfer/send_file.pyeZ)i_eZ)i_\ $⛲CK)wZSfile_transfer/tests/__init__.pyeZ)i_eZ)i_\ %*`Dbownl9[gI;%file_transfer/tests/test_send_file.pyeZ)i_eZ)i_\ 5⛲CK)wZSfuzzy_logic/__init__.pyev4ev4\ W?c>jj(_fuzzy_logic/fuzzy_operations.pyeZ)i_eZ)i_\ 9⛲CK)wZSgenetic_algorithm/__init__.pyeu eu \DႼJ% <JP!genetic_algorithm/basic_string.pyeZ)i_eZ)i_\ <⛲CK)wZSgeodesy/__init__.pyeu eu \ _ފ8t S)*geodesy/haversine_distance.pyeu eu \ Pީ1E0*(geodesy/lamberts_ellipsoidal_distance.pyeZ)i_eZ)i_\ B⛲CK)wZSgraphics/__init__.pyeu$eu$\k~+dO#cjA/graphics/bezier_curve.pyexQ9aexQ9a\rX[A;PKF' Ygraphics/koch_snowflake.pyexQ9aexQ9a\'y[oEˌZSHUgraphics/mandelbrot.pyeqSeqS\ ߢ"b225N$graphics/vector3_for_2d_rendering.pyeZ)i_eZ)i_\ F⛲CK)wZSgraphs/__init__.pyew:vew:v\6 [/zcV9 ޮgraphs/a_star.pyeu eu \&q6k'熤=G4pgraphs/articulation_points.pyew:vew:v\7s{*wV\B\dJ1ygraphs/basic_graphs.pyew:vew:v\F^VGg@'#l1graphs/bellman_ford.pyew:vew:v\m EuKS~V o&㱓hgraphs/bfs_shortest_path.pyew:vew:v\%a'Bi ߚE$graphs/bfs_zero_one_shortest_path.pyew:vew:v\ rO_:#=sWyC[graphs/bidirectional_a_star.pyew:vew:v\m9}A[MO,graphs/bidirectional_breadth_first_search.pyew:vew:v\^ U - ? Xnmgraphs/breadth_first_search.pyevev\w$:@CqUza!+ graphs/breadth_first_search_2.pyew:vew:v\P 4yeIa,graphs/breadth_first_search_shortest_path.pyevev\ dqd]pܔXtAUD#graphs/check_bipartite_graph_bfs.pyeq$$eq$$\ bdB0DN {pz#graphs/check_bipartite_graph_dfs.pyer, er, \ J=tƄ !!h[љgraphs/connected_components.pyew:vew:v\s|rSe=O$`mgraphs/depth_first_search.pyeo`hA.eo`hA.\E0r'vbSsښ~ɤL:graphs/depth_first_search_2.pyeu eu \ _˿ҒcHH|Vϐgraphs/dijkstra.pyeu eu \v(nJP0F܆?D)_Egraphs/dijkstra_2.pyeu eu \kdJ́vnEz`#@graphs/dijkstra_algorithm.pyeZ)i_eZ)i_\ ` R\ڏfLHBKgraphs/dinic.pyeu eu \o>\ ƼbL!"2graphs/directed_and_undirected_(weighted)_graph.pyeu eu \/5񮣣/4cosg/graphs/edmonds_karp_multiple_source_and_sink.pyewd ewd \xP;KQrxQuK8graphs/eulerian_path_and_circuit_for_undirected_graph.pyew:vew:v\ɮp p1L8W>graphs/even_tree.pyeu}eu}\eU{ž~8F^pgraphs/finding_bridges.pyew'Bew'B\ pc"g17D4JEsY?&graphs/frequent_pattern_graph_miner.pyeZ)i_eZ)i_\ gwT=QnLXngraphs/g_topological_sort.pyew:vew:v\^Y)nm2xl8zgraphs/gale_shapley_bigraph.pyew:vew:v\u3։:>e#DUgraphs/graph_list.pyer, er, \ qhBk[,PU_graphs/graph_matrix.pyeZ)i_eZ)i_\ l Vϋ8+5Igraphs/graphs_floyd_warshall.pyew:vew:v\K=?ENW<LHqdUgraphs/greedy_best_first.pyeu eu \ &Qz!EY_4.graphs/kahns_algorithm_long.pyeu eu \ 3)aG|',ʃgraphs/kahns_algorithm_topo.pyer, er, \ 2 !(Mؠnvgraphs/karger.pyeu eu \ +2T.lcpk1֏uZ'graphs/minimum_spanning_tree_boruvka.pyew:vew:v\qA`R?V=}I'graphs/minimum_spanning_tree_kruskal.pyew:vew:v\ ߸~7dkϛQ@{4Bet(graphs/minimum_spanning_tree_kruskal2.pyeu eu \T(a@'_J3P%S%graphs/minimum_spanning_tree_prims.pyew:vew:v\#Ysl€d$&graphs/minimum_spanning_tree_prims2.pyew:vew:v\!VwW`j<graphs/multi_heuristic_astar.pyew^ ew^ \]Q)mF ɺWh\graphs/page_rank.pyeuL feuL f\ p2?p?<{Ҍgraphs/prim.pyew:vew:v\ 0W<c cj͆obބgraphs/scc_kosaraju.pyew:vew:v\  i b[f<gSP@['graphs/strongly_connected_components.pyeqK9߬OeqK9߬O\  \0ʊ OPym}x]}graphs/tarjans_scc.pyew:vew:v\ :Rz8O[Of:).graphs/tests/test_min_spanning_tree_kruskal.pyeu eu \eY_ozA~$Ms+graphs/tests/test_min_spanning_tree_prim.pyeZ)i_eZ)i_\ ⛲CK)wZShashes/__init__.pyexQ9aexQ9a\G ]|̆hashes/adler32.pyexQ9aexQ9a\ cߘKhb(ا XUhashes/chaos_machine.pyeu eu \ Kg-7"y*Ƕhashes/djb2.pyexQ9aexQ9a\T  CsWShashes/enigma_machine.pyeu$eu$\ M$J2 ]jS)5thashes/hamming_code.pyexQ9aexQ9a\=2QUSaP3 hashes/md5.pyexQ9aexQ9a\>zgi(f[.&Fhashes/sdbm.pyew:vew:v\if̣|?bq4%qd*Ehashes/sha1.pyew Kew K\L`A䎸 HpYknapsack/README.mdeZ)i_eZ)i_\ ⛲CK)wZSknapsack/__init__.pyeZ)i_eZ)i_\ c@[k◒knapsack/greedy_knapsack.pyew^ ew^ \ ^udCacX؎G$jo+knapsack/knapsack.pyeZ)i_eZ)i_\ ⛲CK)wZSknapsack/tests/__init__.pyepEepE\~ +-]@݋xWi&knapsack/tests/test_greedy_knapsack.pyepEepE\5$USq}S2s%knapsack/tests/test_knapsack.pyew Kew K\h ^` @sJtlinear_algebra/README.mdeZ)i_eZ)i_\ ⛲CK)wZSlinear_algebra/__init__.pyeZ)i_eZ)i_\ ⛲CK)wZSlinear_algebra/src/__init__.pyexQ9aexQ9a\|Yeh(>(linear_algebra/src/conjugate_gradient.pyexQ9aexQ9a\- 5<4 ;ɰ7iiIn;ֶlinear_algebra/src/lib.pyexQ9aexQ9a\z67#҅ tϴ (linear_algebra/src/polynom_for_points.pyexQ9aexQ9a\ AGca3!4%׮#C%linear_algebra/src/power_iteration.pyexQ9aexQ9a\i Hp1 'linear_algebra/src/rayleigh_quotient.pyexQ9aexQ9a\wn:8eC9`d3)linear_algebra/src/test_linear_algebra.pyexQ9aexQ9a\ cjVv: pR(linear_algebra/src/transformations_2d.pyeZfr_eZfr_\ ⛲CK)wZSmachine_learning/__init__.pyeu eu \ \g?$䔟üN)TƲmachine_learning/astar.pyeu eu \ ! t~W+Ƈlᢚ΍>(machine_learning/data_transformations.pyeu eu \zCܱD*R!machine_learning/decision_tree.pyeZfr_eZfr_\ ⛲CK)wZS(machine_learning/forecasting/__init__.pyeqZ3eqZ3\ BdUXY?V~(machine_learning/forecasting/ex_data.csvexQ9aexQ9a\X_ûOR cJ#machine_learning/forecasting/run.pyeu eu \ ,ZM-ęGXt_s(machine_learning/gaussian_naive_bayes.pyeuL feuL f\   |ihC/machine_learning/gradient_boosting_regressor.pyer, er, \ u `ub$o$machine_learning/gradient_descent.pyexQ9aexQ9a\2kUԄ_A?t(=i7 !machine_learning/k_means_clust.pyexQ9aexQ9a\sX-5ə.7Ul8(machine_learning/k_nearest_neighbours.pyeq$$eq$$\ dJbBDϭc\FKEmachine_learning/knn_sklearn.pyexQ9aexQ9a\BV psѸ"qG1x0machine_learning/linear_discriminant_analysis.pyexQ9aexQ9a\!&b6q| i$kyE%machine_learning/linear_regression.pyeu eu \ e H؎蔼Ls'machine_learning/logistic_regression.pyeZfr_eZfr_\ ⛲CK)wZS!machine_learning/lstm/__init__.pyexQ9aexQ9a\ TRD?b`niYJ ]+machine_learning/lstm/lstm_prediction.py_tfeZfr_eZfr_\ M!p2u-)%machine_learning/lstm/sample_data.csveu eu \ o`AwȈl>1Ɂ4machine_learning/multilayer_perceptron_classifier.pyer`8er`8\ 7L5o7>OP)machine_learning/polymonial_regression.pyeu eu \ |cp%@2z/ǔϦ7y,machine_learning/random_forest_classifier.pyeu eu \  &8(@E+machine_learning/random_forest_regressor.pyeZfr_eZfr_\  Fi\;!.n҂3 %machine_learning/scoring_functions.pyeu$eu$\jQglRۧV89j3machine_learning/sequential_minimum_optimization.pyew^ ew^ \X\ JEбG%machine_learning/similarity_search.pyeuL feuL f\ ]H:ʽd&+machine_learning/support_vector_machines.pyexQ9aexQ9a\ƾ *G2wLw},machine_learning/word_frequency_functions.pyeses\ > UX4,0maths/3n_plus_1.pyeZfr_eZfr_\ ⛲CK)wZSmaths/__init__.pyeu eu \hɚQ،u0p/ maths/abs.pyew^ ew^ \!WKsx^Tmaths/abs_max.pyew^ ew^ \I7#Q$޷[z~maths/abs_min.pyeu eu \  ږӓ6(U maths/add.pyeZfr_eZfr_\ ~XaўR &2(maths/aliquot_sum.pyeZfr_eZfr_\ MKlW>f[maths/allocation_number.pyewWewW\($݆#̚r:`3c maths/area.pyew^ ew^ \ L-;Cg+m5maths/area_under_curve.pyexQ9aexQ9a\ 00$|<kD%maths/armstrong_numbers.pyew:vew:v\ UKA]w-4rA4maths/average_mean.pyew:vew:v\ WEWoVHF&Rmaths/average_median.pyexQ9aexQ9a\NrԿg3U?ڑmaths/average_mode.pyexQ9aexQ9a\ 1+~U&o15ڌ9maths/bailey_borwein_plouffe.pyew:vew:v\;=Qr1P$Lmaths/basic_maths.pyer, er, \ groG^dsI maths/binary_exp_mod.pyer, er, \ iXREDN#@Ͳ3nmaths/binary_exponentiation.pyeu eu \ |M+#ws%amaths/binomial_coefficient.pyeu$eu$\ yJZ~ٔV!6X%B1=>maths/binomial_distribution.pyeu eu \ "GNFPꪰOi|maths/bisection.pyeu eu \ ~ޗWes6wn! ` maths/ceil.pyeZfr_eZfr_\ tb./?k )E6]maths/chudnovsky_algorithm.pyeqeq\  {66i "e.VLImaths/collatz_sequence.pyeu eu \@P)v0koFmaths/combinations.pyeu eu \ 9ggÛB[:maths/decimal_isolate.pyew^ ew^ \ hC8`ϱOMBbjjmaths/entropy.pyew^ ew^ \ Dn 7Ktl -GO5lmaths/euclidean_distance.pyerckerck\j5 'zQ w'maths/eulers_totient.pyexQ9aexQ9a\ C|x`+i7smaths/explicit_euler.pyew^ ew^ \ mv6 KT^ڱ%maths/extended_euclidean_algorithm.pyew Kew K\kd1G t-ؓmaths/factorial_iterative.pyew Kew K\ EFhaVw}yi21b&maths/factorial_python.pyer, er, \ 0qs5eL"E2maths/factorial_recursive.pyeu eu \ :Na~a7Vmaths/factors.pyer-; er-; \ 1s>( hBڼmaths/fermat_little_theorem.pyev4ev4\&Q5@%z ?maths/fibonacci.pyev4ev4\ OyK:+ &T'%maths/fibonacci_sequence_recursion.pyew^ ew^ \,M~E&>ӌr!maths/find_max.pyew^ ew^ \. f"Y_,'Fmaths/find_max_recursion.pyew^ ew^ \9*KSc?8/}maths/find_min.pyew^ ew^ \KD|zw0D^m`UJmaths/find_min_recursion.pyeu eu \ H"P垗"܌{Omaths/floor.pyer-; er-; \ Bípx'  ؄maths/gamma.pyeu$eu$\ Bۥ }}k ph6maths/gaussian.pyeZfr_eZfr_\ ܢJJIv쐎*5 maths/greatest_common_divisor.pyew^ ew^ \ <p}A;lLmaths/hardy_ramanujanalgo.pyeZfr_eZfr_\ ⛲CK)wZSmaths/images/__init__.pyeZfr_eZfr_\ !|~!)lM0Ϣmaths/images/gaussian.pngeu eu \ f_gi6ǒmaths/is_square_free.pyeu eu \  =O$@PM &mgmaths/jaccard_similarity.pyeu eu \ T9ԢXE?ԿE; maths/kadanes.pyeu$eu$\)z\K): F{ maths/karatsuba.pyeu eu \ \-ȏh'э1+ɶ{Aemaths/krishnamurthy_number.pyeu eu \ =#&H¡C0{`&maths/kth_lexicographic_permutation.pyer-; er-; \  &NƊ|/y"&maths/largest_of_very_large_numbers.pyer-; er-; \+ _ vCiKٮ4Tpmaths/least_common_multiple.pyew^ ew^ \ p8kD /&maths/line_length.pyeu eu \ \]YͼV$maths/lucas_lehmer_primality_test.pyeu eu \ 4k2.D+3ߤ maths/lucas_series.pyeu eu \  <?(Q͕#ÃZmaths/matrix_exponentiation.pyew Kew K\ ' =2OۑRtmaths/miller_rabin.pyer`8er`8\ O5Y[QЬ<maths/mobius_function.pyeZ{^eZ{^\ ;mB}:$/D6whmaths/modular_exponential.pyeu$eu$\ (|Ax=>l`Yy%maths/monte_carlo.pyexQ9aexQ9a\:ǿD7Ț'Imaths/monte_carlo_dice.pyer-; er-; \  ˗f> 8Ar+Wmaths/newton_raphson.pyes^es^\ 9<?`NC/4:x/maths/number_of_digits.pyew^ ew^ \ tJv@\Y֧{Ȟmaths/numerical_integration.pyeo WYeo WY\ 4҇uq maths/perfect_cube.pyeo`hA.eo`hA.\ Q2ғmhjFDmaths/perfect_number.pyeu$eu$\ Ct xV,чqmaths/perfect_square.pyeu$eu$\  mZv9"maths/pi_monte_carlo_estimation.pyexQ9aexQ9a\))r<^ Dmaths/polynomial_evaluation.pyeo`hA.eo`hA.\  Щi<e^0Umaths/power_using_recursion.pyew Kew K\;⼷Q"]8]Gmaths/prime_check.pyeZ{^eZ{^\ ^\ :mG=,;jmaths/prime_factors.pyew Kew K\H8Ala(k maths/prime_numbers.pyeu eu \E`!@N6W!maths/prime_sieve_eratosthenes.pyerckerck\ iw11ܫb]maths/pythagoras.pyeu eu \ _^O*Omݾ2Ymaths/qr_decomposition.pyeit.Seit.S\5NÐad/* TY,maths/quadratic_equations_complex_numbers.pyeq%!#eq%!#\ JTFTgJ,Wmaths/radians.pyewd ewd \ !އT@iR͇q;2maths/radix2_fft.pyeq%!#eq%!#\ =EkÑnU&j|u maths/relu.pyeu eu \ s87ڥ |xg㾻Emaths/runge_kutta.pyeu$eu$\ X`Iz>8_`lΧjmaths/segmented_sieve.pyeZ{^eZ{^\ k⛲CK)wZSmaths/series/__init__.pyewWewW\\Kc?hd*5^maths/series/arithmetic_mean.pyewWewW\nPTet!##@maths/series/geometric_mean.pyeu}eu}\#Ė "혴fn܀ maths/series/geometric_series.pyew'Bew'B\ 呵E7fUu,[Pǃmaths/series/harmonic_series.pyeu}eu}\ Zv-+cvumaths/series/p_series.pyew^ ew^ \ vGTiɣw@˨}maths/sieve_of_eratosthenes.pyeqRr+eqRr+\ (uqA~Tmaths/sigmoid.pyepEepE\ q@mÚqqV\ː=pmaths/simpson_rule.pyeu eu \ !MQ䳕4~wmaths/softmax.pyeu eu \ t$#|$#5-4maths/square_root.pyeu eu \ t+oW9S=b!maths/sum_of_arithmetic_series.pyeu eu \:dcLh?5| :maths/sum_of_digits.pyeu$eu$\ \$h4%maths/sum_of_geometric_progression.pyeu eu \ 8b4vs,@zmaths/test_prime_check.pyeZ{^eZ{^\  M܊ka1 !maths/trapezoidal_rule.pyeu eu \ v~DQڭB :鰦7maths/ugly_numbers.pyew^ ew^ \[ A3>VMv=/˄Bߺomaths/volume.pyeu eu \ 6-J"}yevdmaths/zellers_congruence.pyeZ{^eZ{^\ ⛲CK)wZSmatrix/__init__.pyeu eu \ ggu^|aO!matrix/count_islands_in_matrix.pyeu eu \ : dK\>hߧ]Fmatrix/inverse_of_matrix.pyeu eu \ >*WEѫDW{NIߨmatrix/matrix_class.pyeu}eu}\ܠ1M?~Xnmatrix/matrix_operation.pyewn/!/Xewn/!/X\  L9#mHt+ԋ{3matrix/nth_fibonacci_using_matrix_exponentiation.pyeu eu \q g8Yz]=r[jNmatrix/rotate_matrix.pyew^ ew^ \ zbc/P)16$matrix/searching_in_sorted_matrix.pyeuL feuL f\ 4fԠ-( i*matrix/sherman_morrison.pyewn/!/Xewn/!/X\ ?!ڷaV?ɘ ``fmatrix/spiral_print.pyeZ{^eZ{^\ ⛲CK)wZSmatrix/tests/__init__.pyeZ{^eZ{^\ <V-_ѹQާlmatrix/tests/pytest.iniepEepE\xe_?VµX%matrix/tests/test_matrix_operation.pyeZ{^eZ{^\ ⛲CK)wZSnetworking_flow/__init__.pyeu eu \ 㖷dtj[ !Cdc(SI!networking_flow/ford_fulkerson.pyeu ͙eu ͙\ ן6 9jîWcVnnetworking_flow/minimum_cut.pyexQ9aexQ9a\-1bK.^u|;0neural_network/2_hidden_layers_neural_network.pyeZ{^eZ{^\ ⛲CK)wZSneural_network/__init__.pyeu ͙eu ͙\ {C{,DiQ1neural_network/back_propagation_neural_network.pyeuL feuL f\7!H%e69Ln1,neural_network/convolution_neural_network.pyeq%!#eq%!#\ >ްbčǑut +>U e&neural_network/gan.py_tferPqerPq\ Z/" ͥ=<pj̖neural_network/input_data.py_tfexQ9aexQ9a\ ^# 'z J'kԒneural_network/perceptron.pyeZ]eZ]\ ⛲CK)wZSother/__init__.pyew Kew K\9VҾP'v[9other/activity_selection.pyexQ9aexQ9a\ Q` ռGNa}Dother/anagrams.pyexQ9aexQ9a\ YK"6sxeUbϡdA other/autocomplete_using_trie.pyexQ9aexQ9a\ ZNpA)Ԓ25h^ӻother/binary_exponentiation.pyexQ9aexQ9a\ aQK% ]e[8 other/binary_exponentiation_2.pyew^ ew^ \ ,xmݘ(lS|Q-other/davis–putnam–logemann–loveland.pyexQ9aexQ9a\ rDqkdӺTH_E+other/detecting_english_programmatically.pyexQ9aexQ9a\ s<u9v*@dSڪother/dictionary.txteo WYeo WY\ !{κ]zd6"fNVB#other/dijkstra_bankers_algorithm.pyeZ]eZ]\ !&V_ %h$other/doomsday.pyexQ9aexQ9a\ K%C~po~2M_Gtother/euclidean_gcd.pyewn/!/Xewn/!/X\ nsxMp\&^other/fischer_yates_shuffle.pyexQ9aexQ9a\  VHv ]]1Tother/frequency_finder.pyexQ9aexQ9a\  9:TF\14!~other/game_of_life.pyeZ]eZ]\ DGԫg 'o%05other/gauss_easter.pyew Kew K\Rg͊MM"other/graham_scan.pyeu ͙eu ͙\ KxN^1A]2other/greedy.pyexQ9aexQ9a\ yD 'uZL'other/integeration_by_simpson_approx.pyexQ9aexQ9a\ I.d3Nʾgother/largest_subarray_sum.pyexQ9aexQ9a\w!39cdi.K=rψOother/least_recently_used.pyew^ ew^ \ )-@&BdPYo$K!:AP!/gother/lfu_cache.pyewd ewd \ =V-1Hco &other/linear_congruential_generator.pyew^ ew^ \ O*~IyiX䊊other/lru_cache.pyeu ͙eu ͙\ qPӷrBYrk`eother/magicdiamondpattern.pyexQ9aexQ9a\ <@҈d{8 Z)y=6pother/markov_chain.pyexQ9aexQ9a\ K׆ 2other/max_sum_sliding_window.pyexQ9aexQ9a\ /]~;h%bkother/median_of_two_arrays.pyeu ͙eu ͙\ 󣇗Q&;zmyother/nested_brackets.pyexQ9aexQ9a\ ya,y Xכother/palindrome.pyexQ9aexQ9a\ [5Mxj- t[5<qother/password_generator.pyexQ9aexQ9a\ 87=prӎother/primelib.pyevev\ \wb,Ҡ? w롳other/scoring_algorithm.pyeu ͙eu ͙\  :ť=P)?tS/ other/sdes.pyexQ9aexQ9a\ "As΍ ߏ:other/sierpinski_triangle.pyeu ͙eu ͙\ < 6m,Z09Zother/tower_of_hanoi.pyexQ9aexQ9a\ $ xRrX7{96:fother/triplet_sum.pyexQ9aexQ9a\ %#Lgҭjsyother/two_pointer.pyexQ9aexQ9a\ &>R ~D/jۚ&Foother/two_sum.pyexQ9aexQ9a\ ')M>'O\gother/word_patterns.pyexQ6K`exQ6K`\ *& KWcd:}˫v0 other/wordsew Kew K\8.۳k(:project_euler/README.mdeZ]eZ]\ ⛲CK)wZSproject_euler/__init__.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_001/__init__.pyew^ ew^ \ 2)L2fr?T8!project_euler/problem_001/sol1.pyeZ]eZ]\ SpQ3xX(U{يE!project_euler/problem_001/sol2.pyeZ]eZ]\ gAU:Qz]};=h1!project_euler/problem_001/sol3.pyeZ]eZ]\ d<O$2-/5g!project_euler/problem_001/sol4.pyew^ ew^ \  Ѽ|{voT6!project_euler/problem_001/sol5.pyeZ]eZ]\ Gq7oi!project_euler/problem_001/sol6.pyeu ͙eu ͙\ ͏]w+v!project_euler/problem_001/sol7.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_002/__init__.pyeZ]eZ]\ Shk ʆí 8!project_euler/problem_002/sol1.pyeZ]eZ]\ Ґ3Цɰjjn4%!project_euler/problem_002/sol2.pyeZ]eZ]\ :uzL! kd!project_euler/problem_002/sol3.pyeZ]eZ]\ !p֨ &Qqpn<]E!project_euler/problem_002/sol4.pyeZ]eZ]\ "D9ў8Y`4"3bg_r!project_euler/problem_002/sol5.pyeZ]eZ]\ $⛲CK)wZS%project_euler/problem_003/__init__.pyew^ ew^ \y 4A(w޳YD J)!project_euler/problem_003/sol1.pyeZ]eZ]\ & JFz5,o!project_euler/problem_003/sol2.pyew^ ew^ \{o/aʊr!F[n Ѝ!project_euler/problem_003/sol3.pyeZ]eZ]\ )⛲CK)wZS%project_euler/problem_004/__init__.pyeu ͙eu ͙\ ka3JɧYcԖ!project_euler/problem_004/sol1.pyeZ]eZ]\ +ȀmX|@Ϻg=0!project_euler/problem_004/sol2.pyeZ]eZ]\ -⛲CK)wZS%project_euler/problem_005/__init__.pyer-; er-; \ crһ|{U9϶UZbm!project_euler/problem_005/sol1.pyeu"&jeu"&j\ ȀDH} ~T(Dr!project_euler/problem_005/sol2.pyeZ]eZ]\ 1⛲CK)wZS%project_euler/problem_006/__init__.pyeu$eu$\ R1az2ûcЈʛ_n!project_euler/problem_006/sol1.pyeZ]eZ]\ 3m{Hqja`!project_euler/problem_006/sol2.pyew^ ew^ \ -y10tg/)+&a\.!project_euler/problem_006/sol3.pyeZ]eZ]\ 5tVnKtSOf!project_euler/problem_006/sol4.pyeZ]eZ]\ 7⛲CK)wZS%project_euler/problem_007/__init__.pyeu"&jeu"&j\ 9xQ7&|;!project_euler/problem_007/sol1.pyew^ ew^ \}1f- p Bz@!project_euler/problem_007/sol2.pyeu$eu$\ 7y>oz0ɑOΒ5!project_euler/problem_007/sol3.pyeZ]eZ]\ <⛲CK)wZS%project_euler/problem_008/__init__.pyeu ͙eu ͙\  dy`wxD 辖Nsku!project_euler/problem_008/sol1.pyew^ ew^ \ fH\&~#\}z'S!project_euler/problem_008/sol2.pyeu ͙eu ͙\  PKnvRlVi7!project_euler/problem_008/sol3.pyeZ]eZ]\ A⛲CK)wZS%project_euler/problem_009/__init__.pyew^ ew^ \C ?O!project_euler/problem_009/sol1.pyeZ]eZ]\ Ckr*"E6!project_euler/problem_009/sol2.pyev4ev4\ Էa쒈=jx!project_euler/problem_009/sol3.pyeZ]eZ]\ F⛲CK)wZS%project_euler/problem_010/__init__.pyeu}eu}\ PIIR<v?a Ykkt!project_euler/problem_010/sol1.pyeuL oeuL o\ :/H]P&wX_>{M!project_euler/problem_010/sol2.pyeu$eu$\ }wǯ WP hL!project_euler/problem_010/sol3.pyeZ]eZ]\ K⛲CK)wZS%project_euler/problem_011/__init__.pyeZ]eZ]\ LJE>)1QNFh:"project_euler/problem_011/grid.txteu ͙eu ͙\ 2 ޝs#}$/d=!project_euler/problem_011/sol1.pyeu ͙eu ͙\ < quq2%Մ'=o !project_euler/problem_011/sol2.pyeZ]eZ]\ P⛲CK)wZS%project_euler/problem_012/__init__.pyev4ev4\ c~ NEޫy/P!project_euler/problem_012/sol1.pyew^ ew^ \ {_4IK_> !project_euler/problem_012/sol2.pyeZ]eZ]\ T⛲CK)wZS%project_euler/problem_013/__init__.pyeZ]eZ]\ UChm 1kS-S!project_euler/problem_013/num.txtew^ ew^ \ .wB^,#/m!project_euler/problem_013/sol1.pyeZ]eZ]\ X⛲CK)wZS%project_euler/problem_014/__init__.pyew^ ew^ \EZ i ,{C!project_euler/problem_014/sol1.pyew^ ew^ \p 2t G@ڌ@q~!project_euler/problem_014/sol2.pyeZ]eZ]\ \⛲CK)wZS%project_euler/problem_015/__init__.pyew Kew K\y& ŢfIm,!project_euler/problem_015/sol1.pyeZ]eZ]\ _⛲CK)wZS%project_euler/problem_016/__init__.pyeu$eu$\ b b H/r(R3="!project_euler/problem_016/sol1.pyeu$eu$\ h90M'Ym0ݴ%>!project_euler/problem_016/sol2.pyeZ]eZ]\ c⛲CK)wZS%project_euler/problem_017/__init__.pyeZ]eZ]\ diZNZǁR@^7a!project_euler/problem_017/sol1.pyeZ]eZ]\ f⛲CK)wZS%project_euler/problem_018/__init__.pyer-; er-; \ |<oK>,U6%project_euler/problem_018/solution.pyeZ]eZ]\ hh6~Є.}yX&project_euler/problem_018/triangle.txteZ]eZ]\ j⛲CK)wZS%project_euler/problem_019/__init__.pyer-; er-; \ "Y6XCBb1"o!project_euler/problem_019/sol1.pyeZ]eZ]\ m⛲CK)wZS%project_euler/problem_020/__init__.pyeZ]eZ]\ nǴrNT<yhdyr2!project_euler/problem_020/sol1.pyew^ ew^ \ $G(ΗG%t+w!project_euler/problem_020/sol2.pyeZ]eZ]\ pKO(_4,!project_euler/problem_020/sol3.pyeZ]eZ]\ q;, ߦ> e`{s!project_euler/problem_020/sol4.pyeZ]eZ]\ s⛲CK)wZS%project_euler/problem_021/__init__.pyew^ ew^ \  ?ynA墶%,l%ww6:!project_euler/problem_021/sol1.pyeZ]eZ]\ v⛲CK)wZS%project_euler/problem_022/__init__.pyeZ]eZ]\ wo{lL.4㭇s(project_euler/problem_022/p022_names.txteZ]eZ]\ x)$^t0p]z;lh!project_euler/problem_022/sol1.pyeZ]eZ]\ yZhn,k_HT3ـ!project_euler/problem_022/sol2.pyeZ]eZ]\ {⛲CK)wZS%project_euler/problem_023/__init__.pyeu$eu$\ Nh+a#/}B !project_euler/problem_023/sol1.pyeZ]eZ]\ ~⛲CK)wZS%project_euler/problem_024/__init__.pyeZ]eZ]\ cx`Y9X*!project_euler/problem_024/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_025/__init__.pyer%]er%]\  t<K&#5!project_euler/problem_025/sol1.pyew^ ew^ \ ;T5mS3n!project_euler/problem_025/sol2.pyeu ͙eu ͙\ OdUJϠK{!project_euler/problem_025/sol3.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_026/__init__.pyew^ ew^ \drN>ZBYF!project_euler/problem_026/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_027/__init__.pyeu$eu$\ .o(%r?,")!project_euler/problem_027/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_028/__init__.pyeu$eu$\ rka 9Y|"bo!project_euler/problem_028/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_029/__init__.pyeu$eu$\ UrkNDh9μV!project_euler/problem_029/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_030/__init__.pyeu"&jeu"&j\ /'eqg6>x 7!project_euler/problem_030/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_031/__init__.pyeZ]eZ]\ @81u).y+!project_euler/problem_031/sol1.pyeZ]eZ]\ 8KtʵYDtDZc!project_euler/problem_031/sol2.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_032/__init__.pyeu ͙eu ͙\ W!9237.u[#'u"project_euler/problem_032/sol32.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_033/__init__.pyew^ ew^ \ nU=]LsL!project_euler/problem_033/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_034/__init__.pyew^ ew^ \xmԾHRk"!project_euler/problem_034/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_035/__init__.pyeq%!#eq%!#\ H?g;i &!project_euler/problem_035/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_036/__init__.pyew^ ew^ \ I._>0m !project_euler/problem_036/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_037/__init__.pyew^ ew^ \ TT#| =c>(!project_euler/problem_037/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_038/__init__.pyew^ ew^ \  LmT.X]g=DFT!project_euler/problem_038/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_039/__init__.pyeZ]eZ]\ AYHhtoa!project_euler/problem_039/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_040/__init__.pyeZ]eZ]\ ji7w#N2RPc!project_euler/problem_040/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_041/__init__.pyeu"&jeu"&j\ S!%*!rVKBC!project_euler/problem_041/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_042/__init__.pyeu ͙eu ͙\ ~LDsyyY{d'project_euler/problem_042/solution42.pyeZ]eZ]\ ?گ:BQ ͗t#project_euler/problem_042/words.txteZ]eZ]\ y-`H,oRbQ%project_euler/problem_043/__init__.pyeu}eu}\ [Xz -]!project_euler/problem_043/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_044/__init__.pyew^ ew^ \Ӯdv_M P6xN+!project_euler/problem_044/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_045/__init__.pyev4ev4\ 0s9%qVCnl!project_euler/problem_045/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_046/__init__.pyew^ ew^ \ ?VuQ6͡[2+Ş!project_euler/problem_046/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_047/__init__.pyeZ]eZ]\  8r .|=v7!project_euler/problem_047/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_048/__init__.pyeu$eu$\ zp-c#5Ī\$8գ!project_euler/problem_048/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_049/__init__.pyew^ ew^ \ q[ {Tb%*̎!project_euler/problem_049/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_050/__init__.pyew^ ew^ \ }._+$jI J!project_euler/problem_050/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_051/__init__.pyew^ ew^ \ & `ԅMS)!project_euler/problem_051/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_052/__init__.pyeu ͙eu ͙\ 5"\F{]ZF RyR!project_euler/problem_052/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_053/__init__.pyeZ]eZ]\ 7&Y]zAӻX!project_euler/problem_053/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_054/__init__.pyeZ]eZ]\ u0Had׷)project_euler/problem_054/poker_hands.txtew^ ew^ \ 5 i<ct!project_euler/problem_054/sol1.pyeu ͙eu ͙\ 13lMh/,project_euler/problem_054/test_poker_hand.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_055/__init__.pyeZ]eZ]\  iT:iQ۶ZEu!project_euler/problem_055/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_056/__init__.pyew^ ew^ \ %nU3B Sw/!project_euler/problem_056/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_057/__init__.pyeZ]eZ]\ GX'o'!project_euler/problem_057/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_058/__init__.pyew Kew K\ӱQW &ْ5ڨ!project_euler/problem_058/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_059/__init__.pyeZ]eZ]\ ޳$rR,iYo)project_euler/problem_059/p059_cipher.txtew^ ew^ \ +U&gջ}%4^!project_euler/problem_059/sol1.pyeZ]eZ]\ `'7@t9j/ g\Yʸ!)project_euler/problem_059/test_cipher.txteZ]eZ]\ ⛲CK)wZS%project_euler/problem_062/__init__.pyeu$eu$\ 8V(lCp^!project_euler/problem_062/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_063/__init__.pyeu$eu$\ )ݺB%jM ?w!project_euler/problem_063/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_064/__init__.pyeu$eu$\ "iu$sȽ,0@n.!project_euler/problem_064/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_065/__init__.pyeu ͙eu ͙\ ` "i}Z UH9V!project_euler/problem_065/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_067/__init__.pyeuQ#euQ#\ Zy۫8v.(,f!project_euler/problem_067/sol1.pyeZ]eZ]\ ;.+8-NJYuKZu+&project_euler/problem_067/triangle.txteZ]eZ]\ ⛲CK)wZS%project_euler/problem_069/__init__.pyeu$eu$\ Hyw[iGH5E!project_euler/problem_069/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_070/__init__.pyew^ ew^ \  u'\ÁL1;Hj%!project_euler/problem_070/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_071/__init__.pyeZ]eZ]\  A[~St ]UJ8sk[!project_euler/problem_071/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_072/__init__.pyev4ev4\ c2e~!project_euler/problem_072/sol1.pyeZ]eZ]\ ,:SP0PO~!project_euler/problem_072/sol2.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_074/__init__.pyexQ6K`exQ6K`\ w ^joRo4ẳ<H7!project_euler/problem_074/sol1.pyew^ ew^ \ ' h'z)Moyett}!project_euler/problem_074/sol2.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_075/__init__.pyerckerck\ vjJB 銷!X,,!project_euler/problem_075/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_076/__init__.pyeZ]eZ]\ Q`~ajXel !project_euler/problem_076/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_077/__init__.pyew^ ew^ \ ) N]x!project_euler/problem_077/sol1.pyeZ]eZ]\ +⛲CK)wZS%project_euler/problem_080/__init__.pyew^ ew^ \ (*iEۊxN)F̼!project_euler/problem_080/sol1.pyeZ]eZ]\ .⛲CK)wZS%project_euler/problem_081/__init__.pyeZ]eZ]\ /zIS"A6IƳ4'˜$project_euler/problem_081/matrix.txtew^ ew^ \ 쯡C;3+e= !project_euler/problem_081/sol1.pyeZZ\eZZ\\ 7⛲CK)wZS%project_euler/problem_085/__init__.pyew^ ew^ \ tk4]/!project_euler/problem_085/sol1.pyeZZ\eZZ\\ :⛲CK)wZS%project_euler/problem_086/__init__.pyeu$eu$\  nkZ1Yֲ4+u!project_euler/problem_086/sol1.pyeZZ\eZZ\\ =⛲CK)wZS%project_euler/problem_087/__init__.pyeZZ\eZZ\\ >DH'&u!project_euler/problem_087/sol1.pyeZZ\eZZ\\ @y-`H,oRbQ%project_euler/problem_089/__init__.pyeZZ\eZZ\\ A!B̩-΀⡺K}1project_euler/problem_089/numeralcleanup_test.txteZZ\eZZ\\ B&yPe5Z[h;=kDL>(project_euler/problem_089/p089_roman.txtew^ ew^ \  X*WYw[M%!project_euler/problem_089/sol1.pyeZZ\eZZ\\ E⛲CK)wZS%project_euler/problem_091/__init__.pyeZZ\eZZ\\ Fllp"ELTm26s!project_euler/problem_091/sol1.pyeZZ\eZZ\\ Ny-`H,oRbQ%project_euler/problem_097/__init__.pyeu$eu$\ . @y=%[!;2!project_euler/problem_097/sol1.pyeZZ\eZZ\\ Q⛲CK)wZS%project_euler/problem_099/__init__.pyeZZ\eZZ\\ R6=";&q \ބ &project_euler/problem_099/base_exp.txtew^ ew^ \ -舑.rb=m <Y!project_euler/problem_099/sol1.pyeZZ\eZZ\\ X⛲CK)wZS%project_euler/problem_101/__init__.pyew^ ew^ \ . c |Յ͒MzD!project_euler/problem_101/sol1.pyeZZ\eZZ\\ [⛲CK)wZS%project_euler/problem_102/__init__.pyeZZ\eZZ\\ \g?Ay,@Dr,project_euler/problem_102/p102_triangles.txtew^ ew^ \  QrfVΏwHֈ 7h6!project_euler/problem_102/sol1.pyeZZ\eZZ\\ ^7\e ,project_euler/problem_102/test_triangles.txteZZ\eZZ\\ c⛲CK)wZS%project_euler/problem_107/__init__.pyeZZ\eZZ\\ d6+hꋐ:f^X*project_euler/problem_107/p107_network.txtew^ ew^ \ IvPm/%!project_euler/problem_107/sol1.pyeZZ\eZZ\\ fzW ʺd**b})*project_euler/problem_107/test_network.txtenfJenfJ\ ⛲CK)wZS%project_euler/problem_109/__init__.pyeu ͙eu ͙\  1ꟙ,L2!project_euler/problem_109/sol1.pyeZZ\eZZ\\ k⛲CK)wZS%project_euler/problem_112/__init__.pyew^ ew^ \ 3L iBXsWUL!project_euler/problem_112/sol1.pyeZZ\eZZ\\ n⛲CK)wZS%project_euler/problem_113/__init__.pyeu ͙eu ͙\ gPI:)#UT!project_euler/problem_113/sol1.pyeZZ\eZZ\\ }⛲CK)wZS%project_euler/problem_119/__init__.pyew^ ew^ \ 4:B_x?+Thn!project_euler/problem_119/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_120/__init__.pyeZZ\eZZ\\ :h!!E`qU?dS8!project_euler/problem_120/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_123/__init__.pyew^ ew^ \ 5 IAO}BeiV!project_euler/problem_123/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_125/__init__.pyeu$eu$\  S[g}g%MCw!project_euler/problem_125/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_129/__init__.pyeZZ\eZZ\\ .:'-iLB!project_euler/problem_129/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_135/__init__.pyeq%!#eq%!#\ 9Ehi)q!project_euler/problem_135/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_173/__init__.pyeu$eu$\ 9C~?cr})!project_euler/problem_173/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_174/__init__.pyeZZ\eZZ\\ %ZekPO^7i2r !project_euler/problem_174/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_180/__init__.pyew^ ew^ \ }a.p(O#<ş@P!project_euler/problem_180/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_188/__init__.pyew^ ew^ \ / ds6 S=c!!project_euler/problem_188/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_191/__init__.pyew^ ew^ \ 3 y82[6;ˆɣ94H!project_euler/problem_191/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_203/__init__.pyew^ ew^ \"{Gm1Q e?_rIT!project_euler/problem_203/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_206/__init__.pyeZZ\eZZ\\ +2wp9e!project_euler/problem_206/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_207/__init__.pyew^ ew^ \ @ $TyP&`K!project_euler/problem_207/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_234/__init__.pyeu$eu$\  ud-%$'bQI-!project_euler/problem_234/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_301/__init__.pyeu$eu$\ -4@Fȳ])-u!project_euler/problem_301/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_551/__init__.pyew^ ew^ \ Gqfm9~1!project_euler/problem_551/sol1.pyeu ͙eu ͙\ xHy'0[@Un^ pytest.inieu ͙eu ͙\ uB=43d&<=ll quantum/README.mdeZZ\eZZ\\ ⛲CK)wZSquantum/__init__.pyeu$eu$\ N0Nn0׽i<ZcRquantum/deutsch_jozsa.pyeu ͙eu ͙\  J@Ki:7}}I1quantum/half_adder.pyeu ͙eu ͙\ Yx! YjLE?quantum/not_gate.pyeu ͙eu ͙\ x='q6"P^|[M<Xquantum/quantum_entanglement.pyexQ6K`exQ6K`\  ]emfV^iûquantum/ripple_adder_classic.pyeu ͙eu ͙\ 4!yU()[2~R uquantum/single_qubit_measure.pyexQ6K`exQ6K`\#4FVqxFrequirements.txteZZ\eZZ\\ ⛲CK)wZSscheduling/__init__.pyew^ ew^ \  9U(_'ʹЕ%scheduling/first_come_first_served.pyew^ ew^ \ Jy0e!3scheduling/round_robin.pyew^ ew^ \ t}j#Y O| scheduling/shortest_job_first.pyeZZ\eZZ\\ ⛲CK)wZSscripts/__init__.pyeuL oeuL o\ HzKäX4CDŁd}bscripts/build_directory_md.pyexQ6K`exQ6K`\ ,CWDj^׷Z7"scripts/project_euler_answers.jsonexQ6K`exQ6K`\ "_Agv3j`$Tscripts/validate_filenames.pyexQ6K`exQ6K`\ S N1|r?7cscripts/validate_solutions.pyeZ[eZ[\ ⛲CK)wZSsearches/__init__.pyew^ ew^ \#5<,0I!3EAcQVsearches/binary_search.pyeZ[eZ[\ hƅnEE_5^ searches/double_linear_search.pyeZ[eZ[\ H>L I(ۂ*searches/double_linear_search_recursion.pyew^ ew^ \  ̙JDeEmsearches/fibonacci_search.pyexQ6K`exQ6K`\ pb.N~.T>&oהu8searches/hill_climbing.pyeu ͙eu ͙\ /ߕeEx" } searches/interpolation_search.pyeqe'eqe'\ 1elUñ=y}tsearches/jump_search.pyeq{*Meq{*M\  YwpN6zkWq searches/linear_search.pyeZ[eZ[\ ^ތMj~ lsearches/quick_select.pyeZ[eZ[\ iϟ5\V6%ݚy-<"searches/sentinel_linear_search.pyeu ͙eu ͙\ C5FCJ<] searches/simple_binary_search.pyeu}eu}\ n*wHl}B-5searches/simulated_annealing.pyeu ͙eu ͙\ J*D$=$k! searches/tabu_search.pyeZ[eZ[\ FbzEv;searches/tabu_test_data.txtew^ ]ew^ ]\ qI"̹fp`_b?~searches/ternary_search.pyeZ[eZ[\ ⛲CK)wZSsorts/__init__.pyew^ ]ew^ ]\ 7gB#@sorts/bead_sort.pyew^ ]ew^ ]\  >^SHu$6sorts/bitonic_sort.pyer-; er-; \ a/ rh nNڤsorts/bogo_sort.pyeu ͙eu ͙\ *\|}p[j2sorts/bubble_sort.pyew^ ]ew^ ]\ gtߩFzWsorts/bucket_sort.pyeo WYeo WY\.81h*Ϙ ;+?#ͼsorts/cocktail_shaker_sort.pyer-; er-; \ ;ǏOHl ]sorts/comb_sort.pyer-; er-; \ ܉.D-̝Ŗ(ȅ|sorts/counting_sort.pyeqK9߬OeqK9߬O\ ߀o@Dy+`c} RMsorts/cycle_sort.pyewWewW\ ᆂ|~|1sorts/double_sort.pyeuQ#euQ#\ g'z O 'v*lsorts/external_sort.pyeZ[eZ[\ l&bdKT%jsorts/gnome_sort.pyeZ[eZ[\ Mʇ؜!1_@$M:FLbgRsorts/heap_sort.pyeqK9߬OeqK9߬O\ m[`ә,#>0bJ Bsorts/insertion_sort.pyeo WYeo WY\ IdZ۷|UCsorts/intro_sort.pyeuL oeuL o\ B^ڹFCҩpsorts/iterative_merge_sort.pyeu$eu$\ sqJ<\-]sorts/merge_insertion_sort.pyeu ͙eu ͙\ TM2ms6oz)Tsorts/merge_sort.pyeZ[eZ[\ [ACHW)sorts/natural_sort.pyeu$eu$\ *wi|zL-'sorts/normal_distribution_quick_sort.mdeu ͙eu ͙\ ]Us7w.CWTsorts/odd_even_sort.pyeu ͙eu ͙\ K](A{mK#s (sorts/odd_even_transposition_parallel.pyew^ ]ew^ ]\ =xE9) T3/sorts/odd_even_transposition_single_threaded.pyeZ[eZ[\ Ds5;r@~&@>)Ksorts/pancake_sort.pyew^ ]ew^ ]\ Igy5xsorts/patience_sort.pyew^ ]ew^ ]\ =d8eaY+Gsorts/pigeon_sort.pyeZ[eZ[\ #PEL _S]0sorts/pigeonhole_sort.pyew^ ]ew^ ]\ oQ,MۂiĚsorts/quick_sort.pyeZ[eZ[\ % (md"L2 sorts/quick_sort_3_partition.pyew^ ]ew^ ]\ E' [yeVsorts/radix_sort.pyeu ͙eu ͙\ sp@U\p+t-sorts/random_normal_distribution_quicksort.pyeu ͙eu ͙\ N/*w!s  sorts/random_pivot_quick_sort.pyeo`hA.eo`hA.\ 1Y>[n4}98> K'sorts/recursive_bubble_sort.pyew^ ]ew^ ]\ 7Jw{%;!sorts/recursive_insertion_sort.pyer-; er-; \ Š~s~ZGJV /sorts/recursive_quick_sort.pyeq%!#eq%!#\ Lpp "EVp,yVsorts/selection_sort.pyeq%!#eq%!#\ p)Ѽ w`'bsorts/shell_sort.pyew^ ]ew^ ]\ SUNPN~Fbsorts/slowsort.pyer-; er-; \ [ޙzv<u2zs>j8sorts/stooge_sort.pyes^es^\ \5i?/sorts/strand_sort.pyer-; er-; \ R_L1~ 7W&xJsorts/tim_sort.pyew^ ]ew^ ]\ N/|w3H]{sorts/topological_sort.pyeu ͙eu ͙\ kEE f!Dg`D3sorts/tree_sort.pyeZ[eZ[\ 3D/zX+,?d}sorts/unknown_sort.pyeZ[eZ[\ 4<`oV>]暗sorts/wiggle_sort.pyeZ[eZ[\ 6⛲CK)wZSstrings/__init__.pyewsDewsD\ ƹYՌ2My?LeBustrings/aho_corasick.pyew^ ]ew^ ]\  aN11F;9strings/boyer_moore_search.pyew} ew} \Ň~&4TmL1strings/can_string_be_rearranged_as_palindrome.pyeqeq\ Mc`:~-s9d{͠ʂstrings/capitalize.pyew Kew K\M0 ]H֠+ Sbstrings/check_anagrams.pyexQ6K`exQ6K`\ xi[$B4Sstrings/check_pangram.pyeu ͙eu ͙\ Gv)5ȾQestrings/is_palindrome.pyeZZeZZ\ SM:׾8(Z>strings/jaro_winkler.pyew^ ]ew^ ]\ I7`AlG#ög~strings/knuth_morris_pratt.pyew} ew} \ T !=K}mvstrings/levenshtein_distance.pyexQ6K`exQ6K`\ s}o vmstrings/lower.pyewsDewsD\ Tvh9?XxH;qastrings/manacher.pyewsDewsD\ 鐪gAkS'aW%strings/min_cost_string_conversion.pyew:vew:v\ P&A!ցsV_/vstrings/naive_string_search.pyew^ ]ew^ ]\ RXm@?[$Q¤C7strings/prefix_function.pyeqK9߬OeqK9߬O\  ,av =4?'strings/rabin_karp.pyeZZeZZ\ `Z'Ro g=Me=SMstrings/remove_duplicate.pyeq%!#eq%!#\ \*|%[\W/Ustrings/reverse_letters.pyeZZeZZ\ bVPL \a~Gstrings/reverse_words.pyeZZeZZ\ db+@25Ep$3t:strings/split.pyew^ ]ew^ ]\ KRUgpvM= strings/swap_case.pyepNepN\ V^@`ަwbstrings/upper.pyew} ew} \ Ka.ߤCt摨sstrings/word_occurrence.pyeu$eu$\  #~H s櫛SLxLstrings/z_function.pyexQ6K`exQ6K`\ ,⛲CK)wZStraversals/__init__.pyexQ6K`exQ6K`\ -#4GbIWb9m $traversals/binary_tree_traversals.pyeZXeZX\ r⛲CK)wZSweb_programming/__init__.pyeZXeZX\ s̗~~Ag^ RVweb_programming/co2_emission.pyexQ6K`exQ6K`\ 0+.(v hs(web_programming/covid_stats_via_xpath.pyeu ͙eu ͙\ :?;\~A(S@/b-'web_programming/crawl_google_results.pyeu ͙eu ͙\ ##8 d0n9|0web_programming/crawl_google_scholar_citation.pyexQ6K`exQ6K`\ /j*Ux^{gG{v%web_programming/currency_converter.pyeqZ3eqZ3\ DNQٔ]v!n'٧&web_programming/current_stock_price.pyeu ͙eu ͙\ )C8G?1"n'}H"web_programming/current_weather.pyeZXeZX\ zY$NpI* ӕ_Z"web_programming/daily_horoscope.pyexQ6K`exQ6K`\  St#j@CWQh3,"web_programming/emails_from_url.pyeZXeZX\ ~,{i2ޡJU߷>!web_programming/fetch_bbc_news.pyew^ ]ew^ ]\ `k0 gr $web_programming/fetch_github_info.pyeuL oeuL o\ l!quoȃsweb_programming/fetch_jobs.pyeZXeZX\ KnV)Mw5b .web_programming/get_imdb_top_250_movies_csv.pyewWewW\ _fKfkweb_programming/get_imdbtop.pyer-; er-; \ )E6%zN~01¥~ $web_programming/instagram_crawler.pyeo WYeo WY\ !gM}fi(y(! web_programming/instagram_pic.pyeZXeZX\ /$<PQ=1z-/x"web_programming/instagram_video.pyeZXeZX\  /G/*-`{~lZ B)web_programming/recaptcha_verification.pyeqeq\ ZX~ޗxa3 web_programming/slack_message.pyeZXeZX\ [-|x-T}wY)web_programming/test_fetch_github_info.pyeq3eq3\ m8 '`&^?&web_programming/world_covid19_stats.pyTREEs971 40 Ӄ)/>ɲE'|maths106 2 ,b\ة x$7images2 0 )|A(U!series6 0 VpN`c,wother41 0 gYBy`o.1?{ĈSZsorts46 0 w4\IcB$p cagraphs49 1 }Pm4U*=Uİ|QǾtests2 0 H1SUw0IPhashes9 0 w'l-S^ 2ބmatrix13 1 $\]Vz$*Zdݐtests3 0 t&G+צY*.github7 1 Mr߾m#25workflows4 0 rfs ů72Dc9ciphers40 0 `@pjVğ}2Pvgeodesy3 0 `YgZcL0=2;Equantum8 0 JsH_pzv7Fscripts5 0 #GDq€C)strings25 0 *Κ{lo graphics5 0 S-w1p<w:9knapsack7 1 O6DǴVtests3 0 -v>g 0searches16 0 h7Jl.%aU=blockchain4 0 8ze[|\[gUscheduling4 0 M`cW!@A}ϞEtraversals2 0 1ʺф@iZcompression13 1 lqegP(1image_data7 0 broe\x-.`r`conversions15 0 x]T d5+Belectronics2 0 /xâ$‹U#fuzzy_logic2 0 ß05+7bI|backtracking13 0 LLrufile_transfer6 1 @RHD=Û9hsjNktests2 0 ָ)0<kཫproject_euler266 104 f Z_4n nproblem_0018 0 L @%z A8problem_0026 0 K'3Ϋ:U(])fproblem_0034 0 S=7s%~(Pُqproblem_0043 0 IXk7P͸|problem_0053 0 btձ1G&Tqoproblem_0065 0 +"Q(HΗY,`problem_0074 0 pK]Խ85MV)Zproblem_0084 0 Ap׫EDå problem_0094 0 &-QKD^problem_0104 0 WL<CZq<:]problem_0114 0 ~nJproblem_0123 0 1Dw">d_[.hproblem_0133 0 Gyh/Q<e`Wproblem_0143 0 8a3eHproblem_0152 0 ;QYX;Q[lrR׫problem_0163 0 WSm*problem_0172 0 y=,y)шOt" Hbproblem_0183 0 %M}3z!$~problem_0192 0 >̯W d@ٸt7problem_0205 0 kV<"tQ;Ul&problem_0212 0 ֍5TUEL;3{problem_0224 0 sK[媘M problem_0232 0 G /$K_c+xZ problem_0242 0 t S'Kj"1Rȥ problem_0254 0 k+=ւvproblem_0262 0 xd ^+4~Cproblem_0272 0 *QQ%&iqproblem_0282 0 I#+2=1c<problem_0292 0 %*՜4<oproblem_0302 0 :syJU05tproblem_0313 0 cʸ"@+%problem_0322 0 sjce6^YDk%Y aproblem_0332 0 [ŋ$ڇmGv$Iqproblem_0342 0 Rݝ}]!s fproblem_0352 0 hr.A%3C"{problem_0362 0 <,sybN>Cproblem_0372 0 qeyeEVproblem_0382 0 5l?o&>_problem_0392 0 -} -/ny]problem_0402 0 P *uСXA?(problem_0412 0 φ/e37problem_0423 0 SfUghG+eproblem_0432 0 $"Rmr딠URproblem_0442 0 PޣR(V-ngproblem_0452 0 IEzd4EȻ0\problem_0462 0 #|~8iz^mproblem_0472 0 L ifJ%Q@{Eproblem_0482 0 %ThW +Wwproblem_0492 0 9OIi[䟐-rŇp98problem_0502 0 E[.CF)ORtoproblem_0512 0 ȀC!yɀ@ýproblem_0522 0 چ E_uproblem_0532 0 \vET-" E^problem_0544 0 pGk]0·#ݫzU96problem_0552 0 Ggmd~GGw,B_problem_0562 0 jS[``[mdproblem_0572 0 | K^κV-problem_0582 0 곋)cw= nWproblem_0594 0 (Kz`J&^(lproblem_0622 0 K !|o^ucCrxproblem_0632 0 >cgD̲ Apnproblem_0642 0 #EYR)problem_0652 0 Bd8 Q9problem_0673 0 'IWfK Reproblem_0692 0 1`e problem_0702 0 |>(TsLproblem_0712 0 h."y۾Nf;awproblem_0723 0 vnۢ=SQsI?problem_0743 0 kORO$+37problem_0752 0 a2p[$sproblem_0762 0 v= txZْqproblem_0772 0 7t 4J2problem_0802 0 w k]7G*;/1/problem_0813 0 !N_;#[>O$problem_0852 0 ̥\ҡ)>*O problem_0862 0 "i]rRproblem_0872 0 WRg\:3iproblem_0894 0 JPih5 problem_0912 0 h3c=6}LӞbproblem_0972 0 U_t{ږI6problem_0993 0 SxI>Um\,ZSnproblem_1012 0 jki^ՅGS%problem_1024 0 (zUU2vv] problem_1074 0 ]T.bX;(I&problem_1092 0 (?G w<*e<!problem_1122 0 tt@:ELUh problem_1132 0 TQAZW7㛨problem_1192 0 ? NR ^>vproblem_1202 0 2)X')0c6problem_1232 0 m#T@r֤V+fproblem_1252 0 :0pᝀB8ߨmSzproblem_1292 0 f//]@V76problem_1352 0 {\By/Iproblem_1732 0 :ԣmF:}Yproblem_1742 0 z0Y$A۾RtV8problem_1802 0 ,raxx Aproblem_1882 0 @ ڱ0Vz|":%2problem_1912 0 :ӂtwhG .,Fproblem_2032 0 U:GxuԍUb:ߡo{problem_2062 0 m* ptP[problem_2072 0 h7)8CT/3$~problem_2342 0 y\F} [qAZV problem_3012 0 #(Tͺ)}e,|aproblem_5512 0 ZfhIkzQ2Ay8tlinear_algebra10 1  K'}9Gsrc8 0 껰Q߱:w&E]^%neural_network7 0 6?#4Lf,boolean_algebra2 0 (uG{` ?rcomputer_vision4 0 :jfb$O4data_structures72 8 @Q u~7%UBheap8 0 (I,Tj Utrie2 0 kvvL%^>aM1queue7 0 Z@[t|^U{WOstacks13 0 9K2{Rחhashing7 1 ̸o`$m,2number_theory2 0 cأ/<ӥbinary_tree17 0 &ߣJ>3D,llinked_list14 0 Jyl̬M˻q disjoint_set3 0 :s#j[networking_flow3 0 6ѫ. g8{a?!web_programming22 0 )ncQz+N@ivbit_manipulation12 0 ET*h8 f64!Umachine_learning28 2 rH$k"`ʿ]lstm3 0 ]xc0T29nforecasting3 0 j(-l^[EQecellular_automata4 0 UşPY2G[dgenetic_algorithm2 0 cukd*{^va/divide_and_conquer13 0 .*8vSq_ܠarithmetic_analysis13 1 KDƳE^I<mimage_data3 0 'PZbwұ-_dynamic_programming31 0 fS "O9d۪digital_image_processing30 7 n 7nTWɧ&rlYresize2 0 -$?T =JQJifilters6 0 Aď'@ ߗOrotation2 0 l}avw=tdithering2 0 LHl(vKpŒ9image_data3 0 Lu(X,aӕm=edge_detection2 0 wfp8ب8:ޓ<histogram_equalization6 2 =a7Ȥtk.'Uimage_data2 0 ‰דM>+V\output_data2 0 yMmA~Eiѯb8t
DIRCeu Seu S\R(!+NG #ʸ .coveragerceZ3deZ3d\G jERrgk k#.gitattributeseu Seu S\IG& LL1o쟓o .github/CODEOWNERSevev\K>|(o\ITH3)v .github/pull_request_template.mder`8er`8\P 6V&k&g:d5 +.github/stale.ymlexQ0bexQ0b\EBъގ{!.github/workflows/build.ymleuL feuL f\SOT&@Pe3,[w$&.github/workflows/directory_writer.ymlexQ0bexQ0b\YY\Υܲ͜mu+ .github/workflows/pre-commit.ymleuL feuL f\TgR8e~ا~U#.github/workflows/project_euler.ymleu"&jeu"&j\VWL1(6+a"h}~ .gitignoreeZ3deZ3d\W4Yu郍nO8 E .gitpod.ymlexQ0bexQ0b\5(^ﱴ m Ђ.pre-commit-config.yamlexQ0bexQ0b\D)A^͘ Bn$*[CONTRIBUTING.mdexQ0bexQ0b\F;m߶sި)OKa">%.vR DIRECTORY.mdeuIeuI\]4…| ) LICENSE.mdexQ0bexQ0b\Nj1>TU*Rئ qF README.mdeo Peo P\⛲CK)wZSarithmetic_analysis/__init__.pyeuIeuI\\yg4;5_i : arithmetic_analysis/bisection.pyexQ0bexQ0b\c [Q v*4ٕQ'J+arithmetic_analysis/gaussian_elimination.pyeo Peo P\倈ddûr^7 .arithmetic_analysis/image_data/2D_problems.jpgeo Peo P\ jE6  =PC20arithmetic_analysis/image_data/2D_problems_1.jpgeo Peo P\ ⛲CK)wZS*arithmetic_analysis/image_data/__init__.pyexQ0bexQ0b\ 2(P= :-7d`/H,arithmetic_analysis/in_static_equilibrium.pyeu$eu$\e Mة5Do[;1#arithmetic_analysis/intersection.pyew9mew9m\7ѷM4()'arithmetic_analysis/lu_decomposition.pyew^ ew^ \f<O,[Cg_SD:3arithmetic_analysis/newton_forward_interpolation.pyeu$eu$\ᩩCrgpB Ñ$arithmetic_analysis/newton_method.pyew^ ew^ \skZߍI%L}6%arithmetic_analysis/newton_raphson.pyew9mew9m\D~ݏ\ka: $arithmetic_analysis/secant_method.pyeZ3deZ3d\i⛲CK)wZSbacktracking/__init__.pyew^ ew^ \jvF(75PUTu % backtracking/all_combinations.pyew^ ew^ \k,\z[gDp; backtracking/all_permutations.pyew^ ew^ \lNeڠ0P:_' backtracking/all_subsequences.pyew^ ew^ \m 9Vz㙡 rw`backtracking/coloring.pyew^ ew^ \q{5 |-"\c4>J!backtracking/hamiltonian_cycle.pyew^ ew^ \r if}x94g =<Qbacktracking/knight_tour.pyew^ ew^ \tIݢGDQ-F backtracking/minimax.pyew^ ew^ \u .);Ijbacktracking/n_queens.pyew^ ew^ \vBe\6.s YBbacktracking/n_queens_math.pyew^ ew^ \x *AڨO"Nbbacktracking/rat_in_maze.pyew9mew9m\y;o)O9.r<`}lbacktracking/sudoku.pyew^ ew^ \z%oĵzu3sbacktracking/sum_of_subsets.pyewWewW\`.f$⦃Й6bit_manipulation/README.mdeZ<ceZ<c\~⛲CK)wZSbit_manipulation/__init__.pyewWewW\bD0Q]5m 'bit_manipulation/binary_and_operator.pyeZ<ceZ<c\V<iE3M f~-1t(bit_manipulation/binary_count_setbits.pyeZ<ceZ<c\īfD9BHƊ/bit_manipulation/binary_count_trailing_zeros.pyewWewW\ڿ[ ]n+b<&bit_manipulation/binary_or_operator.pyexQ0bexQ0b\ |bX3 H.+!bit_manipulation/binary_shifts.pyenf/enf/\&a,NB׌ޓXGd*bit_manipulation/binary_twos_complement.pyewWewW\ob*pOÃ'bit_manipulation/binary_xor_operator.pyeu Seu S\Q+cQu9]I,bit_manipulation/count_number_of_one_bits.pyeqSeqS\ U`)H7:Z}^ bit_manipulation/reverse_bits.pyexQ0bexQ0b\@(f7h&EcT4Y6bit_manipulation/single_bit_manipulation_operations.pyeZ<ceZ<c\⛲CK)wZSblockchain/__init__.pyew^ ew^ \)ߵGNyi)¿a'blockchain/chinese_remainder_theorem.pyew^ ew^ \ }t8ErC(\I"blockchain/diophantine_equation.pyew^ ew^ \H iOP*бTo1WaFƎblockchain/modular_division.pyeZ<ceZ<c\⛲CK)wZSboolean_algebra/__init__.pyew^ ew^ \{pZpr#g]S Q4#boolean_algebra/quine_mc_cluskey.pyeu8ieu8i\ݴ'!81cellular_automata/README.mdeZ<ceZ<c\⛲CK)wZScellular_automata/__init__.pyexQ0bexQ0b\ 4z?"<{dk8)cellular_automata/conways_game_of_life.pyexQ0bexQ0b\ P]ŹB\WfLJ$cellular_automata/one_dimensional.pyeZ<ceZ<c\⛲CK)wZSciphers/__init__.pyexQ0bexQ0b\JqKP/w^ɶEciphers/a1z26.pyexQ0bexQ0b\M ό _LC3;Cfͮ,ciphers/affine_cipher.pyexQ0bexQ0b\D}4zR%epM ciphers/atbash.pyew Kew K\_!~bT=p>WC<ciphers/base16.pyexQ0bexQ0b\W[Mօ#rb Sciphers/base32.pyew Kew K\cJs<^" k)_ciphers/base64_encoding.pyexQ0bexQ0b\W3ZV>E'Uciphers/base85.pyexQ0bexQ0b\ȅ@t ASo>ciphers/beaufort_cipher.pyexQ0bexQ0b\re$TkQ K$ciphers/brute_force_caesar_cipher.pyew^ ew^ \K/vsņX_\kciphers/caesar_cipher.pyexQ0bexQ0b\tads袔<5ɣciphers/cryptomath_module.pyexQ0bexQ0b\a"A+S 2#-JF *ciphers/decrypt_caesar_with_chi_squared.pyeu$eu$\X~lXS' n-%ciphers/deterministic_miller_rabin.pyexQ0bexQ0b\D+F` ciphers/diffie.pyexQ0bexQ0b\L15{H>a}2%пciphers/diffie_hellman.pyexQ0bexQ0b\RiAcңi? ciphers/elgamal_key_generator.pyexQ0bexQ0b\!`CDVxOaAFUciphers/enigma_machine2.pyexQ0bexQ0b\7]- "iA,a31ciphers/hill_cipher.pyexQ0bexQ0b\/Y)1 c򅧻Fciphers/mixed_keyword_cypher.pyexQ0bexQ0b\ )D(ղc{"ciphers/mono_alphabetic_ciphers.pyexQ0bexQ0b\K.(2j?ffv$ciphers/morse_code_implementation.pyexQ0bexQ0b\Q+M1B憝fX,ciphers/onepad_cipher.pyexQ0bexQ0b\ !7DSB9%oɃs&ciphers/playfair_cipher.pyexQ0bexQ0b\L)<L|~_ۂciphers/porta_cipher.pyeq$$eq$$\n$RS:5}aciphers/prehistoric_men.txteu$eu$\ ebN^}[ciphers/rabin_miller.pyexQ0bexQ0b\ 8%ARj9K⳾jciphers/rail_fence_cipher.pyexQ0bexQ0b\A!ژ̨B79(ciphers/rot13.pyexQ0bexQ0b\ }n3av;]iciphers/rsa_cipher.pyexQ0bexQ0b\`-39z&yciphers/rsa_factorization.pyexQ0bexQ0b\+VPrPVKMo4rciphers/rsa_key_generator.pyexQ0bexQ0b\"b<P6=粐M ciphers/shuffled_shift_cipher.pyexQ0bexQ0b\ q>s]i Xph ciphers/simple_keyword_cypher.pyexQ0bexQ0b\dnI"K4%%ciphers/simple_substitution_cipher.pyexQ0bexQ0b\ 2wDB$ܺ2ciphers/trafid_cipher.pyexQ0bexQ0b\j " _<J|1jhciphers/transposition_cipher.pyexQ0bexQ0b\prEV4㏠84ciphers/transposition_cipher_encrypt_decrypt_file.pyexQ0bexQ0b\R=|%g!j ;ciphers/vigenere_cipher.pyexQ0bexQ0b\2PVzys '1]ciphers/xor_cipher.pyeZ5EbeZ5Eb\⛲CK)wZScompression/__init__.pyew Kew K\O}pZB [!w7{?compression/burrows_wheeler.pyew9mew9m\d :<zv+u6tcompression/huffman.pyeZ5EbeZ5Eb\DſE |#f|,compression/image_data/PSNR-example-base.pngeZrNbeZrNb\7mwMf?G/compression/image_data/PSNR-example-comp-10.jpgeZrNbeZrNb\⛲CK)wZS"compression/image_data/__init__.pyeZrNbeZrNb\h<u!ǵy쮹V+compression/image_data/compressed_image.pngeZrNbeZrNb\u":X:3 Dי)C#(compression/image_data/example_image.jpgeZrNbeZrNb\nE>VQjHTN 2compression/image_data/example_wikipedia_image.jpgeZrNbeZrNb\G oޛjqt+4Wj)compression/image_data/original_image.pngexQ0bexQ0b\f-{448]yVLcompression/lempel_ziv.pyeu Seu S\ 8M<, ,O}8婚B:5$compression/lempel_ziv_decompress.pyew Kew K\llL8*;\.qsv)compression/peak_signal_to_noise_ratio.pyeu8ieu8i\I0 {O YS2 "computer_vision/README.mdeZrNbeZrNb\⛲CK)wZScomputer_vision/__init__.pyexQ0bexQ0b\Vxs0/d'computer_vision/harriscorner.pyexQ0bexQ0b\ vey3֩'w |s computer_vision/meanthreshold.pyeZWaeZWa\⛲CK)wZSconversions/__init__.pyeu Seu S\b^G[ܗ+ufgo conversions/binary_to_decimal.pyexQ0bexQ0b\YH~ɕ&}+~\}conversions/binary_to_octal.pyeu Seu S\ <rs*c50$<conversions/decimal_to_any.pyexQ0bexQ0b\~jc*f%. conversions/decimal_to_binary.pyeu Seu S\IY/jg^!s m+h*conversions/decimal_to_binary_recursion.pyexQ0bexQ0b\nC?xfͩCC1x%conversions/decimal_to_hexadecimal.pyexQ9aexQ9a\H0B*A conversions/decimal_to_octal.pyeu Seu S\徱~d=db|I^%conversions/hexadecimal_to_decimal.pyew^ ew^ \ hEeMr<4`"conversions/molecular_chemistry.pyeuL feuL f\Zss.ԱulԽ/Oconversions/octal_to_decimal.pyexQ9aexQ9a\ D nݻv-!conversions/prefix_conversions.pyeu Seu S\3槊M2N } y0conversions/roman_numerals.pyeu Seu S\-"|G'=ٺ|Džj&conversions/temperature_conversions.pyexQ9aexQ9a\$Q_/o*"R conversions/weight_conversion.pyeZWaeZWa\%⛲CK)wZSdata_structures/__init__.pyeZWaeZWa\5⛲CK)wZS'data_structures/binary_tree/__init__.pyew^ ew^ \%8ݖiehS$'data_structures/binary_tree/avl_tree.pyew^ ew^ \W[~h -ҡu}.$0data_structures/binary_tree/basic_binary_tree.pyexQ9aexQ9a\EÓ?| /P#oFM~*j1data_structures/binary_tree/binary_search_tree.pyew^ ew^ \@|^(T"pNG.;data_structures/binary_tree/binary_search_tree_recursive.pyewWewW\e{7N)Ew 2~ 1data_structures/binary_tree/binary_tree_mirror.pyexQ9aexQ9a\f|ۼ*_9BC.IK l5data_structures/binary_tree/binary_tree_traversals.pyeu"&jeu"&j\"Tzƍ \4o +data_structures/binary_tree/fenwick_tree.pyew^ ew^ \f)F j:*0data_structures/binary_tree/lazy_segment_tree.pyev4ev4\h /?ϙ_.Bٙ k}5data_structures/binary_tree/lowest_common_ancestor.pyew^ ew^ \k *<6w|Ћ55data_structures/binary_tree/merge_two_binary_trees.pyev4ev4\ ۧ(?JSw9data_structures/binary_tree/non_recursive_segment_tree.pyeu Seu S\ TBIm9O3U>data_structures/binary_tree/number_of_possible_binary_trees.pyew^ ew^ \U`ޗq/'U1 l-data_structures/binary_tree/red_black_tree.pyeu Seu S\  8E拲pSAˉ]+data_structures/binary_tree/segment_tree.pyeses\/)ʋqOtxiDã1data_structures/binary_tree/segment_tree_other.pyew^ ew^ \ O̒C373PXe$data_structures/binary_tree/treap.pyeZWaeZWa\V⛲CK)wZS(data_structures/disjoint_set/__init__.pyeZWaeZWa\WQ3[ ްI kdO6data_structures/disjoint_set/alternate_disjoint_set.pyew^ ew^ \٩;bJm醷iHK^~,data_structures/disjoint_set/disjoint_set.pyeZWaeZWa\Z⛲CK)wZS#data_structures/hashing/__init__.pyeuL feuL f\XWGpIݟ +%پ&data_structures/hashing/double_hash.pyew^ ew^ \  nL6>ET%data_structures/hashing/hash_table.pyew^ ew^ \_Ph|m_Io'36data_structures/hashing/hash_table_with_linked_list.pyeZWaeZWa\a⛲CK)wZS1data_structures/hashing/number_theory/__init__.pyeuQg#euQg#\M@upxyw?6data_structures/hashing/number_theory/prime_numbers.pyeo WYeo WY\c 04 4F ozc {R,data_structures/hashing/quadratic_probing.pyeZWaeZWa\g⛲CK)wZS data_structures/heap/__init__.pyeu Seu S\ 13KDNv__'X|l%data_structures/heap/binomial_heap.pyexQ9aexQ9a\M6,#^4;n;5CRdata_structures/heap/heap.pyeu Seu S\U<E8W$3Լla$data_structures/heap/heap_generic.pyexQ9aexQ9a\ *,uY9ۊ?5 data_structures/heap/max_heap.pyeu Seu S\eă6)UT3< data_structures/heap/min_heap.pyew^ ew^ \A "r'zax?'data_structures/heap/randomized_heap.pyew^ ew^ \JAz8?s>$i|4!data_structures/heap/skew_heap.pyew^ ew^ \xS{O˰'0ş`'data_structures/linked_list/__init__.pyew^ ew^ \c|,!:+Fh(c??L3data_structures/linked_list/circular_linked_list.pyexQ9aexQ9a\ɮ=zSKU|-+data_structures/linked_list/deque_doubly.pyeu Seu S\>6r)1data_structures/linked_list/doubly_linked_list.pyeu Seu S\Kifj^{'ힿ ;5data_structures/linked_list/doubly_linked_list_two.pyeZWaeZWa\vДOd4%uȷ,data_structures/linked_list/from_sequence.pyew^ ew^ \p@^~'Ȫnd e|'data_structures/linked_list/has_loop.pyeu Seu S\1|'+tvX[36,data_structures/linked_list/is_palindrome.pyew^ ew^ \kRAtiYZ.data_structures/linked_list/merge_two_lists.pyew^ ew^ \\L˻ ]uomb<data_structures/linked_list/middle_element_of_linked_list.pyew^ ew^ \ o"r`yB(9 Kb,data_structures/linked_list/print_reverse.pyewWewW\,Z! So|T01data_structures/linked_list/singly_linked_list.pyew^ ew^ \1-=R[8tӝtM(data_structures/linked_list/skip_list.pyeq$$eq$$\&?WVGP!l `d)data_structures/linked_list/swap_nodes.pyeZWaeZWa\⛲CK)wZS!data_structures/queue/__init__.pyeZWaeZWa\ \|)bj~",0'data_structures/queue/circular_queue.pyew Kew K\;|y^O<~YW+data_structures/queue/double_ended_queue.pyew Kew K\ ޅ&1SSIr~%data_structures/queue/linked_queue.pyeu Seu S\A&C?4C'/߉-y2data_structures/queue/priority_queue_using_list.pyeu Seu S\H\{rI:ԛaC-&data_structures/queue/queue_on_list.pyeu Seu S\!%f3?w .data_structures/queue/queue_on_pseudo_stack.pyeZWaeZWa\⛲CK)wZS"data_structures/stacks/__init__.pyew Kew K\#gO~6PD}.data_structures/stacks/balanced_parentheses.pyew Kew K\ >Fh99薙UД37data_structures/stacks/dijkstras_two_stack_algorithm.pyexQ9aexQ9a\2ؠ<; ^2O4data_structures/stacks/evaluate_postfix_notations.pyew Kew K\ۨGȦd% KAƙ5data_structures/stacks/infix_to_postfix_conversion.pyeu Seu S\ &ܞ>s*L{I4data_structures/stacks/infix_to_prefix_conversion.pyexQ9aexQ9a\>@-|7y@7U&data_structures/stacks/linked_stack.pyeu}eu}\} -1{~Ĝ*f~fͳ.data_structures/stacks/next_greater_element.pyeu Seu S\-WJCW1!xQ$,data_structures/stacks/postfix_evaluation.pyer, er, \d,crmJNj)Bt4+data_structures/stacks/prefix_evaluation.pyexQ9aexQ9a\ 8е/`O/data_structures/stacks/stack.pyew Kew K\ u d WM13)data_structures/stacks/stack_using_dll.pyeu Seu S\80*l!CXI< :z,data_structures/stacks/stock_span_problem.pyeZ``eZ``\⛲CK)wZS data_structures/trie/__init__.pyew Kew K\* e$ LQ"kϧdata_structures/trie/trie.pyeZ``eZ``\⛲CK)wZS$digital_image_processing/__init__.pyeZ``eZ``\I?9nF!Pc=-digital_image_processing/change_brightness.pyer`8er`8\Gj$nYN὿z+digital_image_processing/change_contrast.pyeZ``eZ``\}A8<(ʬ)-(E3/digital_image_processing/convert_to_negative.pyeZ``eZ``\⛲CK)wZS.digital_image_processing/dithering/__init__.pyeqSeqS\: +2% ~¹@||y}w,digital_image_processing/dithering/burkes.pyeZ``eZ``\⛲CK)wZS3digital_image_processing/edge_detection/__init__.pyeu Seu S\<Z)[M\ Rי0digital_image_processing/edge_detection/canny.pyeZ``eZ``\⛲CK)wZS,digital_image_processing/filters/__init__.pyeu Seu S\@ ;vMEO cg4digital_image_processing/filters/bilateral_filter.pyeqK9OeqK9O\c) <cHfV ,digital_image_processing/filters/convolve.pyeZ``eZ``\އge<q=={_־3digital_image_processing/filters/gaussian_filter.pyeZ``eZ``\@VbfmepӶbgy1digital_image_processing/filters/median_filter.pyeZ``eZ``\3(J2$t䈷y[0digital_image_processing/filters/sobel_filter.pyeZ``eZ``\⛲CK)wZS;digital_image_processing/histogram_equalization/__init__.pyeu Seu S\SfӨI;p!0Ddigital_image_processing/histogram_equalization/histogram_stretch.pyeZ``eZ``\⛲CK)wZSFdigital_image_processing/histogram_equalization/image_data/__init__.pyeZ``eZ``\H=F$YP)wDdigital_image_processing/histogram_equalization/image_data/input.jpgeZ``eZ``\⛲CK)wZSGdigital_image_processing/histogram_equalization/output_data/__init__.pyeZ``eZ``\οH } W7OUcFdigital_image_processing/histogram_equalization/output_data/output.jpgeZ``eZ``\⛲CK)wZS/digital_image_processing/image_data/__init__.pyeZ``eZ``\vN孝JSxs,digital_image_processing/image_data/lena.jpgeZ``eZ``\;QD\yœ$2-2digital_image_processing/image_data/lena_small.jpgeu$eu$\LCP`3?1E=|I-digital_image_processing/index_calculation.pyeZ``eZ``\⛲CK)wZS+digital_image_processing/resize/__init__.pyeZ``eZ``\H6RX?GPt)digital_image_processing/resize/resize.pyeZ``eZ``\⛲CK)wZS-digital_image_processing/rotation/__init__.pyexQ9aexQ9a\f)Q :qp҉r-digital_image_processing/rotation/rotation.pyexQ9aexQ9a\?ߵv^w+%4.|!digital_image_processing/sepia.pyeu"&jeu"&j\' @;mqLZ3`:9digital_image_processing/test_digital_image_processing.pyeZ``eZ``\⛲CK)wZSdivide_and_conquer/__init__.pyeZ``eZ``\ y{$"1 ,divide_and_conquer/closest_pair_of_points.pyew^ ew^ \Z? ogKr6'Į`!divide_and_conquer/convex_hull.pyeZ``eZ``\0fAlNsk<#%divide_and_conquer/heaps_algorithm.pyeZ``eZ``\LMA96!=:-/divide_and_conquer/heaps_algorithm_iterative.pyew^ ew^ \)V"!.!] divide_and_conquer/inversions.pyew^ ew^ \0kg 3j)divide_and_conquer/kth_order_statistic.pyexQ9aexQ9a\Cv174? (+̽6d)divide_and_conquer/max_difference_pair.pyeu Seu S\CxӒ-Ûbu6'&divide_and_conquer/max_subarray_sum.pyew^ ew^ \ FiAʳ|jc )R @divide_and_conquer/mergesort.pyew^ ew^ \O?Ň4a Fdivide_and_conquer/peak.pyeZ``eZ``\#6$g_ԭ tw'divide_and_conquer/power.pyexQ9aexQ9a\Iz)tx2QY3GL4divide_and_conquer/strassen_matrix_multiplication.pyeZ``eZ``\⛲CK)wZSdynamic_programming/__init__.pyeZ``eZ``\Qu/ ھz.~#dynamic_programming/abbreviation.pyeu Seu S\s $)[^筤|Bdynamic_programming/bitmask.pyeu Seu S\[WѾgJr)nHm&dynamic_programming/climbing_stairs.pyeu Seu S\ V~ P;ib$^]$dynamic_programming/edit_distance.pyeZ``eZ``\IZw´]PMD dynamic_programming/factorial.pyeZ``eZ``\`􁆣L%0J^FRNy%dynamic_programming/fast_fibonacci.pyev4ev4\Gʱ5ޡ'1L dynamic_programming/fibonacci.pyeu Seu S\tƨ%h58*1 ?%dynamic_programming/floyd_warshall.pyeu Seu S\ FJŎOh$>Dz*dynamic_programming/fractional_knapsack.pyewd ewd \ w81.= y/eU,dynamic_programming/fractional_knapsack_2.pyewd ewd \1%NcH΄`I>*?(dynamic_programming/integer_partition.pyer, er, \!MNU_2M:C31dynamic_programming/iterating_through_submasks.pyerPqerPq\ 4uO܄T՚s/7dynamic_programming/k_means_clustering_tensorflow.py_tfewd ewd \QiLNyubn udynamic_programming/knapsack.pyeu Seu S\3xjCRQBԽ l1dynamic_programming/longest_common_subsequence.pyewd ewd \ʊ+\܃VޮقI5dynamic_programming/longest_increasing_subsequence.pyeu Seu S\ESoȡ'XMX">dynamic_programming/longest_increasing_subsequence_o(nlogn).pyeu Seu S\ V.0ˏ^Υ}fg-(dynamic_programming/longest_sub_array.pyeu Seu S\֔pO1/[ 4s)dynamic_programming/matrix_chain_order.pyeu Seu S\vSb,]w,l)8+dynamic_programming/max_non_adjacent_sum.pyeu Seu S\ x R0`Ɲݮ L/PS$dynamic_programming/max_sub_array.pyeqeq\ Œ7 ]uY/ oSI5dynamic_programming/max_sum_contiguous_subsequence.pyeu Seu S\D(i{1d`D%*dynamic_programming/minimum_coin_change.pyeZ``eZ``\:KU(-4LN#JC(dynamic_programming/minimum_cost_path.pyeu eu \4N/ ةeXc(dynamic_programming/minimum_partition.pyeqSeqS\=-p3 C[H+dynamic_programming/minimum_steps_to_one.pyeu eu \" 9fgD Xp!1dynamic_programming/optimal_binary_search_tree.pyeuQg#euQg#\RD*9NV2 N"dynamic_programming/rod_cutting.pyeu eu \BG;2x+a(dynamic_programming/subset_generation.pyeu eu \e!w|t*t8: t$dynamic_programming/sum_of_subset.pyexQ9aexQ9a\Lv=\r2ò =+9>electronics/electric_power.pyexQ9aexQ9a\0@{cSU#Belectronics/ohms_law.pyeZ)i_eZ)i_\ ⛲CK)wZSfile_transfer/__init__.pyeZ)i_eZ)i_\ CTϧfǃ2ptF,."hnfile_transfer/mytext.txtexQ9aexQ9a\NϺn؄>1bB)5qfile_transfer/receive_file.pyexQ9aexQ9a\O[SGP<Ghם<file_transfer/send_file.pyeZ)i_eZ)i_\ $⛲CK)wZSfile_transfer/tests/__init__.pyeZ)i_eZ)i_\ %*`Dbownl9[gI;%file_transfer/tests/test_send_file.pyeZ)i_eZ)i_\ 5⛲CK)wZSfuzzy_logic/__init__.pyev4ev4\ W?c>jj(_fuzzy_logic/fuzzy_operations.pyeZ)i_eZ)i_\ 9⛲CK)wZSgenetic_algorithm/__init__.pyeu eu \DႼJ% <JP!genetic_algorithm/basic_string.pyeZ)i_eZ)i_\ <⛲CK)wZSgeodesy/__init__.pyeu eu \ _ފ8t S)*geodesy/haversine_distance.pyeu eu \ Pީ1E0*(geodesy/lamberts_ellipsoidal_distance.pyeZ)i_eZ)i_\ B⛲CK)wZSgraphics/__init__.pyeu$eu$\k~+dO#cjA/graphics/bezier_curve.pyexQ9aexQ9a\rX[A;PKF' Ygraphics/koch_snowflake.pyexQ9aexQ9a\'y[oEˌZSHUgraphics/mandelbrot.pyeqSeqS\ ߢ"b225N$graphics/vector3_for_2d_rendering.pyeZ)i_eZ)i_\ F⛲CK)wZSgraphs/__init__.pyew:vew:v\6 [/zcV9 ޮgraphs/a_star.pyeu eu \&q6k'熤=G4pgraphs/articulation_points.pyew:vew:v\7s{*wV\B\dJ1ygraphs/basic_graphs.pyew:vew:v\F^VGg@'#l1graphs/bellman_ford.pyew:vew:v\m EuKS~V o&㱓hgraphs/bfs_shortest_path.pyew:vew:v\%a'Bi ߚE$graphs/bfs_zero_one_shortest_path.pyew:vew:v\ rO_:#=sWyC[graphs/bidirectional_a_star.pyew:vew:v\m9}A[MO,graphs/bidirectional_breadth_first_search.pyew:vew:v\^ U - ? Xnmgraphs/breadth_first_search.pyevev\w$:@CqUza!+ graphs/breadth_first_search_2.pyew:vew:v\P 4yeIa,graphs/breadth_first_search_shortest_path.pyevev\ dqd]pܔXtAUD#graphs/check_bipartite_graph_bfs.pyeq$$eq$$\ bdB0DN {pz#graphs/check_bipartite_graph_dfs.pyer, er, \ J=tƄ !!h[љgraphs/connected_components.pyew:vew:v\s|rSe=O$`mgraphs/depth_first_search.pyeo`hA.eo`hA.\E0r'vbSsښ~ɤL:graphs/depth_first_search_2.pyeu eu \ _˿ҒcHH|Vϐgraphs/dijkstra.pyeu eu \v(nJP0F܆?D)_Egraphs/dijkstra_2.pyeu eu \kdJ́vnEz`#@graphs/dijkstra_algorithm.pyeZ)i_eZ)i_\ ` R\ڏfLHBKgraphs/dinic.pyeu eu \o>\ ƼbL!"2graphs/directed_and_undirected_(weighted)_graph.pyeu eu \/5񮣣/4cosg/graphs/edmonds_karp_multiple_source_and_sink.pyewd ewd \xP;KQrxQuK8graphs/eulerian_path_and_circuit_for_undirected_graph.pyew:vew:v\ɮp p1L8W>graphs/even_tree.pyeu}eu}\eU{ž~8F^pgraphs/finding_bridges.pyew'Bew'B\ pc"g17D4JEsY?&graphs/frequent_pattern_graph_miner.pyeZ)i_eZ)i_\ gwT=QnLXngraphs/g_topological_sort.pyew:vew:v\^Y)nm2xl8zgraphs/gale_shapley_bigraph.pyew:vew:v\u3։:>e#DUgraphs/graph_list.pyer, er, \ qhBk[,PU_graphs/graph_matrix.pyeZ)i_eZ)i_\ l Vϋ8+5Igraphs/graphs_floyd_warshall.pyew:vew:v\K=?ENW<LHqdUgraphs/greedy_best_first.pyeu eu \ &Qz!EY_4.graphs/kahns_algorithm_long.pyeu eu \ 3)aG|',ʃgraphs/kahns_algorithm_topo.pyer, er, \ 2 !(Mؠnvgraphs/karger.pyeu eu \ +2T.lcpk1֏uZ'graphs/minimum_spanning_tree_boruvka.pyew:vew:v\qA`R?V=}I'graphs/minimum_spanning_tree_kruskal.pyew:vew:v\ ߸~7dkϛQ@{4Bet(graphs/minimum_spanning_tree_kruskal2.pyeu eu \T(a@'_J3P%S%graphs/minimum_spanning_tree_prims.pyew:vew:v\#Ysl€d$&graphs/minimum_spanning_tree_prims2.pyew:vew:v\!VwW`j<graphs/multi_heuristic_astar.pyew^ ew^ \]Q)mF ɺWh\graphs/page_rank.pyeuL feuL f\ p2?p?<{Ҍgraphs/prim.pyew:vew:v\ 0W<c cj͆obބgraphs/scc_kosaraju.pyew:vew:v\  i b[f<gSP@['graphs/strongly_connected_components.pyeqK9߬OeqK9߬O\  \0ʊ OPym}x]}graphs/tarjans_scc.pyew:vew:v\ :Rz8O[Of:).graphs/tests/test_min_spanning_tree_kruskal.pyeu eu \eY_ozA~$Ms+graphs/tests/test_min_spanning_tree_prim.pyeZ)i_eZ)i_\ ⛲CK)wZShashes/__init__.pyexQ9aexQ9a\G ]|̆hashes/adler32.pyexQ9aexQ9a\ cߘKhb(ا XUhashes/chaos_machine.pyeu eu \ Kg-7"y*Ƕhashes/djb2.pyexQ9aexQ9a\T  CsWShashes/enigma_machine.pyeu$eu$\ M$J2 ]jS)5thashes/hamming_code.pyexQ9aexQ9a\=2QUSaP3 hashes/md5.pyexQ9aexQ9a\>zgi(f[.&Fhashes/sdbm.pyew:vew:v\if̣|?bq4%qd*Ehashes/sha1.pyew Kew K\L`A䎸 HpYknapsack/README.mdeZ)i_eZ)i_\ ⛲CK)wZSknapsack/__init__.pyeZ)i_eZ)i_\ c@[k◒knapsack/greedy_knapsack.pyew^ ew^ \ ^udCacX؎G$jo+knapsack/knapsack.pyeZ)i_eZ)i_\ ⛲CK)wZSknapsack/tests/__init__.pyepEepE\~ +-]@݋xWi&knapsack/tests/test_greedy_knapsack.pyepEepE\5$USq}S2s%knapsack/tests/test_knapsack.pyew Kew K\h ^` @sJtlinear_algebra/README.mdeZ)i_eZ)i_\ ⛲CK)wZSlinear_algebra/__init__.pyeZ)i_eZ)i_\ ⛲CK)wZSlinear_algebra/src/__init__.pyexQ9aexQ9a\|Yeh(>(linear_algebra/src/conjugate_gradient.pyexQ9aexQ9a\- 5<4 ;ɰ7iiIn;ֶlinear_algebra/src/lib.pyexQ9aexQ9a\z67#҅ tϴ (linear_algebra/src/polynom_for_points.pyexQ9aexQ9a\ AGca3!4%׮#C%linear_algebra/src/power_iteration.pyexQ9aexQ9a\i Hp1 'linear_algebra/src/rayleigh_quotient.pyexQ9aexQ9a\wn:8eC9`d3)linear_algebra/src/test_linear_algebra.pyexQ9aexQ9a\ cjVv: pR(linear_algebra/src/transformations_2d.pyeZfr_eZfr_\ ⛲CK)wZSmachine_learning/__init__.pyeu eu \ \g?$䔟üN)TƲmachine_learning/astar.pyeu eu \ ! t~W+Ƈlᢚ΍>(machine_learning/data_transformations.pyeu eu \zCܱD*R!machine_learning/decision_tree.pyeZfr_eZfr_\ ⛲CK)wZS(machine_learning/forecasting/__init__.pyeqZ3eqZ3\ BdUXY?V~(machine_learning/forecasting/ex_data.csvexQ9aexQ9a\X_ûOR cJ#machine_learning/forecasting/run.pyeu eu \ ,ZM-ęGXt_s(machine_learning/gaussian_naive_bayes.pyeuL feuL f\   |ihC/machine_learning/gradient_boosting_regressor.pyer, er, \ u `ub$o$machine_learning/gradient_descent.pyexQ9aexQ9a\2kUԄ_A?t(=i7 !machine_learning/k_means_clust.pyexQ9aexQ9a\sX-5ə.7Ul8(machine_learning/k_nearest_neighbours.pyeq$$eq$$\ dJbBDϭc\FKEmachine_learning/knn_sklearn.pyexQ9aexQ9a\BV psѸ"qG1x0machine_learning/linear_discriminant_analysis.pyexQ9aexQ9a\!&b6q| i$kyE%machine_learning/linear_regression.pyeu eu \ e H؎蔼Ls'machine_learning/logistic_regression.pyeZfr_eZfr_\ ⛲CK)wZS!machine_learning/lstm/__init__.pyexQ9aexQ9a\ TRD?b`niYJ ]+machine_learning/lstm/lstm_prediction.py_tfeZfr_eZfr_\ M!p2u-)%machine_learning/lstm/sample_data.csveu eu \ o`AwȈl>1Ɂ4machine_learning/multilayer_perceptron_classifier.pyer`8er`8\ 7L5o7>OP)machine_learning/polymonial_regression.pyeu eu \ |cp%@2z/ǔϦ7y,machine_learning/random_forest_classifier.pyeu eu \  &8(@E+machine_learning/random_forest_regressor.pyeZfr_eZfr_\  Fi\;!.n҂3 %machine_learning/scoring_functions.pyeu$eu$\jQglRۧV89j3machine_learning/sequential_minimum_optimization.pyew^ ew^ \X\ JEбG%machine_learning/similarity_search.pyeuL feuL f\ ]H:ʽd&+machine_learning/support_vector_machines.pyexQ9aexQ9a\ƾ *G2wLw},machine_learning/word_frequency_functions.pyeses\ > UX4,0maths/3n_plus_1.pyeZfr_eZfr_\ ⛲CK)wZSmaths/__init__.pyeu eu \hɚQ،u0p/ maths/abs.pyew^ ew^ \!WKsx^Tmaths/abs_max.pyew^ ew^ \I7#Q$޷[z~maths/abs_min.pyeu eu \  ږӓ6(U maths/add.pyeZfr_eZfr_\ ~XaўR &2(maths/aliquot_sum.pyeZfr_eZfr_\ MKlW>f[maths/allocation_number.pyewWewW\($݆#̚r:`3c maths/area.pyew^ ew^ \ L-;Cg+m5maths/area_under_curve.pyexQ9aexQ9a\ 00$|<kD%maths/armstrong_numbers.pyew:vew:v\ UKA]w-4rA4maths/average_mean.pyew:vew:v\ WEWoVHF&Rmaths/average_median.pyexQ9aexQ9a\NrԿg3U?ڑmaths/average_mode.pyexQ9aexQ9a\ 1+~U&o15ڌ9maths/bailey_borwein_plouffe.pyew:vew:v\;=Qr1P$Lmaths/basic_maths.pyer, er, \ groG^dsI maths/binary_exp_mod.pyer, er, \ iXREDN#@Ͳ3nmaths/binary_exponentiation.pyeu eu \ |M+#ws%amaths/binomial_coefficient.pyeu$eu$\ yJZ~ٔV!6X%B1=>maths/binomial_distribution.pyeu eu \ "GNFPꪰOi|maths/bisection.pyeu eu \ ~ޗWes6wn! ` maths/ceil.pyeZfr_eZfr_\ tb./?k )E6]maths/chudnovsky_algorithm.pyeqeq\  {66i "e.VLImaths/collatz_sequence.pyeu eu \@P)v0koFmaths/combinations.pyeu eu \ 9ggÛB[:maths/decimal_isolate.pyew^ ew^ \ hC8`ϱOMBbjjmaths/entropy.pyew^ ew^ \ Dn 7Ktl -GO5lmaths/euclidean_distance.pyerckerck\j5 'zQ w'maths/eulers_totient.pyexQ9aexQ9a\ C|x`+i7smaths/explicit_euler.pyew^ ew^ \ mv6 KT^ڱ%maths/extended_euclidean_algorithm.pyew Kew K\kd1G t-ؓmaths/factorial_iterative.pyew Kew K\ EFhaVw}yi21b&maths/factorial_python.pyer, er, \ 0qs5eL"E2maths/factorial_recursive.pyeu eu \ :Na~a7Vmaths/factors.pyer-; er-; \ 1s>( hBڼmaths/fermat_little_theorem.pyev4ev4\&Q5@%z ?maths/fibonacci.pyev4ev4\ OyK:+ &T'%maths/fibonacci_sequence_recursion.pyew^ ew^ \,M~E&>ӌr!maths/find_max.pyew^ ew^ \. f"Y_,'Fmaths/find_max_recursion.pyew^ ew^ \9*KSc?8/}maths/find_min.pyew^ ew^ \KD|zw0D^m`UJmaths/find_min_recursion.pyeu eu \ H"P垗"܌{Omaths/floor.pyer-; er-; \ Bípx'  ؄maths/gamma.pyeu$eu$\ Bۥ }}k ph6maths/gaussian.pyeZfr_eZfr_\ ܢJJIv쐎*5 maths/greatest_common_divisor.pyew^ ew^ \ <p}A;lLmaths/hardy_ramanujanalgo.pyeZfr_eZfr_\ ⛲CK)wZSmaths/images/__init__.pyeZfr_eZfr_\ !|~!)lM0Ϣmaths/images/gaussian.pngeu eu \ f_gi6ǒmaths/is_square_free.pyeu eu \  =O$@PM &mgmaths/jaccard_similarity.pyeu eu \ T9ԢXE?ԿE; maths/kadanes.pyeu$eu$\)z\K): F{ maths/karatsuba.pyeu eu \ \-ȏh'э1+ɶ{Aemaths/krishnamurthy_number.pyeu eu \ =#&H¡C0{`&maths/kth_lexicographic_permutation.pyer-; er-; \  &NƊ|/y"&maths/largest_of_very_large_numbers.pyer-; er-; \+ _ vCiKٮ4Tpmaths/least_common_multiple.pyew^ ew^ \ p8kD /&maths/line_length.pyeu eu \ \]YͼV$maths/lucas_lehmer_primality_test.pyeu eu \ 4k2.D+3ߤ maths/lucas_series.pyeu eu \  <?(Q͕#ÃZmaths/matrix_exponentiation.pyew Kew K\ ' =2OۑRtmaths/miller_rabin.pyer`8er`8\ O5Y[QЬ<maths/mobius_function.pyeZ{^eZ{^\ ;mB}:$/D6whmaths/modular_exponential.pyeu$eu$\ (|Ax=>l`Yy%maths/monte_carlo.pyexQ9aexQ9a\:ǿD7Ț'Imaths/monte_carlo_dice.pyer-; er-; \  ˗f> 8Ar+Wmaths/newton_raphson.pyes^es^\ 9<?`NC/4:x/maths/number_of_digits.pyew^ ew^ \ tJv@\Y֧{Ȟmaths/numerical_integration.pyeo WYeo WY\ 4҇uq maths/perfect_cube.pyeo`hA.eo`hA.\ Q2ғmhjFDmaths/perfect_number.pyeu$eu$\ Ct xV,чqmaths/perfect_square.pyeu$eu$\  mZv9"maths/pi_monte_carlo_estimation.pyexQ9aexQ9a\))r<^ Dmaths/polynomial_evaluation.pyeo`hA.eo`hA.\  Щi<e^0Umaths/power_using_recursion.pyew Kew K\;⼷Q"]8]Gmaths/prime_check.pyeZ{^eZ{^\ ^\ :mG=,;jmaths/prime_factors.pyew Kew K\H8Ala(k maths/prime_numbers.pyeu eu \E`!@N6W!maths/prime_sieve_eratosthenes.pyerckerck\ iw11ܫb]maths/pythagoras.pyeu eu \ _^O*Omݾ2Ymaths/qr_decomposition.pyeit.Seit.S\5NÐad/* TY,maths/quadratic_equations_complex_numbers.pyeq%!#eq%!#\ JTFTgJ,Wmaths/radians.pyewd ewd \ !އT@iR͇q;2maths/radix2_fft.pyeq%!#eq%!#\ =EkÑnU&j|u maths/relu.pyeu eu \ s87ڥ |xg㾻Emaths/runge_kutta.pyeu$eu$\ X`Iz>8_`lΧjmaths/segmented_sieve.pyeZ{^eZ{^\ k⛲CK)wZSmaths/series/__init__.pyewWewW\\Kc?hd*5^maths/series/arithmetic_mean.pyewWewW\nPTet!##@maths/series/geometric_mean.pyeu}eu}\#Ė "혴fn܀ maths/series/geometric_series.pyew'Bew'B\ 呵E7fUu,[Pǃmaths/series/harmonic_series.pyeu}eu}\ Zv-+cvumaths/series/p_series.pyew^ ew^ \ vGTiɣw@˨}maths/sieve_of_eratosthenes.pyeqRr+eqRr+\ (uqA~Tmaths/sigmoid.pyepEepE\ q@mÚqqV\ː=pmaths/simpson_rule.pyeu eu \ !MQ䳕4~wmaths/softmax.pyeu eu \ t$#|$#5-4maths/square_root.pyeu eu \ t+oW9S=b!maths/sum_of_arithmetic_series.pyeu eu \:dcLh?5| :maths/sum_of_digits.pyeu$eu$\ \$h4%maths/sum_of_geometric_progression.pyeu eu \ 8b4vs,@zmaths/test_prime_check.pyeZ{^eZ{^\  M܊ka1 !maths/trapezoidal_rule.pyeu eu \ v~DQڭB :鰦7maths/ugly_numbers.pyew^ ew^ \[ A3>VMv=/˄Bߺomaths/volume.pyeu eu \ 6-J"}yevdmaths/zellers_congruence.pyeZ{^eZ{^\ ⛲CK)wZSmatrix/__init__.pyeu eu \ ggu^|aO!matrix/count_islands_in_matrix.pyeu eu \ : dK\>hߧ]Fmatrix/inverse_of_matrix.pyeu eu \ >*WEѫDW{NIߨmatrix/matrix_class.pyeu}eu}\ܠ1M?~Xnmatrix/matrix_operation.pyewn/!/Xewn/!/X\  L9#mHt+ԋ{3matrix/nth_fibonacci_using_matrix_exponentiation.pyeu eu \q g8Yz]=r[jNmatrix/rotate_matrix.pyew^ ew^ \ zbc/P)16$matrix/searching_in_sorted_matrix.pyeuL feuL f\ 4fԠ-( i*matrix/sherman_morrison.pyewn/!/Xewn/!/X\ ?!ڷaV?ɘ ``fmatrix/spiral_print.pyeZ{^eZ{^\ ⛲CK)wZSmatrix/tests/__init__.pyeZ{^eZ{^\ <V-_ѹQާlmatrix/tests/pytest.iniepEepE\xe_?VµX%matrix/tests/test_matrix_operation.pyeZ{^eZ{^\ ⛲CK)wZSnetworking_flow/__init__.pyeu eu \ 㖷dtj[ !Cdc(SI!networking_flow/ford_fulkerson.pyeu ͙eu ͙\ ן6 9jîWcVnnetworking_flow/minimum_cut.pyexQ9aexQ9a\-1bK.^u|;0neural_network/2_hidden_layers_neural_network.pyeZ{^eZ{^\ ⛲CK)wZSneural_network/__init__.pyeu ͙eu ͙\ {C{,DiQ1neural_network/back_propagation_neural_network.pyeuL feuL f\7!H%e69Ln1,neural_network/convolution_neural_network.pyeq%!#eq%!#\ >ްbčǑut +>U e&neural_network/gan.py_tferPqerPq\ Z/" ͥ=<pj̖neural_network/input_data.py_tfexQ9aexQ9a\ ^# 'z J'kԒneural_network/perceptron.pyeZ]eZ]\ ⛲CK)wZSother/__init__.pyew Kew K\9VҾP'v[9other/activity_selection.pyexQ9aexQ9a\ Q` ռGNa}Dother/anagrams.pyexQ9aexQ9a\ YK"6sxeUbϡdA other/autocomplete_using_trie.pyexQ9aexQ9a\ ZNpA)Ԓ25h^ӻother/binary_exponentiation.pyexQ9aexQ9a\ aQK% ]e[8 other/binary_exponentiation_2.pyew^ ew^ \ ,xmݘ(lS|Q-other/davis–putnam–logemann–loveland.pyexQ9aexQ9a\ rDqkdӺTH_E+other/detecting_english_programmatically.pyexQ9aexQ9a\ s<u9v*@dSڪother/dictionary.txteo WYeo WY\ !{κ]zd6"fNVB#other/dijkstra_bankers_algorithm.pyeZ]eZ]\ !&V_ %h$other/doomsday.pyexQ9aexQ9a\ K%C~po~2M_Gtother/euclidean_gcd.pyewn/!/Xewn/!/X\ nsxMp\&^other/fischer_yates_shuffle.pyexQ9aexQ9a\  VHv ]]1Tother/frequency_finder.pyexQ9aexQ9a\  9:TF\14!~other/game_of_life.pyeZ]eZ]\ DGԫg 'o%05other/gauss_easter.pyew Kew K\Rg͊MM"other/graham_scan.pyeu ͙eu ͙\ KxN^1A]2other/greedy.pyexQ9aexQ9a\ yD 'uZL'other/integeration_by_simpson_approx.pyexQ9aexQ9a\ I.d3Nʾgother/largest_subarray_sum.pyexQ9aexQ9a\w!39cdi.K=rψOother/least_recently_used.pyew^ ew^ \ )-@&BdPYo$K!:AP!/gother/lfu_cache.pyewd ewd \ =V-1Hco &other/linear_congruential_generator.pyew^ ew^ \ O*~IyiX䊊other/lru_cache.pyeu ͙eu ͙\ qPӷrBYrk`eother/magicdiamondpattern.pyexQ9aexQ9a\ <@҈d{8 Z)y=6pother/markov_chain.pyexQ9aexQ9a\ K׆ 2other/max_sum_sliding_window.pyexQ9aexQ9a\ /]~;h%bkother/median_of_two_arrays.pyeu ͙eu ͙\ 󣇗Q&;zmyother/nested_brackets.pyexQ9aexQ9a\ ya,y Xכother/palindrome.pyexQ9aexQ9a\ [5Mxj- t[5<qother/password_generator.pyexQ9aexQ9a\ 87=prӎother/primelib.pyevev\ \wb,Ҡ? w롳other/scoring_algorithm.pyeu ͙eu ͙\  :ť=P)?tS/ other/sdes.pyexQ9aexQ9a\ "As΍ ߏ:other/sierpinski_triangle.pyeu ͙eu ͙\ < 6m,Z09Zother/tower_of_hanoi.pyexQ9aexQ9a\ $ xRrX7{96:fother/triplet_sum.pyexQ9aexQ9a\ %#Lgҭjsyother/two_pointer.pyexQ9aexQ9a\ &>R ~D/jۚ&Foother/two_sum.pyexQ9aexQ9a\ ')M>'O\gother/word_patterns.pyexQ6K`exQ6K`\ *& KWcd:}˫v0 other/wordsew Kew K\8.۳k(:project_euler/README.mdeZ]eZ]\ ⛲CK)wZSproject_euler/__init__.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_001/__init__.pyew^ ew^ \ 2)L2fr?T8!project_euler/problem_001/sol1.pyeZ]eZ]\ SpQ3xX(U{يE!project_euler/problem_001/sol2.pyeZ]eZ]\ gAU:Qz]};=h1!project_euler/problem_001/sol3.pyeZ]eZ]\ d<O$2-/5g!project_euler/problem_001/sol4.pyew^ ew^ \  Ѽ|{voT6!project_euler/problem_001/sol5.pyeZ]eZ]\ Gq7oi!project_euler/problem_001/sol6.pyeu ͙eu ͙\ ͏]w+v!project_euler/problem_001/sol7.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_002/__init__.pyeZ]eZ]\ Shk ʆí 8!project_euler/problem_002/sol1.pyeZ]eZ]\ Ґ3Цɰjjn4%!project_euler/problem_002/sol2.pyeZ]eZ]\ :uzL! kd!project_euler/problem_002/sol3.pyeZ]eZ]\ !p֨ &Qqpn<]E!project_euler/problem_002/sol4.pyeZ]eZ]\ "D9ў8Y`4"3bg_r!project_euler/problem_002/sol5.pyeZ]eZ]\ $⛲CK)wZS%project_euler/problem_003/__init__.pyew^ ew^ \y 4A(w޳YD J)!project_euler/problem_003/sol1.pyeZ]eZ]\ & JFz5,o!project_euler/problem_003/sol2.pyew^ ew^ \{o/aʊr!F[n Ѝ!project_euler/problem_003/sol3.pyeZ]eZ]\ )⛲CK)wZS%project_euler/problem_004/__init__.pyeu ͙eu ͙\ ka3JɧYcԖ!project_euler/problem_004/sol1.pyeZ]eZ]\ +ȀmX|@Ϻg=0!project_euler/problem_004/sol2.pyeZ]eZ]\ -⛲CK)wZS%project_euler/problem_005/__init__.pyer-; er-; \ crһ|{U9϶UZbm!project_euler/problem_005/sol1.pyeu"&jeu"&j\ ȀDH} ~T(Dr!project_euler/problem_005/sol2.pyeZ]eZ]\ 1⛲CK)wZS%project_euler/problem_006/__init__.pyeu$eu$\ R1az2ûcЈʛ_n!project_euler/problem_006/sol1.pyeZ]eZ]\ 3m{Hqja`!project_euler/problem_006/sol2.pyew^ ew^ \ -y10tg/)+&a\.!project_euler/problem_006/sol3.pyeZ]eZ]\ 5tVnKtSOf!project_euler/problem_006/sol4.pyeZ]eZ]\ 7⛲CK)wZS%project_euler/problem_007/__init__.pyeu"&jeu"&j\ 9xQ7&|;!project_euler/problem_007/sol1.pyew^ ew^ \}1f- p Bz@!project_euler/problem_007/sol2.pyeu$eu$\ 7y>oz0ɑOΒ5!project_euler/problem_007/sol3.pyeZ]eZ]\ <⛲CK)wZS%project_euler/problem_008/__init__.pyeu ͙eu ͙\  dy`wxD 辖Nsku!project_euler/problem_008/sol1.pyew^ ew^ \ fH\&~#\}z'S!project_euler/problem_008/sol2.pyeu ͙eu ͙\  PKnvRlVi7!project_euler/problem_008/sol3.pyeZ]eZ]\ A⛲CK)wZS%project_euler/problem_009/__init__.pyew^ ew^ \C ?O!project_euler/problem_009/sol1.pyeZ]eZ]\ Ckr*"E6!project_euler/problem_009/sol2.pyev4ev4\ Էa쒈=jx!project_euler/problem_009/sol3.pyeZ]eZ]\ F⛲CK)wZS%project_euler/problem_010/__init__.pyeu}eu}\ PIIR<v?a Ykkt!project_euler/problem_010/sol1.pyeuL oeuL o\ :/H]P&wX_>{M!project_euler/problem_010/sol2.pyeu$eu$\ }wǯ WP hL!project_euler/problem_010/sol3.pyeZ]eZ]\ K⛲CK)wZS%project_euler/problem_011/__init__.pyeZ]eZ]\ LJE>)1QNFh:"project_euler/problem_011/grid.txteu ͙eu ͙\ 2 ޝs#}$/d=!project_euler/problem_011/sol1.pyeu ͙eu ͙\ < quq2%Մ'=o !project_euler/problem_011/sol2.pyeZ]eZ]\ P⛲CK)wZS%project_euler/problem_012/__init__.pyev4ev4\ c~ NEޫy/P!project_euler/problem_012/sol1.pyew^ ew^ \ {_4IK_> !project_euler/problem_012/sol2.pyeZ]eZ]\ T⛲CK)wZS%project_euler/problem_013/__init__.pyeZ]eZ]\ UChm 1kS-S!project_euler/problem_013/num.txtew^ ew^ \ .wB^,#/m!project_euler/problem_013/sol1.pyeZ]eZ]\ X⛲CK)wZS%project_euler/problem_014/__init__.pyew^ ew^ \EZ i ,{C!project_euler/problem_014/sol1.pyew^ ew^ \p 2t G@ڌ@q~!project_euler/problem_014/sol2.pyeZ]eZ]\ \⛲CK)wZS%project_euler/problem_015/__init__.pyew Kew K\y& ŢfIm,!project_euler/problem_015/sol1.pyeZ]eZ]\ _⛲CK)wZS%project_euler/problem_016/__init__.pyeu$eu$\ b b H/r(R3="!project_euler/problem_016/sol1.pyeu$eu$\ h90M'Ym0ݴ%>!project_euler/problem_016/sol2.pyeZ]eZ]\ c⛲CK)wZS%project_euler/problem_017/__init__.pyeZ]eZ]\ diZNZǁR@^7a!project_euler/problem_017/sol1.pyeZ]eZ]\ f⛲CK)wZS%project_euler/problem_018/__init__.pyer-; er-; \ |<oK>,U6%project_euler/problem_018/solution.pyeZ]eZ]\ hh6~Є.}yX&project_euler/problem_018/triangle.txteZ]eZ]\ j⛲CK)wZS%project_euler/problem_019/__init__.pyer-; er-; \ "Y6XCBb1"o!project_euler/problem_019/sol1.pyeZ]eZ]\ m⛲CK)wZS%project_euler/problem_020/__init__.pyeZ]eZ]\ nǴrNT<yhdyr2!project_euler/problem_020/sol1.pyew^ ew^ \ $G(ΗG%t+w!project_euler/problem_020/sol2.pyeZ]eZ]\ pKO(_4,!project_euler/problem_020/sol3.pyeZ]eZ]\ q;, ߦ> e`{s!project_euler/problem_020/sol4.pyeZ]eZ]\ s⛲CK)wZS%project_euler/problem_021/__init__.pyew^ ew^ \  ?ynA墶%,l%ww6:!project_euler/problem_021/sol1.pyeZ]eZ]\ v⛲CK)wZS%project_euler/problem_022/__init__.pyeZ]eZ]\ wo{lL.4㭇s(project_euler/problem_022/p022_names.txteZ]eZ]\ x)$^t0p]z;lh!project_euler/problem_022/sol1.pyeZ]eZ]\ yZhn,k_HT3ـ!project_euler/problem_022/sol2.pyeZ]eZ]\ {⛲CK)wZS%project_euler/problem_023/__init__.pyeu$eu$\ Nh+a#/}B !project_euler/problem_023/sol1.pyeZ]eZ]\ ~⛲CK)wZS%project_euler/problem_024/__init__.pyeZ]eZ]\ cx`Y9X*!project_euler/problem_024/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_025/__init__.pyer%]er%]\  t<K&#5!project_euler/problem_025/sol1.pyew^ ew^ \ ;T5mS3n!project_euler/problem_025/sol2.pyeu ͙eu ͙\ OdUJϠK{!project_euler/problem_025/sol3.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_026/__init__.pyew^ ew^ \drN>ZBYF!project_euler/problem_026/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_027/__init__.pyeu$eu$\ .o(%r?,")!project_euler/problem_027/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_028/__init__.pyeu$eu$\ rka 9Y|"bo!project_euler/problem_028/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_029/__init__.pyeu$eu$\ UrkNDh9μV!project_euler/problem_029/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_030/__init__.pyeu"&jeu"&j\ /'eqg6>x 7!project_euler/problem_030/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_031/__init__.pyeZ]eZ]\ @81u).y+!project_euler/problem_031/sol1.pyeZ]eZ]\ 8KtʵYDtDZc!project_euler/problem_031/sol2.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_032/__init__.pyeu ͙eu ͙\ W!9237.u[#'u"project_euler/problem_032/sol32.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_033/__init__.pyew^ ew^ \ nU=]LsL!project_euler/problem_033/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_034/__init__.pyew^ ew^ \xmԾHRk"!project_euler/problem_034/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_035/__init__.pyeq%!#eq%!#\ H?g;i &!project_euler/problem_035/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_036/__init__.pyew^ ew^ \ I._>0m !project_euler/problem_036/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_037/__init__.pyew^ ew^ \ TT#| =c>(!project_euler/problem_037/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_038/__init__.pyew^ ew^ \  LmT.X]g=DFT!project_euler/problem_038/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_039/__init__.pyeZ]eZ]\ AYHhtoa!project_euler/problem_039/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_040/__init__.pyeZ]eZ]\ ji7w#N2RPc!project_euler/problem_040/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_041/__init__.pyeu"&jeu"&j\ S!%*!rVKBC!project_euler/problem_041/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_042/__init__.pyeu ͙eu ͙\ ~LDsyyY{d'project_euler/problem_042/solution42.pyeZ]eZ]\ ?گ:BQ ͗t#project_euler/problem_042/words.txteZ]eZ]\ y-`H,oRbQ%project_euler/problem_043/__init__.pyeu}eu}\ [Xz -]!project_euler/problem_043/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_044/__init__.pyew^ ew^ \Ӯdv_M P6xN+!project_euler/problem_044/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_045/__init__.pyev4ev4\ 0s9%qVCnl!project_euler/problem_045/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_046/__init__.pyew^ ew^ \ ?VuQ6͡[2+Ş!project_euler/problem_046/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_047/__init__.pyeZ]eZ]\  8r .|=v7!project_euler/problem_047/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_048/__init__.pyeu$eu$\ zp-c#5Ī\$8գ!project_euler/problem_048/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_049/__init__.pyew^ ew^ \ q[ {Tb%*̎!project_euler/problem_049/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_050/__init__.pyew^ ew^ \ }._+$jI J!project_euler/problem_050/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_051/__init__.pyew^ ew^ \ & `ԅMS)!project_euler/problem_051/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_052/__init__.pyeu ͙eu ͙\ 5"\F{]ZF RyR!project_euler/problem_052/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_053/__init__.pyeZ]eZ]\ 7&Y]zAӻX!project_euler/problem_053/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_054/__init__.pyeZ]eZ]\ u0Had׷)project_euler/problem_054/poker_hands.txtew^ ew^ \ 5 i<ct!project_euler/problem_054/sol1.pyeu ͙eu ͙\ 13lMh/,project_euler/problem_054/test_poker_hand.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_055/__init__.pyeZ]eZ]\  iT:iQ۶ZEu!project_euler/problem_055/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_056/__init__.pyew^ ew^ \ %nU3B Sw/!project_euler/problem_056/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_057/__init__.pyeZ]eZ]\ GX'o'!project_euler/problem_057/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_058/__init__.pyew Kew K\ӱQW &ْ5ڨ!project_euler/problem_058/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_059/__init__.pyeZ]eZ]\ ޳$rR,iYo)project_euler/problem_059/p059_cipher.txtew^ ew^ \ +U&gջ}%4^!project_euler/problem_059/sol1.pyeZ]eZ]\ `'7@t9j/ g\Yʸ!)project_euler/problem_059/test_cipher.txteZ]eZ]\ ⛲CK)wZS%project_euler/problem_062/__init__.pyeu$eu$\ 8V(lCp^!project_euler/problem_062/sol1.pyeZ]eZ]\ y-`H,oRbQ%project_euler/problem_063/__init__.pyeu$eu$\ )ݺB%jM ?w!project_euler/problem_063/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_064/__init__.pyeu$eu$\ "iu$sȽ,0@n.!project_euler/problem_064/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_065/__init__.pyeu ͙eu ͙\ ` "i}Z UH9V!project_euler/problem_065/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_067/__init__.pyeuQ#euQ#\ Zy۫8v.(,f!project_euler/problem_067/sol1.pyeZ]eZ]\ ;.+8-NJYuKZu+&project_euler/problem_067/triangle.txteZ]eZ]\ ⛲CK)wZS%project_euler/problem_069/__init__.pyeu$eu$\ Hyw[iGH5E!project_euler/problem_069/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_070/__init__.pyew^ ew^ \  u'\ÁL1;Hj%!project_euler/problem_070/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_071/__init__.pyeZ]eZ]\  A[~St ]UJ8sk[!project_euler/problem_071/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_072/__init__.pyev4ev4\ c2e~!project_euler/problem_072/sol1.pyeZ]eZ]\ ,:SP0PO~!project_euler/problem_072/sol2.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_074/__init__.pyexQ6K`exQ6K`\ w ^joRo4ẳ<H7!project_euler/problem_074/sol1.pyew^ ew^ \ ' h'z)Moyett}!project_euler/problem_074/sol2.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_075/__init__.pyerckerck\ vjJB 銷!X,,!project_euler/problem_075/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_076/__init__.pyeZ]eZ]\ Q`~ajXel !project_euler/problem_076/sol1.pyeZ]eZ]\ ⛲CK)wZS%project_euler/problem_077/__init__.pyew^ ew^ \ ) N]x!project_euler/problem_077/sol1.pyeZ]eZ]\ +⛲CK)wZS%project_euler/problem_080/__init__.pyew^ ew^ \ (*iEۊxN)F̼!project_euler/problem_080/sol1.pyeZ]eZ]\ .⛲CK)wZS%project_euler/problem_081/__init__.pyeZ]eZ]\ /zIS"A6IƳ4'˜$project_euler/problem_081/matrix.txtew^ ew^ \ 쯡C;3+e= !project_euler/problem_081/sol1.pyeZZ\eZZ\\ 7⛲CK)wZS%project_euler/problem_085/__init__.pyew^ ew^ \ tk4]/!project_euler/problem_085/sol1.pyeZZ\eZZ\\ :⛲CK)wZS%project_euler/problem_086/__init__.pyeu$eu$\  nkZ1Yֲ4+u!project_euler/problem_086/sol1.pyeZZ\eZZ\\ =⛲CK)wZS%project_euler/problem_087/__init__.pyeZZ\eZZ\\ >DH'&u!project_euler/problem_087/sol1.pyeZZ\eZZ\\ @y-`H,oRbQ%project_euler/problem_089/__init__.pyeZZ\eZZ\\ A!B̩-΀⡺K}1project_euler/problem_089/numeralcleanup_test.txteZZ\eZZ\\ B&yPe5Z[h;=kDL>(project_euler/problem_089/p089_roman.txtew^ ew^ \  X*WYw[M%!project_euler/problem_089/sol1.pyeZZ\eZZ\\ E⛲CK)wZS%project_euler/problem_091/__init__.pyeZZ\eZZ\\ Fllp"ELTm26s!project_euler/problem_091/sol1.pyeZZ\eZZ\\ Ny-`H,oRbQ%project_euler/problem_097/__init__.pyeu$eu$\ . @y=%[!;2!project_euler/problem_097/sol1.pyeZZ\eZZ\\ Q⛲CK)wZS%project_euler/problem_099/__init__.pyeZZ\eZZ\\ R6=";&q \ބ &project_euler/problem_099/base_exp.txtew^ ew^ \ -舑.rb=m <Y!project_euler/problem_099/sol1.pyeZZ\eZZ\\ X⛲CK)wZS%project_euler/problem_101/__init__.pyew^ ew^ \ . c |Յ͒MzD!project_euler/problem_101/sol1.pyeZZ\eZZ\\ [⛲CK)wZS%project_euler/problem_102/__init__.pyeZZ\eZZ\\ \g?Ay,@Dr,project_euler/problem_102/p102_triangles.txtew^ ew^ \  QrfVΏwHֈ 7h6!project_euler/problem_102/sol1.pyeZZ\eZZ\\ ^7\e ,project_euler/problem_102/test_triangles.txteZZ\eZZ\\ c⛲CK)wZS%project_euler/problem_107/__init__.pyeZZ\eZZ\\ d6+hꋐ:f^X*project_euler/problem_107/p107_network.txtew^ ew^ \ IvPm/%!project_euler/problem_107/sol1.pyeZZ\eZZ\\ fzW ʺd**b})*project_euler/problem_107/test_network.txtenfJenfJ\ ⛲CK)wZS%project_euler/problem_109/__init__.pyeu ͙eu ͙\  1ꟙ,L2!project_euler/problem_109/sol1.pyeZZ\eZZ\\ k⛲CK)wZS%project_euler/problem_112/__init__.pyew^ ew^ \ 3L iBXsWUL!project_euler/problem_112/sol1.pyeZZ\eZZ\\ n⛲CK)wZS%project_euler/problem_113/__init__.pyeu ͙eu ͙\ gPI:)#UT!project_euler/problem_113/sol1.pyeZZ\eZZ\\ }⛲CK)wZS%project_euler/problem_119/__init__.pyew^ ew^ \ 4:B_x?+Thn!project_euler/problem_119/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_120/__init__.pyeZZ\eZZ\\ :h!!E`qU?dS8!project_euler/problem_120/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_123/__init__.pyew^ ew^ \ 5 IAO}BeiV!project_euler/problem_123/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_125/__init__.pyeu$eu$\  S[g}g%MCw!project_euler/problem_125/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_129/__init__.pyeZZ\eZZ\\ .:'-iLB!project_euler/problem_129/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_135/__init__.pyeq%!#eq%!#\ 9Ehi)q!project_euler/problem_135/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_173/__init__.pyeu$eu$\ 9C~?cr})!project_euler/problem_173/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_174/__init__.pyeZZ\eZZ\\ %ZekPO^7i2r !project_euler/problem_174/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_180/__init__.pyew^ ew^ \ }a.p(O#<ş@P!project_euler/problem_180/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_188/__init__.pyew^ ew^ \ / ds6 S=c!!project_euler/problem_188/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_191/__init__.pyew^ ew^ \ 3 y82[6;ˆɣ94H!project_euler/problem_191/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_203/__init__.pyew^ ew^ \"{Gm1Q e?_rIT!project_euler/problem_203/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_206/__init__.pyeZZ\eZZ\\ +2wp9e!project_euler/problem_206/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_207/__init__.pyew^ ew^ \ @ $TyP&`K!project_euler/problem_207/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_234/__init__.pyeu$eu$\  ud-%$'bQI-!project_euler/problem_234/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_301/__init__.pyeu$eu$\ -4@Fȳ])-u!project_euler/problem_301/sol1.pyeZZ\eZZ\\ ⛲CK)wZS%project_euler/problem_551/__init__.pyew^ ew^ \ Gqfm9~1!project_euler/problem_551/sol1.pyeu ͙eu ͙\ xHy'0[@Un^ pytest.inieu ͙eu ͙\ uB=43d&<=ll quantum/README.mdeZZ\eZZ\\ ⛲CK)wZSquantum/__init__.pyeu$eu$\ N0Nn0׽i<ZcRquantum/deutsch_jozsa.pyeu ͙eu ͙\  J@Ki:7}}I1quantum/half_adder.pyeu ͙eu ͙\ Yx! YjLE?quantum/not_gate.pyeu ͙eu ͙\ x='q6"P^|[M<Xquantum/quantum_entanglement.pyexQ6K`exQ6K`\  ]emfV^iûquantum/ripple_adder_classic.pyeu ͙eu ͙\ 4!yU()[2~R uquantum/single_qubit_measure.pyexQ6K`exQ6K`\#4FVqxFrequirements.txteZZ\eZZ\\ ⛲CK)wZSscheduling/__init__.pyew^ ew^ \  9U(_'ʹЕ%scheduling/first_come_first_served.pyew^ ew^ \ Jy0e!3scheduling/round_robin.pyew^ ew^ \ t}j#Y O| scheduling/shortest_job_first.pyeZZ\eZZ\\ ⛲CK)wZSscripts/__init__.pyeuL oeuL o\ HzKäX4CDŁd}bscripts/build_directory_md.pyexQ6K`exQ6K`\ ,CWDj^׷Z7"scripts/project_euler_answers.jsonexQ6K`exQ6K`\ "_Agv3j`$Tscripts/validate_filenames.pyexQ6K`exQ6K`\ S N1|r?7cscripts/validate_solutions.pyeZ[eZ[\ ⛲CK)wZSsearches/__init__.pyew^ ew^ \#5<,0I!3EAcQVsearches/binary_search.pyeZ[eZ[\ hƅnEE_5^ searches/double_linear_search.pyeZ[eZ[\ H>L I(ۂ*searches/double_linear_search_recursion.pyew^ ew^ \  ̙JDeEmsearches/fibonacci_search.pyexQ6K`exQ6K`\ pb.N~.T>&oהu8searches/hill_climbing.pyeu ͙eu ͙\ /ߕeEx" } searches/interpolation_search.pyeqe'eqe'\ 1elUñ=y}tsearches/jump_search.pyeq{*Meq{*M\  YwpN6zkWq searches/linear_search.pyeZ[eZ[\ ^ތMj~ lsearches/quick_select.pyeZ[eZ[\ iϟ5\V6%ݚy-<"searches/sentinel_linear_search.pyeu ͙eu ͙\ C5FCJ<] searches/simple_binary_search.pyeu}eu}\ n*wHl}B-5searches/simulated_annealing.pyeu ͙eu ͙\ J*D$=$k! searches/tabu_search.pyeZ[eZ[\ FbzEv;searches/tabu_test_data.txtew^ ]ew^ ]\ qI"̹fp`_b?~searches/ternary_search.pyeZ[eZ[\ ⛲CK)wZSsorts/__init__.pyew^ ]ew^ ]\ 7gB#@sorts/bead_sort.pyew^ ]ew^ ]\  >^SHu$6sorts/bitonic_sort.pyer-; er-; \ a/ rh nNڤsorts/bogo_sort.pyeu ͙eu ͙\ *\|}p[j2sorts/bubble_sort.pyew^ ]ew^ ]\ gtߩFzWsorts/bucket_sort.pyeo WYeo WY\.81h*Ϙ ;+?#ͼsorts/cocktail_shaker_sort.pyer-; er-; \ ;ǏOHl ]sorts/comb_sort.pyer-; er-; \ ܉.D-̝Ŗ(ȅ|sorts/counting_sort.pyeqK9߬OeqK9߬O\ ߀o@Dy+`c} RMsorts/cycle_sort.pyewWewW\ ᆂ|~|1sorts/double_sort.pyeuQ#euQ#\ g'z O 'v*lsorts/external_sort.pyeZ[eZ[\ l&bdKT%jsorts/gnome_sort.pyeZ[eZ[\ Mʇ؜!1_@$M:FLbgRsorts/heap_sort.pyeqK9߬OeqK9߬O\ m[`ә,#>0bJ Bsorts/insertion_sort.pyeo WYeo WY\ IdZ۷|UCsorts/intro_sort.pyeuL oeuL o\ B^ڹFCҩpsorts/iterative_merge_sort.pyeu$eu$\ sqJ<\-]sorts/merge_insertion_sort.pyeu ͙eu ͙\ TM2ms6oz)Tsorts/merge_sort.pyeZ[eZ[\ [ACHW)sorts/natural_sort.pyeu$eu$\ *wi|zL-'sorts/normal_distribution_quick_sort.mdeu ͙eu ͙\ ]Us7w.CWTsorts/odd_even_sort.pyeu ͙eu ͙\ K](A{mK#s (sorts/odd_even_transposition_parallel.pyew^ ]ew^ ]\ =xE9) T3/sorts/odd_even_transposition_single_threaded.pyeZ[eZ[\ Ds5;r@~&@>)Ksorts/pancake_sort.pyew^ ]ew^ ]\ Igy5xsorts/patience_sort.pyew^ ]ew^ ]\ =d8eaY+Gsorts/pigeon_sort.pyeZ[eZ[\ #PEL _S]0sorts/pigeonhole_sort.pyew^ ]ew^ ]\ oQ,MۂiĚsorts/quick_sort.pyeZ[eZ[\ % (md"L2 sorts/quick_sort_3_partition.pyew^ ]ew^ ]\ E' [yeVsorts/radix_sort.pyeu ͙eu ͙\ sp@U\p+t-sorts/random_normal_distribution_quicksort.pyeu ͙eu ͙\ N/*w!s  sorts/random_pivot_quick_sort.pyeo`hA.eo`hA.\ 1Y>[n4}98> K'sorts/recursive_bubble_sort.pyew^ ]ew^ ]\ 7Jw{%;!sorts/recursive_insertion_sort.pyer-; er-; \ Š~s~ZGJV /sorts/recursive_quick_sort.pyeq%!#eq%!#\ Lpp "EVp,yVsorts/selection_sort.pyeq%!#eq%!#\ p)Ѽ w`'bsorts/shell_sort.pyew^ ]ew^ ]\ SUNPN~Fbsorts/slowsort.pyer-; er-; \ [ޙzv<u2zs>j8sorts/stooge_sort.pyes^es^\ \5i?/sorts/strand_sort.pyer-; er-; \ R_L1~ 7W&xJsorts/tim_sort.pyew^ ]ew^ ]\ N/|w3H]{sorts/topological_sort.pyeu ͙eu ͙\ kEE f!Dg`D3sorts/tree_sort.pyeZ[eZ[\ 3D/zX+,?d}sorts/unknown_sort.pyeZ[eZ[\ 4<`oV>]暗sorts/wiggle_sort.pyeZ[eZ[\ 6⛲CK)wZSstrings/__init__.pyewsDewsD\ ƹYՌ2My?LeBustrings/aho_corasick.pyew^ ]ew^ ]\  aN11F;9strings/boyer_moore_search.pyew} ew} \Ň~&4TmL1strings/can_string_be_rearranged_as_palindrome.pyeqeq\ Mc`:~-s9d{͠ʂstrings/capitalize.pyew Kew K\M0 ]H֠+ Sbstrings/check_anagrams.pyexQ6K`exQ6K`\ xi[$B4Sstrings/check_pangram.pyeu ͙eu ͙\ Gv)5ȾQestrings/is_palindrome.pyeZZeZZ\ SM:׾8(Z>strings/jaro_winkler.pyew^ ]ew^ ]\ I7`AlG#ög~strings/knuth_morris_pratt.pyew} ew} \ T !=K}mvstrings/levenshtein_distance.pyexQ6K`exQ6K`\ s}o vmstrings/lower.pyewsDewsD\ Tvh9?XxH;qastrings/manacher.pyewsDewsD\ 鐪gAkS'aW%strings/min_cost_string_conversion.pyew:vew:v\ P&A!ցsV_/vstrings/naive_string_search.pyew^ ]ew^ ]\ RXm@?[$Q¤C7strings/prefix_function.pyeqK9߬OeqK9߬O\  ,av =4?'strings/rabin_karp.pyeZZeZZ\ `Z'Ro g=Me=SMstrings/remove_duplicate.pyeq%!#eq%!#\ \*|%[\W/Ustrings/reverse_letters.pyeZZeZZ\ bVPL \a~Gstrings/reverse_words.pyeZZeZZ\ db+@25Ep$3t:strings/split.pyew^ ]ew^ ]\ KRUgpvM= strings/swap_case.pyepNepN\ V^@`ަwbstrings/upper.pyew} ew} \ Ka.ߤCt摨sstrings/word_occurrence.pyeu$eu$\  #~H s櫛SLxLstrings/z_function.pyexQ6K`exQ6K`\ ,⛲CK)wZStraversals/__init__.pyexQ6K`exQ6K`\ -#4GbIWb9m $traversals/binary_tree_traversals.pyeZXeZX\ r⛲CK)wZSweb_programming/__init__.pyeZXeZX\ s̗~~Ag^ RVweb_programming/co2_emission.pyexQ6K`exQ6K`\ 0+.(v hs(web_programming/covid_stats_via_xpath.pyeu ͙eu ͙\ :?;\~A(S@/b-'web_programming/crawl_google_results.pyeu ͙eu ͙\ ##8 d0n9|0web_programming/crawl_google_scholar_citation.pyexQ6K`exQ6K`\ /j*Ux^{gG{v%web_programming/currency_converter.pyeqZ3eqZ3\ DNQٔ]v!n'٧&web_programming/current_stock_price.pyeu ͙eu ͙\ )C8G?1"n'}H"web_programming/current_weather.pyeZXeZX\ zY$NpI* ӕ_Z"web_programming/daily_horoscope.pyexQ6K`exQ6K`\  St#j@CWQh3,"web_programming/emails_from_url.pyeZXeZX\ ~,{i2ޡJU߷>!web_programming/fetch_bbc_news.pyew^ ]ew^ ]\ `k0 gr $web_programming/fetch_github_info.pyeuL oeuL o\ l!quoȃsweb_programming/fetch_jobs.pyeZXeZX\ KnV)Mw5b .web_programming/get_imdb_top_250_movies_csv.pyewWewW\ _fKfkweb_programming/get_imdbtop.pyer-; er-; \ )E6%zN~01¥~ $web_programming/instagram_crawler.pyeo WYeo WY\ !gM}fi(y(! web_programming/instagram_pic.pyeZXeZX\ /$<PQ=1z-/x"web_programming/instagram_video.pyeZXeZX\  /G/*-`{~lZ B)web_programming/recaptcha_verification.pyeqeq\ ZX~ޗxa3 web_programming/slack_message.pyeZXeZX\ [-|x-T}wY)web_programming/test_fetch_github_info.pyeq3eq3\ m8 '`&^?&web_programming/world_covid19_stats.pyTREEs971 40 Ӄ)/>ɲE'|maths106 2 ,b\ة x$7images2 0 )|A(U!series6 0 VpN`c,wother41 0 gYBy`o.1?{ĈSZsorts46 0 w4\IcB$p cagraphs49 1 }Pm4U*=Uİ|QǾtests2 0 H1SUw0IPhashes9 0 w'l-S^ 2ބmatrix13 1 $\]Vz$*Zdݐtests3 0 t&G+צY*.github7 1 Mr߾m#25workflows4 0 rfs ů72Dc9ciphers40 0 `@pjVğ}2Pvgeodesy3 0 `YgZcL0=2;Equantum8 0 JsH_pzv7Fscripts5 0 #GDq€C)strings25 0 *Κ{lo graphics5 0 S-w1p<w:9knapsack7 1 O6DǴVtests3 0 -v>g 0searches16 0 h7Jl.%aU=blockchain4 0 8ze[|\[gUscheduling4 0 M`cW!@A}ϞEtraversals2 0 1ʺф@iZcompression13 1 lqegP(1image_data7 0 broe\x-.`r`conversions15 0 x]T d5+Belectronics2 0 /xâ$‹U#fuzzy_logic2 0 ß05+7bI|backtracking13 0 LLrufile_transfer6 1 @RHD=Û9hsjNktests2 0 ָ)0<kཫproject_euler266 104 f Z_4n nproblem_0018 0 L @%z A8problem_0026 0 K'3Ϋ:U(])fproblem_0034 0 S=7s%~(Pُqproblem_0043 0 IXk7P͸|problem_0053 0 btձ1G&Tqoproblem_0065 0 +"Q(HΗY,`problem_0074 0 pK]Խ85MV)Zproblem_0084 0 Ap׫EDå problem_0094 0 &-QKD^problem_0104 0 WL<CZq<:]problem_0114 0 ~nJproblem_0123 0 1Dw">d_[.hproblem_0133 0 Gyh/Q<e`Wproblem_0143 0 8a3eHproblem_0152 0 ;QYX;Q[lrR׫problem_0163 0 WSm*problem_0172 0 y=,y)шOt" Hbproblem_0183 0 %M}3z!$~problem_0192 0 >̯W d@ٸt7problem_0205 0 kV<"tQ;Ul&problem_0212 0 ֍5TUEL;3{problem_0224 0 sK[媘M problem_0232 0 G /$K_c+xZ problem_0242 0 t S'Kj"1Rȥ problem_0254 0 k+=ւvproblem_0262 0 xd ^+4~Cproblem_0272 0 *QQ%&iqproblem_0282 0 I#+2=1c<problem_0292 0 %*՜4<oproblem_0302 0 :syJU05tproblem_0313 0 cʸ"@+%problem_0322 0 sjce6^YDk%Y aproblem_0332 0 [ŋ$ڇmGv$Iqproblem_0342 0 Rݝ}]!s fproblem_0352 0 hr.A%3C"{problem_0362 0 <,sybN>Cproblem_0372 0 qeyeEVproblem_0382 0 5l?o&>_problem_0392 0 -} -/ny]problem_0402 0 P *uСXA?(problem_0412 0 φ/e37problem_0423 0 SfUghG+eproblem_0432 0 $"Rmr딠URproblem_0442 0 PޣR(V-ngproblem_0452 0 IEzd4EȻ0\problem_0462 0 #|~8iz^mproblem_0472 0 L ifJ%Q@{Eproblem_0482 0 %ThW +Wwproblem_0492 0 9OIi[䟐-rŇp98problem_0502 0 E[.CF)ORtoproblem_0512 0 ȀC!yɀ@ýproblem_0522 0 چ E_uproblem_0532 0 \vET-" E^problem_0544 0 pGk]0·#ݫzU96problem_0552 0 Ggmd~GGw,B_problem_0562 0 jS[``[mdproblem_0572 0 | K^κV-problem_0582 0 곋)cw= nWproblem_0594 0 (Kz`J&^(lproblem_0622 0 K !|o^ucCrxproblem_0632 0 >cgD̲ Apnproblem_0642 0 #EYR)problem_0652 0 Bd8 Q9problem_0673 0 'IWfK Reproblem_0692 0 1`e problem_0702 0 |>(TsLproblem_0712 0 h."y۾Nf;awproblem_0723 0 vnۢ=SQsI?problem_0743 0 kORO$+37problem_0752 0 a2p[$sproblem_0762 0 v= txZْqproblem_0772 0 7t 4J2problem_0802 0 w k]7G*;/1/problem_0813 0 !N_;#[>O$problem_0852 0 ̥\ҡ)>*O problem_0862 0 "i]rRproblem_0872 0 WRg\:3iproblem_0894 0 JPih5 problem_0912 0 h3c=6}LӞbproblem_0972 0 U_t{ږI6problem_0993 0 SxI>Um\,ZSnproblem_1012 0 jki^ՅGS%problem_1024 0 (zUU2vv] problem_1074 0 ]T.bX;(I&problem_1092 0 (?G w<*e<!problem_1122 0 tt@:ELUh problem_1132 0 TQAZW7㛨problem_1192 0 ? NR ^>vproblem_1202 0 2)X')0c6problem_1232 0 m#T@r֤V+fproblem_1252 0 :0pᝀB8ߨmSzproblem_1292 0 f//]@V76problem_1352 0 {\By/Iproblem_1732 0 :ԣmF:}Yproblem_1742 0 z0Y$A۾RtV8problem_1802 0 ,raxx Aproblem_1882 0 @ ڱ0Vz|":%2problem_1912 0 :ӂtwhG .,Fproblem_2032 0 U:GxuԍUb:ߡo{problem_2062 0 m* ptP[problem_2072 0 h7)8CT/3$~problem_2342 0 y\F} [qAZV problem_3012 0 #(Tͺ)}e,|aproblem_5512 0 ZfhIkzQ2Ay8tlinear_algebra10 1  K'}9Gsrc8 0 껰Q߱:w&E]^%neural_network7 0 6?#4Lf,boolean_algebra2 0 (uG{` ?rcomputer_vision4 0 :jfb$O4data_structures72 8 @Q u~7%UBheap8 0 (I,Tj Utrie2 0 kvvL%^>aM1queue7 0 Z@[t|^U{WOstacks13 0 9K2{Rחhashing7 1 ̸o`$m,2number_theory2 0 cأ/<ӥbinary_tree17 0 &ߣJ>3D,llinked_list14 0 Jyl̬M˻q disjoint_set3 0 :s#j[networking_flow3 0 6ѫ. g8{a?!web_programming22 0 )ncQz+N@ivbit_manipulation12 0 ET*h8 f64!Umachine_learning28 2 rH$k"`ʿ]lstm3 0 ]xc0T29nforecasting3 0 j(-l^[EQecellular_automata4 0 UşPY2G[dgenetic_algorithm2 0 cukd*{^va/divide_and_conquer13 0 .*8vSq_ܠarithmetic_analysis13 1 KDƳE^I<mimage_data3 0 'PZbwұ-_dynamic_programming31 0 fS "O9d۪digital_image_processing30 7 n 7nTWɧ&rlYresize2 0 -$?T =JQJifilters6 0 Aď'@ ߗOrotation2 0 l}avw=tdithering2 0 LHl(vKpŒ9image_data3 0 Lu(X,aӕm=edge_detection2 0 wfp8ب8:ޓ<histogram_equalization6 2 =a7Ȥtk.'Uimage_data2 0 ‰דM>+V\output_data2 0 yMmA~Eiѯb8t
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
def max_subarray_sum(nums: list) -> int: """ >>> max_subarray_sum([6 , 9, -1, 3, -7, -5, 10]) 17 """ if not nums: return 0 n = len(nums) res, s, s_pre = nums[0], nums[0], nums[0] for i in range(1, n): s = max(nums[i], s_pre + nums[i]) s_pre = s res = max(res, s) return res if __name__ == "__main__": nums = [6, 9, -1, 3, -7, -5, 10] print(max_subarray_sum(nums))
def max_subarray_sum(nums: list) -> int: """ >>> max_subarray_sum([6 , 9, -1, 3, -7, -5, 10]) 17 """ if not nums: return 0 n = len(nums) res, s, s_pre = nums[0], nums[0], nums[0] for i in range(1, n): s = max(nums[i], s_pre + nums[i]) s_pre = s res = max(res, s) return res if __name__ == "__main__": nums = [6, 9, -1, 3, -7, -5, 10] print(max_subarray_sum(nums))
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Combinatoric selections Problem 53 There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 In combinatorics, we use the notation, 5C3 = 10. In general, nCr = n!/(r!(n−r)!),where r ≤ n, n! = n×(n−1)×...×3×2×1, and 0! = 1. It is not until n = 23, that a value exceeds one-million: 23C10 = 1144066. How many, not necessarily distinct, values of nCr, for 1 ≤ n ≤ 100, are greater than one-million? """ from math import factorial def combinations(n, r): return factorial(n) / (factorial(r) * factorial(n - r)) def solution(): """Returns the number of values of nCr, for 1 ≤ n ≤ 100, are greater than one-million >>> solution() 4075 """ total = 0 for i in range(1, 101): for j in range(1, i + 1): if combinations(i, j) > 1e6: total += 1 return total if __name__ == "__main__": print(solution())
""" Combinatoric selections Problem 53 There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 In combinatorics, we use the notation, 5C3 = 10. In general, nCr = n!/(r!(n−r)!),where r ≤ n, n! = n×(n−1)×...×3×2×1, and 0! = 1. It is not until n = 23, that a value exceeds one-million: 23C10 = 1144066. How many, not necessarily distinct, values of nCr, for 1 ≤ n ≤ 100, are greater than one-million? """ from math import factorial def combinations(n, r): return factorial(n) / (factorial(r) * factorial(n - r)) def solution(): """Returns the number of values of nCr, for 1 ≤ n ≤ 100, are greater than one-million >>> solution() 4075 """ total = 0 for i in range(1, 101): for j in range(1, i + 1): if combinations(i, j) > 1e6: total += 1 return total if __name__ == "__main__": print(solution())
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" The number of partitions of a number n into at least k parts equals the number of partitions into exactly k parts plus the number of partitions into at least k-1 parts. Subtracting 1 from each part of a partition of n into k parts gives a partition of n-k into k parts. These two facts together are used for this algorithm. """ def partition(m): memo = [[0 for _ in range(m)] for _ in range(m + 1)] for i in range(m + 1): memo[i][0] = 1 for n in range(m + 1): for k in range(1, m): memo[n][k] += memo[n][k - 1] if n - k > 0: memo[n][k] += memo[n - k - 1][k] return memo[m][m - 1] if __name__ == "__main__": import sys if len(sys.argv) == 1: try: n = int(input("Enter a number: ").strip()) print(partition(n)) except ValueError: print("Please enter a number.") else: try: n = int(sys.argv[1]) print(partition(n)) except ValueError: print("Please pass a number.")
""" The number of partitions of a number n into at least k parts equals the number of partitions into exactly k parts plus the number of partitions into at least k-1 parts. Subtracting 1 from each part of a partition of n into k parts gives a partition of n-k into k parts. These two facts together are used for this algorithm. """ def partition(m): memo = [[0 for _ in range(m)] for _ in range(m + 1)] for i in range(m + 1): memo[i][0] = 1 for n in range(m + 1): for k in range(1, m): memo[n][k] += memo[n][k - 1] if n - k > 0: memo[n][k] += memo[n - k - 1][k] return memo[m][m - 1] if __name__ == "__main__": import sys if len(sys.argv) == 1: try: n = int(input("Enter a number: ").strip()) print(partition(n)) except ValueError: print("Please enter a number.") else: try: n = int(sys.argv[1]) print(partition(n)) except ValueError: print("Please pass a number.")
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Changing contrast with PIL This algorithm is used in https://noivce.pythonanywhere.com/ Python web app. python/black: True flake8 : True """ from PIL import Image def change_contrast(img: Image, level: int) -> Image: """ Function to change contrast """ factor = (259 * (level + 255)) / (255 * (259 - level)) def contrast(c: int) -> int: """ Fundamental Transformation/Operation that'll be performed on every bit. """ return int(128 + factor * (c - 128)) return img.point(contrast) if __name__ == "__main__": # Load image with Image.open("image_data/lena.jpg") as img: # Change contrast to 170 cont_img = change_contrast(img, 170) cont_img.save("image_data/lena_high_contrast.png", format="png")
""" Changing contrast with PIL This algorithm is used in https://noivce.pythonanywhere.com/ Python web app. python/black: True flake8 : True """ from PIL import Image def change_contrast(img: Image, level: int) -> Image: """ Function to change contrast """ factor = (259 * (level + 255)) / (255 * (259 - level)) def contrast(c: int) -> int: """ Fundamental Transformation/Operation that'll be performed on every bit. """ return int(128 + factor * (c - 128)) return img.point(contrast) if __name__ == "__main__": # Load image with Image.open("image_data/lena.jpg") as img: # Change contrast to 170 cont_img = change_contrast(img, 170) cont_img.save("image_data/lena_high_contrast.png", format="png")
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" This is a pure Python implementation of the Geometric Series algorithm https://en.wikipedia.org/wiki/Geometric_series Run the doctests with the following command: python3 -m doctest -v geometric_series.py or python -m doctest -v geometric_series.py For manual testing run: python3 geometric_series.py """ def geometric_series(nth_term: int, start_term_a: int, common_ratio_r: int) -> list: """Pure Python implementation of Geometric Series algorithm :param nth_term: The last term (nth term of Geometric Series) :param start_term_a : The first term of Geometric Series :param common_ratio_r : The common ratio between all the terms :return: The Geometric Series starting from first term a and multiple of common ration with first term with increase in power till last term (nth term) Examples: >>> geometric_series(4, 2, 2) [2, '4.0', '8.0', '16.0'] >>> geometric_series(4.0, 2.0, 2.0) [2.0, '4.0', '8.0', '16.0'] >>> geometric_series(4.1, 2.1, 2.1) [2.1, '4.41', '9.261000000000001', '19.448100000000004'] >>> geometric_series(4, 2, -2) [2, '-4.0', '8.0', '-16.0'] >>> geometric_series(4, -2, 2) [-2, '-4.0', '-8.0', '-16.0'] >>> geometric_series(-4, 2, 2) [] >>> geometric_series(0, 100, 500) [] >>> geometric_series(1, 1, 1) [1] >>> geometric_series(0, 0, 0) [] """ if "" in (nth_term, start_term_a, common_ratio_r): return "" series = [] power = 1 multiple = common_ratio_r for _ in range(int(nth_term)): if series == []: series.append(start_term_a) else: power += 1 series.append(str(float(start_term_a) * float(multiple))) multiple = pow(float(common_ratio_r), power) return series if __name__ == "__main__": nth_term = input("Enter the last number (n term) of the Geometric Series") start_term_a = input("Enter the starting term (a) of the Geometric Series") common_ratio_r = input( "Enter the common ratio between two terms (r) of the Geometric Series" ) print("Formula of Geometric Series => a + ar + ar^2 ... +ar^n") print(geometric_series(nth_term, start_term_a, common_ratio_r))
""" This is a pure Python implementation of the Geometric Series algorithm https://en.wikipedia.org/wiki/Geometric_series Run the doctests with the following command: python3 -m doctest -v geometric_series.py or python -m doctest -v geometric_series.py For manual testing run: python3 geometric_series.py """ def geometric_series(nth_term: int, start_term_a: int, common_ratio_r: int) -> list: """Pure Python implementation of Geometric Series algorithm :param nth_term: The last term (nth term of Geometric Series) :param start_term_a : The first term of Geometric Series :param common_ratio_r : The common ratio between all the terms :return: The Geometric Series starting from first term a and multiple of common ration with first term with increase in power till last term (nth term) Examples: >>> geometric_series(4, 2, 2) [2, '4.0', '8.0', '16.0'] >>> geometric_series(4.0, 2.0, 2.0) [2.0, '4.0', '8.0', '16.0'] >>> geometric_series(4.1, 2.1, 2.1) [2.1, '4.41', '9.261000000000001', '19.448100000000004'] >>> geometric_series(4, 2, -2) [2, '-4.0', '8.0', '-16.0'] >>> geometric_series(4, -2, 2) [-2, '-4.0', '-8.0', '-16.0'] >>> geometric_series(-4, 2, 2) [] >>> geometric_series(0, 100, 500) [] >>> geometric_series(1, 1, 1) [1] >>> geometric_series(0, 0, 0) [] """ if "" in (nth_term, start_term_a, common_ratio_r): return "" series = [] power = 1 multiple = common_ratio_r for _ in range(int(nth_term)): if series == []: series.append(start_term_a) else: power += 1 series.append(str(float(start_term_a) * float(multiple))) multiple = pow(float(common_ratio_r), power) return series if __name__ == "__main__": nth_term = input("Enter the last number (n term) of the Geometric Series") start_term_a = input("Enter the starting term (a) of the Geometric Series") common_ratio_r = input( "Enter the common ratio between two terms (r) of the Geometric Series" ) print("Formula of Geometric Series => a + ar + ar^2 ... +ar^n") print(geometric_series(nth_term, start_term_a, common_ratio_r))
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
from __future__ import annotations from collections import Counter from random import random class MarkovChainGraphUndirectedUnweighted: """ Undirected Unweighted Graph for running Markov Chain Algorithm """ def __init__(self): self.connections = {} def add_node(self, node: str) -> None: self.connections[node] = {} def add_transition_probability( self, node1: str, node2: str, probability: float ) -> None: if node1 not in self.connections: self.add_node(node1) if node2 not in self.connections: self.add_node(node2) self.connections[node1][node2] = probability def get_nodes(self) -> list[str]: return list(self.connections) def transition(self, node: str) -> str: current_probability = 0 random_value = random() for dest in self.connections[node]: current_probability += self.connections[node][dest] if current_probability > random_value: return dest def get_transitions( start: str, transitions: list[tuple[str, str, float]], steps: int ) -> dict[str, int]: """ Running Markov Chain algorithm and calculating the number of times each node is visited >>> transitions = [ ... ('a', 'a', 0.9), ... ('a', 'b', 0.075), ... ('a', 'c', 0.025), ... ('b', 'a', 0.15), ... ('b', 'b', 0.8), ... ('b', 'c', 0.05), ... ('c', 'a', 0.25), ... ('c', 'b', 0.25), ... ('c', 'c', 0.5) ... ] >>> result = get_transitions('a', transitions, 5000) >>> result['a'] > result['b'] > result['c'] True """ graph = MarkovChainGraphUndirectedUnweighted() for node1, node2, probability in transitions: graph.add_transition_probability(node1, node2, probability) visited = Counter(graph.get_nodes()) node = start for _ in range(steps): node = graph.transition(node) visited[node] += 1 return visited if __name__ == "__main__": import doctest doctest.testmod()
from __future__ import annotations from collections import Counter from random import random class MarkovChainGraphUndirectedUnweighted: """ Undirected Unweighted Graph for running Markov Chain Algorithm """ def __init__(self): self.connections = {} def add_node(self, node: str) -> None: self.connections[node] = {} def add_transition_probability( self, node1: str, node2: str, probability: float ) -> None: if node1 not in self.connections: self.add_node(node1) if node2 not in self.connections: self.add_node(node2) self.connections[node1][node2] = probability def get_nodes(self) -> list[str]: return list(self.connections) def transition(self, node: str) -> str: current_probability = 0 random_value = random() for dest in self.connections[node]: current_probability += self.connections[node][dest] if current_probability > random_value: return dest def get_transitions( start: str, transitions: list[tuple[str, str, float]], steps: int ) -> dict[str, int]: """ Running Markov Chain algorithm and calculating the number of times each node is visited >>> transitions = [ ... ('a', 'a', 0.9), ... ('a', 'b', 0.075), ... ('a', 'c', 0.025), ... ('b', 'a', 0.15), ... ('b', 'b', 0.8), ... ('b', 'c', 0.05), ... ('c', 'a', 0.25), ... ('c', 'b', 0.25), ... ('c', 'c', 0.5) ... ] >>> result = get_transitions('a', transitions, 5000) >>> result['a'] > result['b'] > result['c'] True """ graph = MarkovChainGraphUndirectedUnweighted() for node1, node2, probability in transitions: graph.add_transition_probability(node1, node2, probability) visited = Counter(graph.get_nodes()) node = start for _ in range(steps): node = graph.transition(node) visited[node] += 1 return visited if __name__ == "__main__": import doctest doctest.testmod()
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
import tensorflow as tf from random import shuffle from numpy import array def TFKMeansCluster(vectors, noofclusters): """ K-Means Clustering using TensorFlow. 'vectors' should be a n*k 2-D NumPy array, where n is the number of vectors of dimensionality k. 'noofclusters' should be an integer. """ noofclusters = int(noofclusters) assert noofclusters < len(vectors) # Find out the dimensionality dim = len(vectors[0]) # Will help select random centroids from among the available vectors vector_indices = list(range(len(vectors))) shuffle(vector_indices) # GRAPH OF COMPUTATION # We initialize a new graph and set it as the default during each run # of this algorithm. This ensures that as this function is called # multiple times, the default graph doesn't keep getting crowded with # unused ops and Variables from previous function calls. graph = tf.Graph() with graph.as_default(): # SESSION OF COMPUTATION sess = tf.Session() ##CONSTRUCTING THE ELEMENTS OF COMPUTATION ##First lets ensure we have a Variable vector for each centroid, ##initialized to one of the vectors from the available data points centroids = [ tf.Variable(vectors[vector_indices[i]]) for i in range(noofclusters) ] ##These nodes will assign the centroid Variables the appropriate ##values centroid_value = tf.placeholder("float64", [dim]) cent_assigns = [] for centroid in centroids: cent_assigns.append(tf.assign(centroid, centroid_value)) ##Variables for cluster assignments of individual vectors(initialized ##to 0 at first) assignments = [tf.Variable(0) for i in range(len(vectors))] ##These nodes will assign an assignment Variable the appropriate ##value assignment_value = tf.placeholder("int32") cluster_assigns = [] for assignment in assignments: cluster_assigns.append(tf.assign(assignment, assignment_value)) ##Now lets construct the node that will compute the mean # The placeholder for the input mean_input = tf.placeholder("float", [None, dim]) # The Node/op takes the input and computes a mean along the 0th # dimension, i.e. the list of input vectors mean_op = tf.reduce_mean(mean_input, 0) ##Node for computing Euclidean distances # Placeholders for input v1 = tf.placeholder("float", [dim]) v2 = tf.placeholder("float", [dim]) euclid_dist = tf.sqrt(tf.reduce_sum(tf.pow(tf.sub(v1, v2), 2))) ##This node will figure out which cluster to assign a vector to, ##based on Euclidean distances of the vector from the centroids. # Placeholder for input centroid_distances = tf.placeholder("float", [noofclusters]) cluster_assignment = tf.argmin(centroid_distances, 0) ##INITIALIZING STATE VARIABLES ##This will help initialization of all Variables defined with respect ##to the graph. The Variable-initializer should be defined after ##all the Variables have been constructed, so that each of them ##will be included in the initialization. init_op = tf.initialize_all_variables() # Initialize all variables sess.run(init_op) ##CLUSTERING ITERATIONS # Now perform the Expectation-Maximization steps of K-Means clustering # iterations. To keep things simple, we will only do a set number of # iterations, instead of using a Stopping Criterion. noofiterations = 100 for iteration_n in range(noofiterations): ##EXPECTATION STEP ##Based on the centroid locations till last iteration, compute ##the _expected_ centroid assignments. # Iterate over each vector for vector_n in range(len(vectors)): vect = vectors[vector_n] # Compute Euclidean distance between this vector and each # centroid. Remember that this list cannot be named #'centroid_distances', since that is the input to the # cluster assignment node. distances = [ sess.run(euclid_dist, feed_dict={v1: vect, v2: sess.run(centroid)}) for centroid in centroids ] # Now use the cluster assignment node, with the distances # as the input assignment = sess.run( cluster_assignment, feed_dict={centroid_distances: distances} ) # Now assign the value to the appropriate state variable sess.run( cluster_assigns[vector_n], feed_dict={assignment_value: assignment} ) ##MAXIMIZATION STEP # Based on the expected state computed from the Expectation Step, # compute the locations of the centroids so as to maximize the # overall objective of minimizing within-cluster Sum-of-Squares for cluster_n in range(noofclusters): # Collect all the vectors assigned to this cluster assigned_vects = [ vectors[i] for i in range(len(vectors)) if sess.run(assignments[i]) == cluster_n ] # Compute new centroid location new_location = sess.run( mean_op, feed_dict={mean_input: array(assigned_vects)} ) # Assign value to appropriate variable sess.run( cent_assigns[cluster_n], feed_dict={centroid_value: new_location} ) # Return centroids and assignments centroids = sess.run(centroids) assignments = sess.run(assignments) return centroids, assignments
import tensorflow as tf from random import shuffle from numpy import array def TFKMeansCluster(vectors, noofclusters): """ K-Means Clustering using TensorFlow. 'vectors' should be a n*k 2-D NumPy array, where n is the number of vectors of dimensionality k. 'noofclusters' should be an integer. """ noofclusters = int(noofclusters) assert noofclusters < len(vectors) # Find out the dimensionality dim = len(vectors[0]) # Will help select random centroids from among the available vectors vector_indices = list(range(len(vectors))) shuffle(vector_indices) # GRAPH OF COMPUTATION # We initialize a new graph and set it as the default during each run # of this algorithm. This ensures that as this function is called # multiple times, the default graph doesn't keep getting crowded with # unused ops and Variables from previous function calls. graph = tf.Graph() with graph.as_default(): # SESSION OF COMPUTATION sess = tf.Session() ##CONSTRUCTING THE ELEMENTS OF COMPUTATION ##First lets ensure we have a Variable vector for each centroid, ##initialized to one of the vectors from the available data points centroids = [ tf.Variable(vectors[vector_indices[i]]) for i in range(noofclusters) ] ##These nodes will assign the centroid Variables the appropriate ##values centroid_value = tf.placeholder("float64", [dim]) cent_assigns = [] for centroid in centroids: cent_assigns.append(tf.assign(centroid, centroid_value)) ##Variables for cluster assignments of individual vectors(initialized ##to 0 at first) assignments = [tf.Variable(0) for i in range(len(vectors))] ##These nodes will assign an assignment Variable the appropriate ##value assignment_value = tf.placeholder("int32") cluster_assigns = [] for assignment in assignments: cluster_assigns.append(tf.assign(assignment, assignment_value)) ##Now lets construct the node that will compute the mean # The placeholder for the input mean_input = tf.placeholder("float", [None, dim]) # The Node/op takes the input and computes a mean along the 0th # dimension, i.e. the list of input vectors mean_op = tf.reduce_mean(mean_input, 0) ##Node for computing Euclidean distances # Placeholders for input v1 = tf.placeholder("float", [dim]) v2 = tf.placeholder("float", [dim]) euclid_dist = tf.sqrt(tf.reduce_sum(tf.pow(tf.sub(v1, v2), 2))) ##This node will figure out which cluster to assign a vector to, ##based on Euclidean distances of the vector from the centroids. # Placeholder for input centroid_distances = tf.placeholder("float", [noofclusters]) cluster_assignment = tf.argmin(centroid_distances, 0) ##INITIALIZING STATE VARIABLES ##This will help initialization of all Variables defined with respect ##to the graph. The Variable-initializer should be defined after ##all the Variables have been constructed, so that each of them ##will be included in the initialization. init_op = tf.initialize_all_variables() # Initialize all variables sess.run(init_op) ##CLUSTERING ITERATIONS # Now perform the Expectation-Maximization steps of K-Means clustering # iterations. To keep things simple, we will only do a set number of # iterations, instead of using a Stopping Criterion. noofiterations = 100 for iteration_n in range(noofiterations): ##EXPECTATION STEP ##Based on the centroid locations till last iteration, compute ##the _expected_ centroid assignments. # Iterate over each vector for vector_n in range(len(vectors)): vect = vectors[vector_n] # Compute Euclidean distance between this vector and each # centroid. Remember that this list cannot be named #'centroid_distances', since that is the input to the # cluster assignment node. distances = [ sess.run(euclid_dist, feed_dict={v1: vect, v2: sess.run(centroid)}) for centroid in centroids ] # Now use the cluster assignment node, with the distances # as the input assignment = sess.run( cluster_assignment, feed_dict={centroid_distances: distances} ) # Now assign the value to the appropriate state variable sess.run( cluster_assigns[vector_n], feed_dict={assignment_value: assignment} ) ##MAXIMIZATION STEP # Based on the expected state computed from the Expectation Step, # compute the locations of the centroids so as to maximize the # overall objective of minimizing within-cluster Sum-of-Squares for cluster_n in range(noofclusters): # Collect all the vectors assigned to this cluster assigned_vects = [ vectors[i] for i in range(len(vectors)) if sess.run(assignments[i]) == cluster_n ] # Compute new centroid location new_location = sess.run( mean_op, feed_dict={mean_input: array(assigned_vects)} ) # Assign value to appropriate variable sess.run( cent_assigns[cluster_n], feed_dict={centroid_value: new_location} ) # Return centroids and assignments centroids = sess.run(centroids) assignments = sess.run(assignments) return centroids, assignments
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Project Euler Problem 56: https://projecteuler.net/problem=56 A googol (10^100) is a massive number: one followed by one-hundred zeros; 100^100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1. Considering natural numbers of the form, ab, where a, b < 100, what is the maximum digital sum? """ def solution(a: int = 100, b: int = 100) -> int: """ Considering natural numbers of the form, a**b, where a, b < 100, what is the maximum digital sum? :param a: :param b: :return: >>> solution(10,10) 45 >>> solution(100,100) 972 >>> solution(100,200) 1872 """ # RETURN the MAXIMUM from the list of SUMs of the list of INT converted from STR of # BASE raised to the POWER return max( [ sum([int(x) for x in str(base ** power)]) for base in range(a) for power in range(b) ] ) # Tests if __name__ == "__main__": import doctest doctest.testmod()
""" Project Euler Problem 56: https://projecteuler.net/problem=56 A googol (10^100) is a massive number: one followed by one-hundred zeros; 100^100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1. Considering natural numbers of the form, ab, where a, b < 100, what is the maximum digital sum? """ def solution(a: int = 100, b: int = 100) -> int: """ Considering natural numbers of the form, a**b, where a, b < 100, what is the maximum digital sum? :param a: :param b: :return: >>> solution(10,10) 45 >>> solution(100,100) 972 >>> solution(100,200) 1872 """ # RETURN the MAXIMUM from the list of SUMs of the list of INT converted from STR of # BASE raised to the POWER return max( [ sum([int(x) for x in str(base ** power)]) for base in range(a) for power in range(b) ] ) # Tests if __name__ == "__main__": import doctest doctest.testmod()
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
alphabet = { "A": ("ABCDEFGHIJKLM", "NOPQRSTUVWXYZ"), "B": ("ABCDEFGHIJKLM", "NOPQRSTUVWXYZ"), "C": ("ABCDEFGHIJKLM", "ZNOPQRSTUVWXY"), "D": ("ABCDEFGHIJKLM", "ZNOPQRSTUVWXY"), "E": ("ABCDEFGHIJKLM", "YZNOPQRSTUVWX"), "F": ("ABCDEFGHIJKLM", "YZNOPQRSTUVWX"), "G": ("ABCDEFGHIJKLM", "XYZNOPQRSTUVW"), "H": ("ABCDEFGHIJKLM", "XYZNOPQRSTUVW"), "I": ("ABCDEFGHIJKLM", "WXYZNOPQRSTUV"), "J": ("ABCDEFGHIJKLM", "WXYZNOPQRSTUV"), "K": ("ABCDEFGHIJKLM", "VWXYZNOPQRSTU"), "L": ("ABCDEFGHIJKLM", "VWXYZNOPQRSTU"), "M": ("ABCDEFGHIJKLM", "UVWXYZNOPQRST"), "N": ("ABCDEFGHIJKLM", "UVWXYZNOPQRST"), "O": ("ABCDEFGHIJKLM", "TUVWXYZNOPQRS"), "P": ("ABCDEFGHIJKLM", "TUVWXYZNOPQRS"), "Q": ("ABCDEFGHIJKLM", "STUVWXYZNOPQR"), "R": ("ABCDEFGHIJKLM", "STUVWXYZNOPQR"), "S": ("ABCDEFGHIJKLM", "RSTUVWXYZNOPQ"), "T": ("ABCDEFGHIJKLM", "RSTUVWXYZNOPQ"), "U": ("ABCDEFGHIJKLM", "QRSTUVWXYZNOP"), "V": ("ABCDEFGHIJKLM", "QRSTUVWXYZNOP"), "W": ("ABCDEFGHIJKLM", "PQRSTUVWXYZNO"), "X": ("ABCDEFGHIJKLM", "PQRSTUVWXYZNO"), "Y": ("ABCDEFGHIJKLM", "OPQRSTUVWXYZN"), "Z": ("ABCDEFGHIJKLM", "OPQRSTUVWXYZN"), } def generate_table(key: str) -> [(str, str)]: """ >>> generate_table('marvin') # doctest: +NORMALIZE_WHITESPACE [('ABCDEFGHIJKLM', 'UVWXYZNOPQRST'), ('ABCDEFGHIJKLM', 'NOPQRSTUVWXYZ'), ('ABCDEFGHIJKLM', 'STUVWXYZNOPQR'), ('ABCDEFGHIJKLM', 'QRSTUVWXYZNOP'), ('ABCDEFGHIJKLM', 'WXYZNOPQRSTUV'), ('ABCDEFGHIJKLM', 'UVWXYZNOPQRST')] """ return [alphabet[char] for char in key.upper()] def encrypt(key: str, words: str) -> str: """ >>> encrypt('marvin', 'jessica') 'QRACRWU' """ cipher = "" count = 0 table = generate_table(key) for char in words.upper(): cipher += get_opponent(table[count], char) count = (count + 1) % len(table) return cipher def decrypt(key: str, words: str) -> str: """ >>> decrypt('marvin', 'QRACRWU') 'JESSICA' """ return encrypt(key, words) def get_position(table: [(str, str)], char: str) -> (int, int) or (None, None): """ >>> table = [ ... ('ABCDEFGHIJKLM', 'UVWXYZNOPQRST'), ('ABCDEFGHIJKLM', 'NOPQRSTUVWXYZ'), ... ('ABCDEFGHIJKLM', 'STUVWXYZNOPQR'), ('ABCDEFGHIJKLM', 'QRSTUVWXYZNOP'), ... ('ABCDEFGHIJKLM', 'WXYZNOPQRSTUV'), ('ABCDEFGHIJKLM', 'UVWXYZNOPQRST')] >>> get_position(table, 'A') (None, None) """ if char in table[0]: row = 0 else: row = 1 if char in table[1] else -1 return (None, None) if row == -1 else (row, table[row].index(char)) def get_opponent(table: [(str, str)], char: str) -> str: """ >>> table = [ ... ('ABCDEFGHIJKLM', 'UVWXYZNOPQRST'), ('ABCDEFGHIJKLM', 'NOPQRSTUVWXYZ'), ... ('ABCDEFGHIJKLM', 'STUVWXYZNOPQR'), ('ABCDEFGHIJKLM', 'QRSTUVWXYZNOP'), ... ('ABCDEFGHIJKLM', 'WXYZNOPQRSTUV'), ('ABCDEFGHIJKLM', 'UVWXYZNOPQRST')] >>> get_opponent(table, 'A') 'A' """ row, col = get_position(table, char.upper()) if row == 1: return table[0][col] else: return table[1][col] if row == 0 else char if __name__ == "__main__": import doctest doctest.testmod() # Fist ensure that all our tests are passing... """ ENTER KEY: marvin ENTER TEXT TO ENCRYPT: jessica ENCRYPTED: QRACRWU DECRYPTED WITH KEY: JESSICA """ key = input("ENTER KEY: ").strip() text = input("ENTER TEXT TO ENCRYPT: ").strip() cipher_text = encrypt(key, text) print(f"ENCRYPTED: {cipher_text}") print(f"DECRYPTED WITH KEY: {decrypt(key, cipher_text)}")
alphabet = { "A": ("ABCDEFGHIJKLM", "NOPQRSTUVWXYZ"), "B": ("ABCDEFGHIJKLM", "NOPQRSTUVWXYZ"), "C": ("ABCDEFGHIJKLM", "ZNOPQRSTUVWXY"), "D": ("ABCDEFGHIJKLM", "ZNOPQRSTUVWXY"), "E": ("ABCDEFGHIJKLM", "YZNOPQRSTUVWX"), "F": ("ABCDEFGHIJKLM", "YZNOPQRSTUVWX"), "G": ("ABCDEFGHIJKLM", "XYZNOPQRSTUVW"), "H": ("ABCDEFGHIJKLM", "XYZNOPQRSTUVW"), "I": ("ABCDEFGHIJKLM", "WXYZNOPQRSTUV"), "J": ("ABCDEFGHIJKLM", "WXYZNOPQRSTUV"), "K": ("ABCDEFGHIJKLM", "VWXYZNOPQRSTU"), "L": ("ABCDEFGHIJKLM", "VWXYZNOPQRSTU"), "M": ("ABCDEFGHIJKLM", "UVWXYZNOPQRST"), "N": ("ABCDEFGHIJKLM", "UVWXYZNOPQRST"), "O": ("ABCDEFGHIJKLM", "TUVWXYZNOPQRS"), "P": ("ABCDEFGHIJKLM", "TUVWXYZNOPQRS"), "Q": ("ABCDEFGHIJKLM", "STUVWXYZNOPQR"), "R": ("ABCDEFGHIJKLM", "STUVWXYZNOPQR"), "S": ("ABCDEFGHIJKLM", "RSTUVWXYZNOPQ"), "T": ("ABCDEFGHIJKLM", "RSTUVWXYZNOPQ"), "U": ("ABCDEFGHIJKLM", "QRSTUVWXYZNOP"), "V": ("ABCDEFGHIJKLM", "QRSTUVWXYZNOP"), "W": ("ABCDEFGHIJKLM", "PQRSTUVWXYZNO"), "X": ("ABCDEFGHIJKLM", "PQRSTUVWXYZNO"), "Y": ("ABCDEFGHIJKLM", "OPQRSTUVWXYZN"), "Z": ("ABCDEFGHIJKLM", "OPQRSTUVWXYZN"), } def generate_table(key: str) -> [(str, str)]: """ >>> generate_table('marvin') # doctest: +NORMALIZE_WHITESPACE [('ABCDEFGHIJKLM', 'UVWXYZNOPQRST'), ('ABCDEFGHIJKLM', 'NOPQRSTUVWXYZ'), ('ABCDEFGHIJKLM', 'STUVWXYZNOPQR'), ('ABCDEFGHIJKLM', 'QRSTUVWXYZNOP'), ('ABCDEFGHIJKLM', 'WXYZNOPQRSTUV'), ('ABCDEFGHIJKLM', 'UVWXYZNOPQRST')] """ return [alphabet[char] for char in key.upper()] def encrypt(key: str, words: str) -> str: """ >>> encrypt('marvin', 'jessica') 'QRACRWU' """ cipher = "" count = 0 table = generate_table(key) for char in words.upper(): cipher += get_opponent(table[count], char) count = (count + 1) % len(table) return cipher def decrypt(key: str, words: str) -> str: """ >>> decrypt('marvin', 'QRACRWU') 'JESSICA' """ return encrypt(key, words) def get_position(table: [(str, str)], char: str) -> (int, int) or (None, None): """ >>> table = [ ... ('ABCDEFGHIJKLM', 'UVWXYZNOPQRST'), ('ABCDEFGHIJKLM', 'NOPQRSTUVWXYZ'), ... ('ABCDEFGHIJKLM', 'STUVWXYZNOPQR'), ('ABCDEFGHIJKLM', 'QRSTUVWXYZNOP'), ... ('ABCDEFGHIJKLM', 'WXYZNOPQRSTUV'), ('ABCDEFGHIJKLM', 'UVWXYZNOPQRST')] >>> get_position(table, 'A') (None, None) """ if char in table[0]: row = 0 else: row = 1 if char in table[1] else -1 return (None, None) if row == -1 else (row, table[row].index(char)) def get_opponent(table: [(str, str)], char: str) -> str: """ >>> table = [ ... ('ABCDEFGHIJKLM', 'UVWXYZNOPQRST'), ('ABCDEFGHIJKLM', 'NOPQRSTUVWXYZ'), ... ('ABCDEFGHIJKLM', 'STUVWXYZNOPQR'), ('ABCDEFGHIJKLM', 'QRSTUVWXYZNOP'), ... ('ABCDEFGHIJKLM', 'WXYZNOPQRSTUV'), ('ABCDEFGHIJKLM', 'UVWXYZNOPQRST')] >>> get_opponent(table, 'A') 'A' """ row, col = get_position(table, char.upper()) if row == 1: return table[0][col] else: return table[1][col] if row == 0 else char if __name__ == "__main__": import doctest doctest.testmod() # Fist ensure that all our tests are passing... """ ENTER KEY: marvin ENTER TEXT TO ENCRYPT: jessica ENCRYPTED: QRACRWU DECRYPTED WITH KEY: JESSICA """ key = input("ENTER KEY: ").strip() text = input("ENTER TEXT TO ENCRYPT: ").strip() cipher_text = encrypt(key, text) print(f"ENCRYPTED: {cipher_text}") print(f"DECRYPTED WITH KEY: {decrypt(key, cipher_text)}")
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" In this problem, we want to determine all possible subsequences of the given sequence. We use backtracking to solve this problem. Time complexity: O(2^n), where n denotes the length of the given sequence. """ from typing import Any, List def generate_all_subsequences(sequence: List[Any]) -> None: create_state_space_tree(sequence, [], 0) def create_state_space_tree( sequence: List[Any], current_subsequence: List[Any], index: int ) -> None: """ Creates a state space tree to iterate through each branch using DFS. We know that each state has exactly two children. It terminates when it reaches the end of the given sequence. """ if index == len(sequence): print(current_subsequence) return create_state_space_tree(sequence, current_subsequence, index + 1) current_subsequence.append(sequence[index]) create_state_space_tree(sequence, current_subsequence, index + 1) current_subsequence.pop() if __name__ == "__main__": seq: List[Any] = [3, 1, 2, 4] generate_all_subsequences(seq) seq.clear() seq.extend(["A", "B", "C"]) generate_all_subsequences(seq)
""" In this problem, we want to determine all possible subsequences of the given sequence. We use backtracking to solve this problem. Time complexity: O(2^n), where n denotes the length of the given sequence. """ from typing import Any, List def generate_all_subsequences(sequence: List[Any]) -> None: create_state_space_tree(sequence, [], 0) def create_state_space_tree( sequence: List[Any], current_subsequence: List[Any], index: int ) -> None: """ Creates a state space tree to iterate through each branch using DFS. We know that each state has exactly two children. It terminates when it reaches the end of the given sequence. """ if index == len(sequence): print(current_subsequence) return create_state_space_tree(sequence, current_subsequence, index + 1) current_subsequence.append(sequence[index]) create_state_space_tree(sequence, current_subsequence, index + 1) current_subsequence.pop() if __name__ == "__main__": seq: List[Any] = [3, 1, 2, 4] generate_all_subsequences(seq) seq.clear() seq.extend(["A", "B", "C"]) generate_all_subsequences(seq)
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
shan7030
"2021-03-01T16:50:26Z"
"2021-03-18T07:39:53Z"
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [ ] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
def quick_sort_3partition(sorting: list, left: int, right: int) -> None: if right <= left: return a = i = left b = right pivot = sorting[left] while i <= b: if sorting[i] < pivot: sorting[a], sorting[i] = sorting[i], sorting[a] a += 1 i += 1 elif sorting[i] > pivot: sorting[b], sorting[i] = sorting[i], sorting[b] b -= 1 else: i += 1 quick_sort_3partition(sorting, left, a - 1) quick_sort_3partition(sorting, b + 1, right) def quick_sort_lomuto_partition(sorting: list, left: int, right: int) -> None: """ A pure Python implementation of quick sort algorithm(in-place) with Lomuto partition scheme: https://en.wikipedia.org/wiki/Quicksort#Lomuto_partition_scheme :param sorting: sort list :param left: left endpoint of sorting :param right: right endpoint of sorting :return: None Examples: >>> nums1 = [0, 5, 3, 1, 2] >>> quick_sort_lomuto_partition(nums1, 0, 4) >>> nums1 [0, 1, 2, 3, 5] >>> nums2 = [] >>> quick_sort_lomuto_partition(nums2, 0, 0) >>> nums2 [] >>> nums3 = [-2, 5, 0, -4] >>> quick_sort_lomuto_partition(nums3, 0, 3) >>> nums3 [-4, -2, 0, 5] """ if left < right: pivot_index = lomuto_partition(sorting, left, right) quick_sort_lomuto_partition(sorting, left, pivot_index - 1) quick_sort_lomuto_partition(sorting, pivot_index + 1, right) def lomuto_partition(sorting: list, left: int, right: int) -> int: """ Example: >>> lomuto_partition([1,5,7,6], 0, 3) 2 """ pivot = sorting[right] store_index = left for i in range(left, right): if sorting[i] < pivot: sorting[store_index], sorting[i] = sorting[i], sorting[store_index] store_index += 1 sorting[right], sorting[store_index] = sorting[store_index], sorting[right] return store_index def three_way_radix_quicksort(sorting: list) -> list: """ Three-way radix quicksort: https://en.wikipedia.org/wiki/Quicksort#Three-way_radix_quicksort First divide the list into three parts. Then recursively sort the "less than" and "greater than" partitions. >>> three_way_radix_quicksort([]) [] >>> three_way_radix_quicksort([1]) [1] >>> three_way_radix_quicksort([-5, -2, 1, -2, 0, 1]) [-5, -2, -2, 0, 1, 1] >>> three_way_radix_quicksort([1, 2, 5, 1, 2, 0, 0, 5, 2, -1]) [-1, 0, 0, 1, 1, 2, 2, 2, 5, 5] """ if len(sorting) <= 1: return sorting return ( three_way_radix_quicksort([i for i in sorting if i < sorting[0]]) + [i for i in sorting if i == sorting[0]] + three_way_radix_quicksort([i for i in sorting if i > sorting[0]]) ) if __name__ == "__main__": import doctest doctest.testmod(verbose=True) user_input = input("Enter numbers separated by a comma:\n").strip() unsorted = [int(item) for item in user_input.split(",")] quick_sort_3partition(unsorted, 0, len(unsorted) - 1) print(unsorted)
def quick_sort_3partition(sorting: list, left: int, right: int) -> None: if right <= left: return a = i = left b = right pivot = sorting[left] while i <= b: if sorting[i] < pivot: sorting[a], sorting[i] = sorting[i], sorting[a] a += 1 i += 1 elif sorting[i] > pivot: sorting[b], sorting[i] = sorting[i], sorting[b] b -= 1 else: i += 1 quick_sort_3partition(sorting, left, a - 1) quick_sort_3partition(sorting, b + 1, right) def quick_sort_lomuto_partition(sorting: list, left: int, right: int) -> None: """ A pure Python implementation of quick sort algorithm(in-place) with Lomuto partition scheme: https://en.wikipedia.org/wiki/Quicksort#Lomuto_partition_scheme :param sorting: sort list :param left: left endpoint of sorting :param right: right endpoint of sorting :return: None Examples: >>> nums1 = [0, 5, 3, 1, 2] >>> quick_sort_lomuto_partition(nums1, 0, 4) >>> nums1 [0, 1, 2, 3, 5] >>> nums2 = [] >>> quick_sort_lomuto_partition(nums2, 0, 0) >>> nums2 [] >>> nums3 = [-2, 5, 0, -4] >>> quick_sort_lomuto_partition(nums3, 0, 3) >>> nums3 [-4, -2, 0, 5] """ if left < right: pivot_index = lomuto_partition(sorting, left, right) quick_sort_lomuto_partition(sorting, left, pivot_index - 1) quick_sort_lomuto_partition(sorting, pivot_index + 1, right) def lomuto_partition(sorting: list, left: int, right: int) -> int: """ Example: >>> lomuto_partition([1,5,7,6], 0, 3) 2 """ pivot = sorting[right] store_index = left for i in range(left, right): if sorting[i] < pivot: sorting[store_index], sorting[i] = sorting[i], sorting[store_index] store_index += 1 sorting[right], sorting[store_index] = sorting[store_index], sorting[right] return store_index def three_way_radix_quicksort(sorting: list) -> list: """ Three-way radix quicksort: https://en.wikipedia.org/wiki/Quicksort#Three-way_radix_quicksort First divide the list into three parts. Then recursively sort the "less than" and "greater than" partitions. >>> three_way_radix_quicksort([]) [] >>> three_way_radix_quicksort([1]) [1] >>> three_way_radix_quicksort([-5, -2, 1, -2, 0, 1]) [-5, -2, -2, 0, 1, 1] >>> three_way_radix_quicksort([1, 2, 5, 1, 2, 0, 0, 5, 2, -1]) [-1, 0, 0, 1, 1, 2, 2, 2, 5, 5] """ if len(sorting) <= 1: return sorting return ( three_way_radix_quicksort([i for i in sorting if i < sorting[0]]) + [i for i in sorting if i == sorting[0]] + three_way_radix_quicksort([i for i in sorting if i > sorting[0]]) ) if __name__ == "__main__": import doctest doctest.testmod(verbose=True) user_input = input("Enter numbers separated by a comma:\n").strip() unsorted = [int(item) for item in user_input.split(",")] quick_sort_3partition(unsorted, 0, len(unsorted) - 1) print(unsorted)
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
#!/usr/bin/env python3 """ Illustrate how to implement bucket sort algorithm. Author: OMKAR PATHAK This program will illustrate how to implement bucket sort algorithm Wikipedia says: Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm, or by recursively applying the bucket sorting algorithm. It is a distribution sort, and is a cousin of radix sort in the most to least significant digit flavour. Bucket sort is a generalization of pigeonhole sort. Bucket sort can be implemented with comparisons and therefore can also be considered a comparison sort algorithm. The computational complexity estimates involve the number of buckets. Time Complexity of Solution: Worst case scenario occurs when all the elements are placed in a single bucket. The overall performance would then be dominated by the algorithm used to sort each bucket. In this case, O(n log n), because of TimSort Average Case O(n + (n^2)/k + k), where k is the number of buckets If k = O(n), time complexity is O(n) Source: https://en.wikipedia.org/wiki/Bucket_sort """ def bucket_sort(my_list: list) -> list: """ >>> data = [-1, 2, -5, 0] >>> bucket_sort(data) == sorted(data) True >>> data = [9, 8, 7, 6, -12] >>> bucket_sort(data) == sorted(data) True >>> data = [.4, 1.2, .1, .2, -.9] >>> bucket_sort(data) == sorted(data) True >>> bucket_sort([]) == sorted([]) True >>> import random >>> collection = random.sample(range(-50, 50), 50) >>> bucket_sort(collection) == sorted(collection) True """ if len(my_list) == 0: return [] min_value, max_value = min(my_list), max(my_list) bucket_count = int(max_value - min_value) + 1 buckets = [[] for _ in range(bucket_count)] for i in range(len(my_list)): buckets[(int(my_list[i] - min_value) // bucket_count)].append(my_list[i]) return [v for bucket in buckets for v in sorted(bucket)] if __name__ == "__main__": from doctest import testmod testmod() assert bucket_sort([4, 5, 3, 2, 1]) == [1, 2, 3, 4, 5] assert bucket_sort([0, 1, -10, 15, 2, -2]) == [-10, -2, 0, 1, 2, 15]
#!/usr/bin/env python3 """ Illustrate how to implement bucket sort algorithm. Author: OMKAR PATHAK This program will illustrate how to implement bucket sort algorithm Wikipedia says: Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm, or by recursively applying the bucket sorting algorithm. It is a distribution sort, and is a cousin of radix sort in the most to least significant digit flavour. Bucket sort is a generalization of pigeonhole sort. Bucket sort can be implemented with comparisons and therefore can also be considered a comparison sort algorithm. The computational complexity estimates involve the number of buckets. Time Complexity of Solution: Worst case scenario occurs when all the elements are placed in a single bucket. The overall performance would then be dominated by the algorithm used to sort each bucket. In this case, O(n log n), because of TimSort Average Case O(n + (n^2)/k + k), where k is the number of buckets If k = O(n), time complexity is O(n) Source: https://en.wikipedia.org/wiki/Bucket_sort """ from typing import List def bucket_sort(my_list: list) -> list: """ >>> data = [-1, 2, -5, 0] >>> bucket_sort(data) == sorted(data) True >>> data = [9, 8, 7, 6, -12] >>> bucket_sort(data) == sorted(data) True >>> data = [.4, 1.2, .1, .2, -.9] >>> bucket_sort(data) == sorted(data) True >>> bucket_sort([]) == sorted([]) True >>> import random >>> collection = random.sample(range(-50, 50), 50) >>> bucket_sort(collection) == sorted(collection) True """ if len(my_list) == 0: return [] min_value, max_value = min(my_list), max(my_list) bucket_count = int(max_value - min_value) + 1 buckets: List[list] = [[] for _ in range(bucket_count)] for i in range(len(my_list)): buckets[(int(my_list[i] - min_value) // bucket_count)].append(my_list[i]) return [v for bucket in buckets for v in sorted(bucket)] if __name__ == "__main__": from doctest import testmod testmod() assert bucket_sort([4, 5, 3, 2, 1]) == [1, 2, 3, 4, 5] assert bucket_sort([0, 1, -10, 15, 2, -2]) == [-10, -2, 0, 1, 2, 15]
1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" https://en.wikipedia.org/wiki/Cocktail_shaker_sort """ def cocktail_shaker_sort(unsorted: list) -> list: """ Pure implementation of the cocktail shaker sort algorithm in Python. >>> cocktail_shaker_sort([4, 5, 2, 1, 2]) [1, 2, 2, 4, 5] >>> cocktail_shaker_sort([-4, 5, 0, 1, 2, 11]) [-4, 0, 1, 2, 5, 11] >>> cocktail_shaker_sort([0.1, -2.4, 4.4, 2.2]) [-2.4, 0.1, 2.2, 4.4] >>> cocktail_shaker_sort([1, 2, 3, 4, 5]) [1, 2, 3, 4, 5] >>> cocktail_shaker_sort([-4, -5, -24, -7, -11]) [-24, -11, -7, -5, -4] """ for i in range(len(unsorted) - 1, 0, -1): swapped = False for j in range(i, 0, -1): if unsorted[j] < unsorted[j - 1]: unsorted[j], unsorted[j - 1] = unsorted[j - 1], unsorted[j] swapped = True for j in range(i): if unsorted[j] > unsorted[j + 1]: unsorted[j], unsorted[j + 1] = unsorted[j + 1], unsorted[j] swapped = True if not swapped: return unsorted if __name__ == "__main__": import doctest doctest.testmod() user_input = input("Enter numbers separated by a comma:\n").strip() unsorted = [int(item) for item in user_input.split(",")] print(f"{cocktail_shaker_sort(unsorted) = }")
""" https://en.wikipedia.org/wiki/Cocktail_shaker_sort """ def cocktail_shaker_sort(unsorted: list) -> list: """ Pure implementation of the cocktail shaker sort algorithm in Python. >>> cocktail_shaker_sort([4, 5, 2, 1, 2]) [1, 2, 2, 4, 5] >>> cocktail_shaker_sort([-4, 5, 0, 1, 2, 11]) [-4, 0, 1, 2, 5, 11] >>> cocktail_shaker_sort([0.1, -2.4, 4.4, 2.2]) [-2.4, 0.1, 2.2, 4.4] >>> cocktail_shaker_sort([1, 2, 3, 4, 5]) [1, 2, 3, 4, 5] >>> cocktail_shaker_sort([-4, -5, -24, -7, -11]) [-24, -11, -7, -5, -4] """ for i in range(len(unsorted) - 1, 0, -1): swapped = False for j in range(i, 0, -1): if unsorted[j] < unsorted[j - 1]: unsorted[j], unsorted[j - 1] = unsorted[j - 1], unsorted[j] swapped = True for j in range(i): if unsorted[j] > unsorted[j + 1]: unsorted[j], unsorted[j + 1] = unsorted[j + 1], unsorted[j] swapped = True if not swapped: break return unsorted if __name__ == "__main__": import doctest doctest.testmod() user_input = input("Enter numbers separated by a comma:\n").strip() unsorted = [int(item) for item in user_input.split(",")] print(f"{cocktail_shaker_sort(unsorted) = }")
1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
from bisect import bisect_left from functools import total_ordering from heapq import merge """ A pure Python implementation of the patience sort algorithm For more information: https://en.wikipedia.org/wiki/Patience_sorting This algorithm is based on the card game patience For doctests run following command: python3 -m doctest -v patience_sort.py For manual testing run: python3 patience_sort.py """ @total_ordering class Stack(list): def __lt__(self, other): return self[-1] < other[-1] def __eq__(self, other): return self[-1] == other[-1] def patience_sort(collection: list) -> list: """A pure implementation of quick sort algorithm in Python :param collection: some mutable ordered collection with heterogeneous comparable items inside :return: the same collection ordered by ascending Examples: >>> patience_sort([1, 9, 5, 21, 17, 6]) [1, 5, 6, 9, 17, 21] >>> patience_sort([]) [] >>> patience_sort([-3, -17, -48]) [-48, -17, -3] """ stacks = [] # sort into stacks for element in collection: new_stacks = Stack([element]) i = bisect_left(stacks, new_stacks) if i != len(stacks): stacks[i].append(element) else: stacks.append(new_stacks) # use a heap-based merge to merge stack efficiently collection[:] = merge(*[reversed(stack) for stack in stacks]) return collection if __name__ == "__main__": user_input = input("Enter numbers separated by a comma:\n").strip() unsorted = [int(item) for item in user_input.split(",")] print(patience_sort(unsorted))
from bisect import bisect_left from functools import total_ordering from heapq import merge from typing import List """ A pure Python implementation of the patience sort algorithm For more information: https://en.wikipedia.org/wiki/Patience_sorting This algorithm is based on the card game patience For doctests run following command: python3 -m doctest -v patience_sort.py For manual testing run: python3 patience_sort.py """ @total_ordering class Stack(list): def __lt__(self, other): return self[-1] < other[-1] def __eq__(self, other): return self[-1] == other[-1] def patience_sort(collection: list) -> list: """A pure implementation of quick sort algorithm in Python :param collection: some mutable ordered collection with heterogeneous comparable items inside :return: the same collection ordered by ascending Examples: >>> patience_sort([1, 9, 5, 21, 17, 6]) [1, 5, 6, 9, 17, 21] >>> patience_sort([]) [] >>> patience_sort([-3, -17, -48]) [-48, -17, -3] """ stacks: List[Stack] = [] # sort into stacks for element in collection: new_stacks = Stack([element]) i = bisect_left(stacks, new_stacks) if i != len(stacks): stacks[i].append(element) else: stacks.append(new_stacks) # use a heap-based merge to merge stack efficiently collection[:] = merge(*[reversed(stack) for stack in stacks]) return collection if __name__ == "__main__": user_input = input("Enter numbers separated by a comma:\n").strip() unsorted = [int(item) for item in user_input.split(",")] print(patience_sort(unsorted))
1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" This is a pure Python implementation of the quick sort algorithm For doctests run following command: python -m doctest -v radix_sort.py or python3 -m doctest -v radix_sort.py For manual testing run: python radix_sort.py """ from __future__ import annotations from typing import List def radix_sort(list_of_ints: List[int]) -> List[int]: """ Examples: >>> radix_sort([0, 5, 3, 2, 2]) [0, 2, 2, 3, 5] >>> radix_sort(list(range(15))) == sorted(range(15)) True >>> radix_sort(list(range(14,-1,-1))) == sorted(range(15)) True >>> radix_sort([1,100,10,1000]) == sorted([1,100,10,1000]) True """ RADIX = 10 placement = 1 max_digit = max(list_of_ints) while placement <= max_digit: # declare and initialize empty buckets buckets = [list() for _ in range(RADIX)] # split list_of_ints between the buckets for i in list_of_ints: tmp = int((i / placement) % RADIX) buckets[tmp].append(i) # put each buckets' contents into list_of_ints a = 0 for b in range(RADIX): for i in buckets[b]: list_of_ints[a] = i a += 1 # move to next placement *= RADIX return list_of_ints if __name__ == "__main__": import doctest doctest.testmod()
""" This is a pure Python implementation of the quick sort algorithm For doctests run following command: python -m doctest -v radix_sort.py or python3 -m doctest -v radix_sort.py For manual testing run: python radix_sort.py """ from __future__ import annotations from typing import List def radix_sort(list_of_ints: List[int]) -> List[int]: """ Examples: >>> radix_sort([0, 5, 3, 2, 2]) [0, 2, 2, 3, 5] >>> radix_sort(list(range(15))) == sorted(range(15)) True >>> radix_sort(list(range(14,-1,-1))) == sorted(range(15)) True >>> radix_sort([1,100,10,1000]) == sorted([1,100,10,1000]) True """ RADIX = 10 placement = 1 max_digit = max(list_of_ints) while placement <= max_digit: # declare and initialize empty buckets buckets: List[list] = [list() for _ in range(RADIX)] # split list_of_ints between the buckets for i in list_of_ints: tmp = int((i / placement) % RADIX) buckets[tmp].append(i) # put each buckets' contents into list_of_ints a = 0 for b in range(RADIX): for i in buckets[b]: list_of_ints[a] = i a += 1 # move to next placement *= RADIX return list_of_ints if __name__ == "__main__": import doctest doctest.testmod()
1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" A recursive implementation of the insertion sort algorithm """ from __future__ import annotations def rec_insertion_sort(collection: list, n: int): """ Given a collection of numbers and its length, sorts the collections in ascending order :param collection: A mutable collection of comparable elements :param n: The length of collections >>> col = [1, 2, 1] >>> rec_insertion_sort(col, len(col)) >>> print(col) [1, 1, 2] >>> col = [2, 1, 0, -1, -2] >>> rec_insertion_sort(col, len(col)) >>> print(col) [-2, -1, 0, 1, 2] >>> col = [1] >>> rec_insertion_sort(col, len(col)) >>> print(col) [1] """ # Checks if the entire collection has been sorted if len(collection) <= 1 or n <= 1: return insert_next(collection, n - 1) rec_insertion_sort(collection, n - 1) def insert_next(collection: list, index: int): """ Inserts the '(index-1)th' element into place >>> col = [3, 2, 4, 2] >>> insert_next(col, 1) >>> print(col) [2, 3, 4, 2] >>> col = [3, 2, 3] >>> insert_next(col, 2) >>> print(col) [3, 2, 3] >>> col = [] >>> insert_next(col, 1) >>> print(col) [] """ # Checks order between adjacent elements if index >= len(collection) or collection[index - 1] <= collection[index]: return # Swaps adjacent elements since they are not in ascending order collection[index - 1], collection[index] = ( collection[index], collection[index - 1], ) insert_next(collection, index + 1) if __name__ == "__main__": numbers = input("Enter integers separated by spaces: ") numbers = [int(num) for num in numbers.split()] rec_insertion_sort(numbers, len(numbers)) print(numbers)
""" A recursive implementation of the insertion sort algorithm """ from __future__ import annotations from typing import List def rec_insertion_sort(collection: list, n: int): """ Given a collection of numbers and its length, sorts the collections in ascending order :param collection: A mutable collection of comparable elements :param n: The length of collections >>> col = [1, 2, 1] >>> rec_insertion_sort(col, len(col)) >>> print(col) [1, 1, 2] >>> col = [2, 1, 0, -1, -2] >>> rec_insertion_sort(col, len(col)) >>> print(col) [-2, -1, 0, 1, 2] >>> col = [1] >>> rec_insertion_sort(col, len(col)) >>> print(col) [1] """ # Checks if the entire collection has been sorted if len(collection) <= 1 or n <= 1: return insert_next(collection, n - 1) rec_insertion_sort(collection, n - 1) def insert_next(collection: list, index: int): """ Inserts the '(index-1)th' element into place >>> col = [3, 2, 4, 2] >>> insert_next(col, 1) >>> print(col) [2, 3, 4, 2] >>> col = [3, 2, 3] >>> insert_next(col, 2) >>> print(col) [3, 2, 3] >>> col = [] >>> insert_next(col, 1) >>> print(col) [] """ # Checks order between adjacent elements if index >= len(collection) or collection[index - 1] <= collection[index]: return # Swaps adjacent elements since they are not in ascending order collection[index - 1], collection[index] = ( collection[index], collection[index - 1], ) insert_next(collection, index + 1) if __name__ == "__main__": numbers = input("Enter integers separated by spaces: ") number_list: List[int] = [int(num) for num in numbers.split()] rec_insertion_sort(number_list, len(number_list)) print(number_list)
1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" This is a pure Python implementation of the P-Series algorithm https://en.wikipedia.org/wiki/Harmonic_series_(mathematics)#P-series For doctests run following command: python -m doctest -v p_series.py or python3 -m doctest -v p_series.py For manual testing run: python3 p_series.py """ def p_series(nth_term: int, power: int) -> list: """Pure Python implementation of P-Series algorithm :return: The P-Series starting from 1 to last (nth) term Examples: >>> p_series(5, 2) [1, '1/4', '1/9', '1/16', '1/25'] >>> p_series(-5, 2) [] >>> p_series(5, -2) [1, '1/0.25', '1/0.1111111111111111', '1/0.0625', '1/0.04'] >>> p_series("", 1000) '' >>> p_series(0, 0) [] >>> p_series(1, 1) [1] """ if nth_term == "": return nth_term nth_term = int(nth_term) power = int(power) series = [] for temp in range(int(nth_term)): series.append(f"1/{pow(temp + 1, int(power))}" if series else 1) return series if __name__ == "__main__": nth_term = input("Enter the last number (nth term) of the P-Series") power = input("Enter the power for P-Series") print("Formula of P-Series => 1+1/2^p+1/3^p ..... 1/n^p") print(p_series(nth_term, power))
""" This is a pure Python implementation of the P-Series algorithm https://en.wikipedia.org/wiki/Harmonic_series_(mathematics)#P-series For doctests run following command: python -m doctest -v p_series.py or python3 -m doctest -v p_series.py For manual testing run: python3 p_series.py """ def p_series(nth_term: int, power: int) -> list: """Pure Python implementation of P-Series algorithm :return: The P-Series starting from 1 to last (nth) term Examples: >>> p_series(5, 2) [1, '1/4', '1/9', '1/16', '1/25'] >>> p_series(-5, 2) [] >>> p_series(5, -2) [1, '1/0.25', '1/0.1111111111111111', '1/0.0625', '1/0.04'] >>> p_series("", 1000) '' >>> p_series(0, 0) [] >>> p_series(1, 1) [1] """ if nth_term == "": return nth_term nth_term = int(nth_term) power = int(power) series = [] for temp in range(int(nth_term)): series.append(f"1/{pow(temp + 1, int(power))}" if series else 1) return series if __name__ == "__main__": nth_term = input("Enter the last number (nth term) of the P-Series") power = input("Enter the power for P-Series") print("Formula of P-Series => 1+1/2^p+1/3^p ..... 1/n^p") print(p_series(nth_term, power))
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
from math import asin, atan, cos, radians, sin, sqrt, tan def haversine_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> float: """ Calculate great circle distance between two points in a sphere, given longitudes and latitudes https://en.wikipedia.org/wiki/Haversine_formula We know that the globe is "sort of" spherical, so a path between two points isn't exactly a straight line. We need to account for the Earth's curvature when calculating distance from point A to B. This effect is negligible for small distances but adds up as distance increases. The Haversine method treats the earth as a sphere which allows us to "project" the two points A and B onto the surface of that sphere and approximate the spherical distance between them. Since the Earth is not a perfect sphere, other methods which model the Earth's ellipsoidal nature are more accurate but a quick and modifiable computation like Haversine can be handy for shorter range distances. Args: lat1, lon1: latitude and longitude of coordinate 1 lat2, lon2: latitude and longitude of coordinate 2 Returns: geographical distance between two points in metres >>> from collections import namedtuple >>> point_2d = namedtuple("point_2d", "lat lon") >>> SAN_FRANCISCO = point_2d(37.774856, -122.424227) >>> YOSEMITE = point_2d(37.864742, -119.537521) >>> f"{haversine_distance(*SAN_FRANCISCO, *YOSEMITE):0,.0f} meters" '254,352 meters' """ # CONSTANTS per WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System # Distance in metres(m) AXIS_A = 6378137.0 AXIS_B = 6356752.314245 RADIUS = 6378137 # Equation parameters # Equation https://en.wikipedia.org/wiki/Haversine_formula#Formulation flattening = (AXIS_A - AXIS_B) / AXIS_A phi_1 = atan((1 - flattening) * tan(radians(lat1))) phi_2 = atan((1 - flattening) * tan(radians(lat2))) lambda_1 = radians(lon1) lambda_2 = radians(lon2) # Equation sin_sq_phi = sin((phi_2 - phi_1) / 2) sin_sq_lambda = sin((lambda_2 - lambda_1) / 2) # Square both values sin_sq_phi *= sin_sq_phi sin_sq_lambda *= sin_sq_lambda h_value = sqrt(sin_sq_phi + (cos(phi_1) * cos(phi_2) * sin_sq_lambda)) return 2 * RADIUS * asin(h_value) if __name__ == "__main__": import doctest doctest.testmod()
from math import asin, atan, cos, radians, sin, sqrt, tan def haversine_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> float: """ Calculate great circle distance between two points in a sphere, given longitudes and latitudes https://en.wikipedia.org/wiki/Haversine_formula We know that the globe is "sort of" spherical, so a path between two points isn't exactly a straight line. We need to account for the Earth's curvature when calculating distance from point A to B. This effect is negligible for small distances but adds up as distance increases. The Haversine method treats the earth as a sphere which allows us to "project" the two points A and B onto the surface of that sphere and approximate the spherical distance between them. Since the Earth is not a perfect sphere, other methods which model the Earth's ellipsoidal nature are more accurate but a quick and modifiable computation like Haversine can be handy for shorter range distances. Args: lat1, lon1: latitude and longitude of coordinate 1 lat2, lon2: latitude and longitude of coordinate 2 Returns: geographical distance between two points in metres >>> from collections import namedtuple >>> point_2d = namedtuple("point_2d", "lat lon") >>> SAN_FRANCISCO = point_2d(37.774856, -122.424227) >>> YOSEMITE = point_2d(37.864742, -119.537521) >>> f"{haversine_distance(*SAN_FRANCISCO, *YOSEMITE):0,.0f} meters" '254,352 meters' """ # CONSTANTS per WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System # Distance in metres(m) AXIS_A = 6378137.0 AXIS_B = 6356752.314245 RADIUS = 6378137 # Equation parameters # Equation https://en.wikipedia.org/wiki/Haversine_formula#Formulation flattening = (AXIS_A - AXIS_B) / AXIS_A phi_1 = atan((1 - flattening) * tan(radians(lat1))) phi_2 = atan((1 - flattening) * tan(radians(lat2))) lambda_1 = radians(lon1) lambda_2 = radians(lon2) # Equation sin_sq_phi = sin((phi_2 - phi_1) / 2) sin_sq_lambda = sin((lambda_2 - lambda_1) / 2) # Square both values sin_sq_phi *= sin_sq_phi sin_sq_lambda *= sin_sq_lambda h_value = sqrt(sin_sq_phi + (cos(phi_1) * cos(phi_2) * sin_sq_lambda)) return 2 * RADIUS * asin(h_value) if __name__ == "__main__": import doctest doctest.testmod()
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
from typing import Optional class Node: """ A Node has data variable and pointers to Nodes to its left and right. """ def __init__(self, data: int) -> None: self.data = data self.left: Optional[Node] = None self.right: Optional[Node] = None def display(tree: Optional[Node]) -> None: # In Order traversal of the tree """ >>> root = Node(1) >>> root.left = Node(0) >>> root.right = Node(2) >>> display(root) 0 1 2 >>> display(root.right) 2 """ if tree: display(tree.left) print(tree.data) display(tree.right) def depth_of_tree(tree: Optional[Node]) -> int: """ Recursive function that returns the depth of a binary tree. >>> root = Node(0) >>> depth_of_tree(root) 1 >>> root.left = Node(0) >>> depth_of_tree(root) 2 >>> root.right = Node(0) >>> depth_of_tree(root) 2 >>> root.left.right = Node(0) >>> depth_of_tree(root) 3 >>> depth_of_tree(root.left) 2 """ return 1 + max(depth_of_tree(tree.left), depth_of_tree(tree.right)) if tree else 0 def is_full_binary_tree(tree: Node) -> bool: """ Returns True if this is a full binary tree >>> root = Node(0) >>> is_full_binary_tree(root) True >>> root.left = Node(0) >>> is_full_binary_tree(root) False >>> root.right = Node(0) >>> is_full_binary_tree(root) True >>> root.left.left = Node(0) >>> is_full_binary_tree(root) False >>> root.right.right = Node(0) >>> is_full_binary_tree(root) False """ if not tree: return True if tree.left and tree.right: return is_full_binary_tree(tree.left) and is_full_binary_tree(tree.right) else: return not tree.left and not tree.right def main() -> None: # Main function for testing. tree = Node(1) tree.left = Node(2) tree.right = Node(3) tree.left.left = Node(4) tree.left.right = Node(5) tree.left.right.left = Node(6) tree.right.left = Node(7) tree.right.left.left = Node(8) tree.right.left.left.right = Node(9) print(is_full_binary_tree(tree)) print(depth_of_tree(tree)) print("Tree is: ") display(tree) if __name__ == "__main__": main()
from typing import Optional class Node: """ A Node has data variable and pointers to Nodes to its left and right. """ def __init__(self, data: int) -> None: self.data = data self.left: Optional[Node] = None self.right: Optional[Node] = None def display(tree: Optional[Node]) -> None: # In Order traversal of the tree """ >>> root = Node(1) >>> root.left = Node(0) >>> root.right = Node(2) >>> display(root) 0 1 2 >>> display(root.right) 2 """ if tree: display(tree.left) print(tree.data) display(tree.right) def depth_of_tree(tree: Optional[Node]) -> int: """ Recursive function that returns the depth of a binary tree. >>> root = Node(0) >>> depth_of_tree(root) 1 >>> root.left = Node(0) >>> depth_of_tree(root) 2 >>> root.right = Node(0) >>> depth_of_tree(root) 2 >>> root.left.right = Node(0) >>> depth_of_tree(root) 3 >>> depth_of_tree(root.left) 2 """ return 1 + max(depth_of_tree(tree.left), depth_of_tree(tree.right)) if tree else 0 def is_full_binary_tree(tree: Node) -> bool: """ Returns True if this is a full binary tree >>> root = Node(0) >>> is_full_binary_tree(root) True >>> root.left = Node(0) >>> is_full_binary_tree(root) False >>> root.right = Node(0) >>> is_full_binary_tree(root) True >>> root.left.left = Node(0) >>> is_full_binary_tree(root) False >>> root.right.right = Node(0) >>> is_full_binary_tree(root) False """ if not tree: return True if tree.left and tree.right: return is_full_binary_tree(tree.left) and is_full_binary_tree(tree.right) else: return not tree.left and not tree.right def main() -> None: # Main function for testing. tree = Node(1) tree.left = Node(2) tree.right = Node(3) tree.left.left = Node(4) tree.left.right = Node(5) tree.left.right.left = Node(6) tree.right.left = Node(7) tree.right.left.left = Node(8) tree.right.left.left.right = Node(9) print(is_full_binary_tree(tree)) print(depth_of_tree(tree)) print("Tree is: ") display(tree) if __name__ == "__main__": main()
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Project Euler Problem 8: https://projecteuler.net/problem=8 Largest product in a series The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749 30358907296290491560440772390713810515859307960866 70172427121883998797908792274921901699720888093776 65727333001053367881220235421809751254540594752243 52584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482 83972241375657056057490261407972968652414535100474 82166370484403199890008895243450658541227588666881 16427171479924442928230863465674813919123162824586 17866458359124566529476545682848912883142607690042 24219022671055626321111109370544217506941658960408 07198403850962455444362981230987879927244284909188 84580156166097919133875499200524063689912560717606 05886116467109405077541002256983155200055935729725 71636269561882670428252483600823257530420752963450 Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product? """ from functools import reduce N = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950445244523161731856403098711121722383113" "62229893423380308135336276614282806444486645238749" "30358907296290491560440772390713810515859307960866" "70172427121883998797908792274921901699720888093776" "65727333001053367881220235421809751254540594752243" "52584907711670556013604839586446706324415722155397" "53697817977846174064955149290862569321978468622482" "83972241375657056057490261407972968652414535100474" "82166370484403199890008895243450658541227588666881" "16427171479924442928230863465674813919123162824586" "17866458359124566529476545682848912883142607690042" "24219022671055626321111109370544217506941658960408" "07198403850962455444362981230987879927244284909188" "84580156166097919133875499200524063689912560717606" "05886116467109405077541002256983155200055935729725" "71636269561882670428252483600823257530420752963450" ) def solution(n: str = N) -> int: """ Find the thirteen adjacent digits in the 1000-digit number n that have the greatest product and returns it. >>> solution("13978431290823798458352374") 609638400 >>> solution("13978431295823798458352374") 2612736000 >>> solution("1397843129582379841238352374") 209018880 """ return max( [ reduce(lambda x, y: int(x) * int(y), n[i : i + 13]) for i in range(len(n) - 12) ] ) if __name__ == "__main__": print(f"{solution() = }")
""" Project Euler Problem 8: https://projecteuler.net/problem=8 Largest product in a series The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749 30358907296290491560440772390713810515859307960866 70172427121883998797908792274921901699720888093776 65727333001053367881220235421809751254540594752243 52584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482 83972241375657056057490261407972968652414535100474 82166370484403199890008895243450658541227588666881 16427171479924442928230863465674813919123162824586 17866458359124566529476545682848912883142607690042 24219022671055626321111109370544217506941658960408 07198403850962455444362981230987879927244284909188 84580156166097919133875499200524063689912560717606 05886116467109405077541002256983155200055935729725 71636269561882670428252483600823257530420752963450 Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product? """ from functools import reduce N = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950445244523161731856403098711121722383113" "62229893423380308135336276614282806444486645238749" "30358907296290491560440772390713810515859307960866" "70172427121883998797908792274921901699720888093776" "65727333001053367881220235421809751254540594752243" "52584907711670556013604839586446706324415722155397" "53697817977846174064955149290862569321978468622482" "83972241375657056057490261407972968652414535100474" "82166370484403199890008895243450658541227588666881" "16427171479924442928230863465674813919123162824586" "17866458359124566529476545682848912883142607690042" "24219022671055626321111109370544217506941658960408" "07198403850962455444362981230987879927244284909188" "84580156166097919133875499200524063689912560717606" "05886116467109405077541002256983155200055935729725" "71636269561882670428252483600823257530420752963450" ) def solution(n: str = N) -> int: """ Find the thirteen adjacent digits in the 1000-digit number n that have the greatest product and returns it. >>> solution("13978431290823798458352374") 609638400 >>> solution("13978431295823798458352374") 2612736000 >>> solution("1397843129582379841238352374") 209018880 """ return max( [ reduce(lambda x, y: int(x) * int(y), n[i : i + 13]) for i in range(len(n) - 12) ] ) if __name__ == "__main__": print(f"{solution() = }")
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Project Euler Problem 3: https://projecteuler.net/problem=3 Largest prime factor The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? References: - https://en.wikipedia.org/wiki/Prime_number#Unique_factorization """ def solution(n: int = 600851475143) -> int: """ Returns the largest prime factor of a given number n. >>> solution(13195) 29 >>> solution(10) 5 >>> solution(17) 17 >>> solution(3.4) 3 >>> solution(0) Traceback (most recent call last): ... ValueError: Parameter n must be greater than or equal to one. >>> solution(-17) Traceback (most recent call last): ... ValueError: Parameter n must be greater than or equal to one. >>> solution([]) Traceback (most recent call last): ... TypeError: Parameter n must be int or castable to int. >>> solution("asd") Traceback (most recent call last): ... TypeError: Parameter n must be int or castable to int. """ try: n = int(n) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int.") if n <= 0: raise ValueError("Parameter n must be greater than or equal to one.") i = 2 ans = 0 if n == 2: return 2 while n > 2: while n % i != 0: i += 1 ans = i while n % i == 0: n = n / i i += 1 return int(ans) if __name__ == "__main__": print(f"{solution() = }")
""" Project Euler Problem 3: https://projecteuler.net/problem=3 Largest prime factor The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? References: - https://en.wikipedia.org/wiki/Prime_number#Unique_factorization """ def solution(n: int = 600851475143) -> int: """ Returns the largest prime factor of a given number n. >>> solution(13195) 29 >>> solution(10) 5 >>> solution(17) 17 >>> solution(3.4) 3 >>> solution(0) Traceback (most recent call last): ... ValueError: Parameter n must be greater than or equal to one. >>> solution(-17) Traceback (most recent call last): ... ValueError: Parameter n must be greater than or equal to one. >>> solution([]) Traceback (most recent call last): ... TypeError: Parameter n must be int or castable to int. >>> solution("asd") Traceback (most recent call last): ... TypeError: Parameter n must be int or castable to int. """ try: n = int(n) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int.") if n <= 0: raise ValueError("Parameter n must be greater than or equal to one.") i = 2 ans = 0 if n == 2: return 2 while n > 2: while n % i != 0: i += 1 ans = i while n % i == 0: n = n / i i += 1 return int(ans) if __name__ == "__main__": print(f"{solution() = }")
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" disjoint set Reference: https://en.wikipedia.org/wiki/Disjoint-set_data_structure """ class Node: def __init__(self, data): self.data = data def make_set(x): """ make x as a set. """ # rank is the distance from x to its' parent # root's rank is 0 x.rank = 0 x.parent = x def union_set(x, y): """ union two sets. set with bigger rank should be parent, so that the disjoint set tree will be more flat. """ x, y = find_set(x), find_set(y) if x.rank > y.rank: y.parent = x else: x.parent = y if x.rank == y.rank: y.rank += 1 def find_set(x): """ return the parent of x """ if x != x.parent: x.parent = find_set(x.parent) return x.parent def find_python_set(node: Node) -> set: """ Return a Python Standard Library set that contains i. """ sets = ({0, 1, 2}, {3, 4, 5}) for s in sets: if node.data in s: return s raise ValueError(f"{node.data} is not in {sets}") def test_disjoint_set(): """ >>> test_disjoint_set() """ vertex = [Node(i) for i in range(6)] for v in vertex: make_set(v) union_set(vertex[0], vertex[1]) union_set(vertex[1], vertex[2]) union_set(vertex[3], vertex[4]) union_set(vertex[3], vertex[5]) for node0 in vertex: for node1 in vertex: if find_python_set(node0).isdisjoint(find_python_set(node1)): assert find_set(node0) != find_set(node1) else: assert find_set(node0) == find_set(node1) if __name__ == "__main__": test_disjoint_set()
""" disjoint set Reference: https://en.wikipedia.org/wiki/Disjoint-set_data_structure """ class Node: def __init__(self, data): self.data = data def make_set(x): """ make x as a set. """ # rank is the distance from x to its' parent # root's rank is 0 x.rank = 0 x.parent = x def union_set(x, y): """ union two sets. set with bigger rank should be parent, so that the disjoint set tree will be more flat. """ x, y = find_set(x), find_set(y) if x.rank > y.rank: y.parent = x else: x.parent = y if x.rank == y.rank: y.rank += 1 def find_set(x): """ return the parent of x """ if x != x.parent: x.parent = find_set(x.parent) return x.parent def find_python_set(node: Node) -> set: """ Return a Python Standard Library set that contains i. """ sets = ({0, 1, 2}, {3, 4, 5}) for s in sets: if node.data in s: return s raise ValueError(f"{node.data} is not in {sets}") def test_disjoint_set(): """ >>> test_disjoint_set() """ vertex = [Node(i) for i in range(6)] for v in vertex: make_set(v) union_set(vertex[0], vertex[1]) union_set(vertex[1], vertex[2]) union_set(vertex[3], vertex[4]) union_set(vertex[3], vertex[5]) for node0 in vertex: for node1 in vertex: if find_python_set(node0).isdisjoint(find_python_set(node1)): assert find_set(node0) != find_set(node1) else: assert find_set(node0) == find_set(node1) if __name__ == "__main__": test_disjoint_set()
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
from typing import List def kmp(pattern: str, text: str) -> bool: """ The Knuth-Morris-Pratt Algorithm for finding a pattern within a piece of text with complexity O(n + m) 1) Preprocess pattern to identify any suffixes that are identical to prefixes This tells us where to continue from if we get a mismatch between a character in our pattern and the text. 2) Step through the text one character at a time and compare it to a character in the pattern updating our location within the pattern if necessary """ # 1) Construct the failure array failure = get_failure_array(pattern) # 2) Step through text searching for pattern i, j = 0, 0 # index into text, pattern while i < len(text): if pattern[j] == text[i]: if j == (len(pattern) - 1): return True j += 1 # if this is a prefix in our pattern # just go back far enough to continue elif j > 0: j = failure[j - 1] continue i += 1 return False def get_failure_array(pattern: str) -> List[int]: """ Calculates the new index we should go to if we fail a comparison :param pattern: :return: """ failure = [0] i = 0 j = 1 while j < len(pattern): if pattern[i] == pattern[j]: i += 1 elif i > 0: i = failure[i - 1] continue j += 1 failure.append(i) return failure if __name__ == "__main__": # Test 1) pattern = "abc1abc12" text1 = "alskfjaldsabc1abc1abc12k23adsfabcabc" text2 = "alskfjaldsk23adsfabcabc" assert kmp(pattern, text1) and not kmp(pattern, text2) # Test 2) pattern = "ABABX" text = "ABABZABABYABABX" assert kmp(pattern, text) # Test 3) pattern = "AAAB" text = "ABAAAAAB" assert kmp(pattern, text) # Test 4) pattern = "abcdabcy" text = "abcxabcdabxabcdabcdabcy" assert kmp(pattern, text) # Test 5) pattern = "aabaabaaa" assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]
from typing import List def kmp(pattern: str, text: str) -> bool: """ The Knuth-Morris-Pratt Algorithm for finding a pattern within a piece of text with complexity O(n + m) 1) Preprocess pattern to identify any suffixes that are identical to prefixes This tells us where to continue from if we get a mismatch between a character in our pattern and the text. 2) Step through the text one character at a time and compare it to a character in the pattern updating our location within the pattern if necessary """ # 1) Construct the failure array failure = get_failure_array(pattern) # 2) Step through text searching for pattern i, j = 0, 0 # index into text, pattern while i < len(text): if pattern[j] == text[i]: if j == (len(pattern) - 1): return True j += 1 # if this is a prefix in our pattern # just go back far enough to continue elif j > 0: j = failure[j - 1] continue i += 1 return False def get_failure_array(pattern: str) -> List[int]: """ Calculates the new index we should go to if we fail a comparison :param pattern: :return: """ failure = [0] i = 0 j = 1 while j < len(pattern): if pattern[i] == pattern[j]: i += 1 elif i > 0: i = failure[i - 1] continue j += 1 failure.append(i) return failure if __name__ == "__main__": # Test 1) pattern = "abc1abc12" text1 = "alskfjaldsabc1abc1abc12k23adsfabcabc" text2 = "alskfjaldsk23adsfabcabc" assert kmp(pattern, text1) and not kmp(pattern, text2) # Test 2) pattern = "ABABX" text = "ABABZABABYABABX" assert kmp(pattern, text) # Test 3) pattern = "AAAB" text = "ABAAAAAB" assert kmp(pattern, text) # Test 4) pattern = "abcdabcy" text = "abcxabcdabxabcdabcdabcy" assert kmp(pattern, text) # Test 5) pattern = "aabaabaaa" assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" The nested brackets problem is a problem that determines if a sequence of brackets are properly nested. A sequence of brackets s is considered properly nested if any of the following conditions are true: - s is empty - s has the form (U) or [U] or {U} where U is a properly nested string - s has the form VW where V and W are properly nested strings For example, the string "()()[()]" is properly nested but "[(()]" is not. The function called is_balanced takes as input a string S which is a sequence of brackets and returns true if S is nested and false otherwise. """ def is_balanced(S): stack = [] open_brackets = set({"(", "[", "{"}) closed_brackets = set({")", "]", "}"}) open_to_closed = dict({"{": "}", "[": "]", "(": ")"}) for i in range(len(S)): if S[i] in open_brackets: stack.append(S[i]) elif S[i] in closed_brackets: if len(stack) == 0 or ( len(stack) > 0 and open_to_closed[stack.pop()] != S[i] ): return False return len(stack) == 0 def main(): s = input("Enter sequence of brackets: ") if is_balanced(s): print(s, "is balanced") else: print(s, "is not balanced") if __name__ == "__main__": main()
""" The nested brackets problem is a problem that determines if a sequence of brackets are properly nested. A sequence of brackets s is considered properly nested if any of the following conditions are true: - s is empty - s has the form (U) or [U] or {U} where U is a properly nested string - s has the form VW where V and W are properly nested strings For example, the string "()()[()]" is properly nested but "[(()]" is not. The function called is_balanced takes as input a string S which is a sequence of brackets and returns true if S is nested and false otherwise. """ def is_balanced(S): stack = [] open_brackets = set({"(", "[", "{"}) closed_brackets = set({")", "]", "}"}) open_to_closed = dict({"{": "}", "[": "]", "(": ")"}) for i in range(len(S)): if S[i] in open_brackets: stack.append(S[i]) elif S[i] in closed_brackets: if len(stack) == 0 or ( len(stack) > 0 and open_to_closed[stack.pop()] != S[i] ): return False return len(stack) == 0 def main(): s = input("Enter sequence of brackets: ") if is_balanced(s): print(s, "is balanced") else: print(s, "is not balanced") if __name__ == "__main__": main()
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
def factors_of_a_number(num: int) -> list: """ >>> factors_of_a_number(1) [1] >>> factors_of_a_number(5) [1, 5] >>> factors_of_a_number(24) [1, 2, 3, 4, 6, 8, 12, 24] >>> factors_of_a_number(-24) [] """ return [i for i in range(1, num + 1) if num % i == 0] if __name__ == "__main__": num = int(input("Enter a number to find its factors: ")) factors = factors_of_a_number(num) print(f"{num} has {len(factors)} factors: {', '.join(str(f) for f in factors)}")
def factors_of_a_number(num: int) -> list: """ >>> factors_of_a_number(1) [1] >>> factors_of_a_number(5) [1, 5] >>> factors_of_a_number(24) [1, 2, 3, 4, 6, 8, 12, 24] >>> factors_of_a_number(-24) [] """ return [i for i in range(1, num + 1) if num % i == 0] if __name__ == "__main__": num = int(input("Enter a number to find its factors: ")) factors = factors_of_a_number(num) print(f"{num} has {len(factors)} factors: {', '.join(str(f) for f in factors)}")
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" The sum-of-subsetsproblem states that a set of non-negative integers, and a value M, determine all possible subsets of the given set whose summation sum equal to given M. Summation of the chosen numbers must be equal to given number M and one number can be used only once. """ from typing import List def generate_sum_of_subsets_soln(nums: List[int], max_sum: int) -> List[List[int]]: result: List[List[int]] = [] path: List[int] = [] num_index = 0 remaining_nums_sum = sum(nums) create_state_space_tree(nums, max_sum, num_index, path, result, remaining_nums_sum) return result def create_state_space_tree( nums: List[int], max_sum: int, num_index: int, path: List[int], result: List[List[int]], remaining_nums_sum: int, ) -> None: """ Creates a state space tree to iterate through each branch using DFS. It terminates the branching of a node when any of the two conditions given below satisfy. This algorithm follows depth-fist-search and backtracks when the node is not branchable. """ if sum(path) > max_sum or (remaining_nums_sum + sum(path)) < max_sum: return if sum(path) == max_sum: result.append(path) return for num_index in range(num_index, len(nums)): create_state_space_tree( nums, max_sum, num_index + 1, path + [nums[num_index]], result, remaining_nums_sum - nums[num_index], ) """ remove the comment to take an input from the user print("Enter the elements") nums = list(map(int, input().split())) print("Enter max_sum sum") max_sum = int(input()) """ nums = [3, 34, 4, 12, 5, 2] max_sum = 9 result = generate_sum_of_subsets_soln(nums, max_sum) print(*result)
""" The sum-of-subsetsproblem states that a set of non-negative integers, and a value M, determine all possible subsets of the given set whose summation sum equal to given M. Summation of the chosen numbers must be equal to given number M and one number can be used only once. """ from typing import List def generate_sum_of_subsets_soln(nums: List[int], max_sum: int) -> List[List[int]]: result: List[List[int]] = [] path: List[int] = [] num_index = 0 remaining_nums_sum = sum(nums) create_state_space_tree(nums, max_sum, num_index, path, result, remaining_nums_sum) return result def create_state_space_tree( nums: List[int], max_sum: int, num_index: int, path: List[int], result: List[List[int]], remaining_nums_sum: int, ) -> None: """ Creates a state space tree to iterate through each branch using DFS. It terminates the branching of a node when any of the two conditions given below satisfy. This algorithm follows depth-fist-search and backtracks when the node is not branchable. """ if sum(path) > max_sum or (remaining_nums_sum + sum(path)) < max_sum: return if sum(path) == max_sum: result.append(path) return for num_index in range(num_index, len(nums)): create_state_space_tree( nums, max_sum, num_index + 1, path + [nums[num_index]], result, remaining_nums_sum - nums[num_index], ) """ remove the comment to take an input from the user print("Enter the elements") nums = list(map(int, input().split())) print("Enter max_sum sum") max_sum = int(input()) """ nums = [3, 34, 4, 12, 5, 2] max_sum = 9 result = generate_sum_of_subsets_soln(nums, max_sum) print(*result)
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
from typing import List def median_of_two_arrays(nums1: List[float], nums2: List[float]) -> float: """ >>> median_of_two_arrays([1, 2], [3]) 2 >>> median_of_two_arrays([0, -1.1], [2.5, 1]) 0.5 >>> median_of_two_arrays([], [2.5, 1]) 1.75 >>> median_of_two_arrays([], [0]) 0 >>> median_of_two_arrays([], []) Traceback (most recent call last): ... IndexError: list index out of range """ all_numbers = sorted(nums1 + nums2) div, mod = divmod(len(all_numbers), 2) if mod == 1: return all_numbers[div] else: return (all_numbers[div] + all_numbers[div - 1]) / 2 if __name__ == "__main__": import doctest doctest.testmod() array_1 = [float(x) for x in input("Enter the elements of first array: ").split()] array_2 = [float(x) for x in input("Enter the elements of second array: ").split()] print(f"The median of two arrays is: {median_of_two_arrays(array_1, array_2)}")
from typing import List def median_of_two_arrays(nums1: List[float], nums2: List[float]) -> float: """ >>> median_of_two_arrays([1, 2], [3]) 2 >>> median_of_two_arrays([0, -1.1], [2.5, 1]) 0.5 >>> median_of_two_arrays([], [2.5, 1]) 1.75 >>> median_of_two_arrays([], [0]) 0 >>> median_of_two_arrays([], []) Traceback (most recent call last): ... IndexError: list index out of range """ all_numbers = sorted(nums1 + nums2) div, mod = divmod(len(all_numbers), 2) if mod == 1: return all_numbers[div] else: return (all_numbers[div] + all_numbers[div - 1]) / 2 if __name__ == "__main__": import doctest doctest.testmod() array_1 = [float(x) for x in input("Enter the elements of first array: ").split()] array_2 = [float(x) for x in input("Enter the elements of second array: ").split()] print(f"The median of two arrays is: {median_of_two_arrays(array_1, array_2)}")
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" Pure Python implementation of a binary search algorithm. For doctests run following command: python3 -m doctest -v simple_binary_search.py For manual testing run: python3 simple_binary_search.py """ from __future__ import annotations def binary_search(a_list: list[int], item: int) -> bool: """ >>> test_list = [0, 1, 2, 8, 13, 17, 19, 32, 42] >>> print(binary_search(test_list, 3)) False >>> print(binary_search(test_list, 13)) True >>> print(binary_search([4, 4, 5, 6, 7], 4)) True >>> print(binary_search([4, 4, 5, 6, 7], -10)) False >>> print(binary_search([-18, 2], -18)) True >>> print(binary_search([5], 5)) True >>> print(binary_search(['a', 'c', 'd'], 'c')) True >>> print(binary_search(['a', 'c', 'd'], 'f')) False >>> print(binary_search([], 1)) False >>> print(binary_search([-.1, .1 , .8], .1)) True >>> binary_search(range(-5000, 5000, 10), 80) True >>> binary_search(range(-5000, 5000, 10), 1255) False >>> binary_search(range(0, 10000, 5), 2) False """ if len(a_list) == 0: return False midpoint = len(a_list) // 2 if a_list[midpoint] == item: return True if item < a_list[midpoint]: return binary_search(a_list[:midpoint], item) else: return binary_search(a_list[midpoint + 1 :], item) if __name__ == "__main__": user_input = input("Enter numbers separated by comma:\n").strip() sequence = [int(item.strip()) for item in user_input.split(",")] target = int(input("Enter the number to be found in the list:\n").strip()) not_str = "" if binary_search(sequence, target) else "not " print(f"{target} was {not_str}found in {sequence}")
""" Pure Python implementation of a binary search algorithm. For doctests run following command: python3 -m doctest -v simple_binary_search.py For manual testing run: python3 simple_binary_search.py """ from __future__ import annotations def binary_search(a_list: list[int], item: int) -> bool: """ >>> test_list = [0, 1, 2, 8, 13, 17, 19, 32, 42] >>> print(binary_search(test_list, 3)) False >>> print(binary_search(test_list, 13)) True >>> print(binary_search([4, 4, 5, 6, 7], 4)) True >>> print(binary_search([4, 4, 5, 6, 7], -10)) False >>> print(binary_search([-18, 2], -18)) True >>> print(binary_search([5], 5)) True >>> print(binary_search(['a', 'c', 'd'], 'c')) True >>> print(binary_search(['a', 'c', 'd'], 'f')) False >>> print(binary_search([], 1)) False >>> print(binary_search([-.1, .1 , .8], .1)) True >>> binary_search(range(-5000, 5000, 10), 80) True >>> binary_search(range(-5000, 5000, 10), 1255) False >>> binary_search(range(0, 10000, 5), 2) False """ if len(a_list) == 0: return False midpoint = len(a_list) // 2 if a_list[midpoint] == item: return True if item < a_list[midpoint]: return binary_search(a_list[:midpoint], item) else: return binary_search(a_list[midpoint + 1 :], item) if __name__ == "__main__": user_input = input("Enter numbers separated by comma:\n").strip() sequence = [int(item.strip()) for item in user_input.split(",")] target = int(input("Enter the number to be found in the list:\n").strip()) not_str = "" if binary_search(sequence, target) else "not " print(f"{target} was {not_str}found in {sequence}")
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
from typing import Sequence def evaluate_poly(poly: Sequence[float], x: float) -> float: """Evaluate a polynomial f(x) at specified point x and return the value. Arguments: poly -- the coeffiecients of a polynomial as an iterable in order of ascending degree x -- the point at which to evaluate the polynomial >>> evaluate_poly((0.0, 0.0, 5.0, 9.3, 7.0), 10.0) 79800.0 """ return sum(c * (x ** i) for i, c in enumerate(poly)) def horner(poly: Sequence[float], x: float) -> float: """Evaluate a polynomial at specified point using Horner's method. In terms of computational complexity, Horner's method is an efficient method of evaluating a polynomial. It avoids the use of expensive exponentiation, and instead uses only multiplication and addition to evaluate the polynomial in O(n), where n is the degree of the polynomial. https://en.wikipedia.org/wiki/Horner's_method Arguments: poly -- the coeffiecients of a polynomial as an iterable in order of ascending degree x -- the point at which to evaluate the polynomial >>> horner((0.0, 0.0, 5.0, 9.3, 7.0), 10.0) 79800.0 """ result = 0.0 for coeff in reversed(poly): result = result * x + coeff return result if __name__ == "__main__": """ Example: >>> poly = (0.0, 0.0, 5.0, 9.3, 7.0) # f(x) = 7.0x^4 + 9.3x^3 + 5.0x^2 >>> x = -13.0 >>> # f(-13) = 7.0(-13)^4 + 9.3(-13)^3 + 5.0(-13)^2 = 180339.9 >>> print(evaluate_poly(poly, x)) 180339.9 """ poly = (0.0, 0.0, 5.0, 9.3, 7.0) x = 10.0 print(evaluate_poly(poly, x)) print(horner(poly, x))
from typing import Sequence def evaluate_poly(poly: Sequence[float], x: float) -> float: """Evaluate a polynomial f(x) at specified point x and return the value. Arguments: poly -- the coeffiecients of a polynomial as an iterable in order of ascending degree x -- the point at which to evaluate the polynomial >>> evaluate_poly((0.0, 0.0, 5.0, 9.3, 7.0), 10.0) 79800.0 """ return sum(c * (x ** i) for i, c in enumerate(poly)) def horner(poly: Sequence[float], x: float) -> float: """Evaluate a polynomial at specified point using Horner's method. In terms of computational complexity, Horner's method is an efficient method of evaluating a polynomial. It avoids the use of expensive exponentiation, and instead uses only multiplication and addition to evaluate the polynomial in O(n), where n is the degree of the polynomial. https://en.wikipedia.org/wiki/Horner's_method Arguments: poly -- the coeffiecients of a polynomial as an iterable in order of ascending degree x -- the point at which to evaluate the polynomial >>> horner((0.0, 0.0, 5.0, 9.3, 7.0), 10.0) 79800.0 """ result = 0.0 for coeff in reversed(poly): result = result * x + coeff return result if __name__ == "__main__": """ Example: >>> poly = (0.0, 0.0, 5.0, 9.3, 7.0) # f(x) = 7.0x^4 + 9.3x^3 + 5.0x^2 >>> x = -13.0 >>> # f(-13) = 7.0(-13)^4 + 9.3(-13)^3 + 5.0(-13)^2 = 180339.9 >>> print(evaluate_poly(poly, x)) 180339.9 """ poly = (0.0, 0.0, 5.0, 9.3, 7.0) x = 10.0 print(evaluate_poly(poly, x)) print(horner(poly, x))
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
import base64 def main(): inp = input("->") encoded = inp.encode("utf-8") # encoded the input (we need a bytes like object) a85encoded = base64.a85encode(encoded) # a85encoded the encoded string print(a85encoded) print(base64.a85decode(a85encoded).decode("utf-8")) # decoded it if __name__ == "__main__": main()
import base64 def main(): inp = input("->") encoded = inp.encode("utf-8") # encoded the input (we need a bytes like object) a85encoded = base64.a85encode(encoded) # a85encoded the encoded string print(a85encoded) print(base64.a85decode(a85encoded).decode("utf-8")) # decoded it if __name__ == "__main__": main()
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
MatthewG25
"2021-02-22T11:02:18Z"
"2021-02-23T09:02:31Z"
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I have not plagiarized. * [x] I know that pull requests will not be merged if they fail the automated tests. * [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. * [ ] All new Python files are placed inside an existing directory. * [x] All filenames are in all lowercase characters with no spaces or dashes. * [x] All functions and variable names follow Python naming conventions. * [x] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html). * [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing. * [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. * [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
""" https://en.wikipedia.org/wiki/Euclidean_algorithm """ def euclidean_gcd(a: int, b: int) -> int: """ Examples: >>> euclidean_gcd(3, 5) 1 >>> euclidean_gcd(6, 3) 3 """ while b: a, b = b, a % b return a def euclidean_gcd_recursive(a: int, b: int) -> int: """ Recursive method for euclicedan gcd algorithm Examples: >>> euclidean_gcd_recursive(3, 5) 1 >>> euclidean_gcd_recursive(6, 3) 3 """ return a if b == 0 else euclidean_gcd_recursive(b, a % b) def main(): print(f"euclidean_gcd(3, 5) = {euclidean_gcd(3, 5)}") print(f"euclidean_gcd(5, 3) = {euclidean_gcd(5, 3)}") print(f"euclidean_gcd(1, 3) = {euclidean_gcd(1, 3)}") print(f"euclidean_gcd(3, 6) = {euclidean_gcd(3, 6)}") print(f"euclidean_gcd(6, 3) = {euclidean_gcd(6, 3)}") print(f"euclidean_gcd_recursive(3, 5) = {euclidean_gcd_recursive(3, 5)}") print(f"euclidean_gcd_recursive(5, 3) = {euclidean_gcd_recursive(5, 3)}") print(f"euclidean_gcd_recursive(1, 3) = {euclidean_gcd_recursive(1, 3)}") print(f"euclidean_gcd_recursive(3, 6) = {euclidean_gcd_recursive(3, 6)}") print(f"euclidean_gcd_recursive(6, 3) = {euclidean_gcd_recursive(6, 3)}") if __name__ == "__main__": main()
""" https://en.wikipedia.org/wiki/Euclidean_algorithm """ def euclidean_gcd(a: int, b: int) -> int: """ Examples: >>> euclidean_gcd(3, 5) 1 >>> euclidean_gcd(6, 3) 3 """ while b: a, b = b, a % b return a def euclidean_gcd_recursive(a: int, b: int) -> int: """ Recursive method for euclicedan gcd algorithm Examples: >>> euclidean_gcd_recursive(3, 5) 1 >>> euclidean_gcd_recursive(6, 3) 3 """ return a if b == 0 else euclidean_gcd_recursive(b, a % b) def main(): print(f"euclidean_gcd(3, 5) = {euclidean_gcd(3, 5)}") print(f"euclidean_gcd(5, 3) = {euclidean_gcd(5, 3)}") print(f"euclidean_gcd(1, 3) = {euclidean_gcd(1, 3)}") print(f"euclidean_gcd(3, 6) = {euclidean_gcd(3, 6)}") print(f"euclidean_gcd(6, 3) = {euclidean_gcd(6, 3)}") print(f"euclidean_gcd_recursive(3, 5) = {euclidean_gcd_recursive(3, 5)}") print(f"euclidean_gcd_recursive(5, 3) = {euclidean_gcd_recursive(5, 3)}") print(f"euclidean_gcd_recursive(1, 3) = {euclidean_gcd_recursive(1, 3)}") print(f"euclidean_gcd_recursive(3, 6) = {euclidean_gcd_recursive(3, 6)}") print(f"euclidean_gcd_recursive(6, 3) = {euclidean_gcd_recursive(6, 3)}") if __name__ == "__main__": main()
-1