#problem-solving-with-safia
Explore tagged Tumblr posts
captainsafia · 7 years ago
Text
Problem solving with Safia: the optimizer’s dilemma
I have a confession to make.
I'm getting pretty bored of reading the Node codebase.
I know, I know. I've only been doing it for about three weeks now, but what can I say? I've got a rather short attention span. Maybe I'll get back to it at some point, but for now, I'd like to try some different things.
I was recently reminiscing about some of the things I liked doing when I first started coding in my teens. As it turns out, I liked solving some of the problems on Project Euler. In fact, I kept a little blog where I maintained the solutions for the problems that I was solving. I will avoid linking to that blog here because some things just need to die in obscurity.
Anyway, I figured that I would pick up where I left off and start solving some of the problems here and live-blogging my solutions as I write them.
It turns out that the last problem that I solved (or at least publicly blogged about the solution for) was problem 22 back in September of 2012. That would've been the start of my sophomore year in high school. Feels like centuries ago!
So with that in mind, I figured that I would start, six years later, by working on the solution for problem 23. It goes a little something like this.
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.
Alright! So the main goal here is to find the sum of all positive integers that cannot be written as the sum of two abundant numbers. The problem text also tells us that every number greater that 28,123 can be writtern as the sum of two abundant numbers. So this narrows down our search space to numbers between 0 and 28,123. That's a pretty large search space, although we have these things called computers that are stupid and fast and we can put them to work!
I'll admit that I used to be the kind of programmer who would sit and look at problems like these and try to cook up a clever solution right away. But I got older (and wiser) and realized that in most cases, you'd be totally find just throwing a for-loop at the problem. So I created a quick little template for what the solution would look like.
def abundant_terms_for_sum(x): fancy math stuff that I'm unsure of yet def non_abundant_sums(): total = 0 for x in range(28123): if not abundant_terms_for_sum(x): total += x return total
Pretty basic, right?
Side note: I'll be using Python 3 to solve these problems. That's the same programming language I used to solve them when I was a teenager. Although looking back at my blog, I solved some of them using Common Lisp. Maybe I'll take a crack at doing that now!
Now, since I first started solving these problems in my sophomore year of high school, I've had about 6 years of advanced algebra and calculus classes taught to me. That being said, I still have no clue what I'm doing when it comes to math. So I headed over to the good ol' trusty Google dot com to see if someone who liked numbers way more than me had figured out a clever way to determine whether a number could not be the sum of two abundant numbers.
Side note: If you can't be clever yourself, you can always leverage another person's cleverness!
I couldn't find anything useful on the Internet, so it turns out I'll have to use my own noggin for this one. I suppose the point of these problems is to put the noggin to work anyways...
So, my general strategy for things like this is to create an outline of the program with a scaffold of all the functions that I think I might need to call.
def generate_abundant_numbers(): create a list of the abundant numbers less than 28123 ABUNDANT_NUMBERS = generate_abundant_numbers() def abundant_terms_for_sum(x): for num in ABUNDANT_NUMBERS: difference = x - num if difference in ABUNDANT_NUMBERS: return True return False def non_abundant_sums(): total = 0 for x in range(28123): if not abundant_terms_for_sum(x): total += x return total
So basically, my plan is to generate a list of all the abundant numbers that are less than the boundary we set at 28,123 in a global called ABUNDANT_NUMBERS. Then, the abundant_terms_for_sum function will check if the terms of the sum of x are in ABUNDANT_NUMBERS and handle it appropirately. The only unfilled function here is the generate_abundant_numbers function. I did some hacking around to figure out if I could implement something using for-loops and mathy-math and came up with the following.
def get_proper_divisors(n): divisors = [] for x in range(1, n + 1): if n % x == 0 and n != x: divisors.append(x) return divisors def generate_abundant_numbers(): numbers = [] for x in range(28123): proper_divisors = get_proper_divisors(x) if sum(proper_divisors) > x: numbers.append(x) return numbers
Now, this piece of code took so long to run, I had to trim my hair by the time it was done running. Well not really, I actually ended up just halting it as it was checking the 93rd number but you get the gist.
The big culprit here is the fact that there are two iterations that go from 0 to 28123 so the time complexity (oh gosh, did I just use those words?!!?) of this particular implementation is O(n^2).
If this was a technical interview, this is the point where I would stare blankly at the screen and babble out my stream of concious to the poor person on the other end of the phone. Since I'm just doing this alone in my bedroom, I'm going to stare really hard at the code until some revelation hits me through some form of air-based diffusion.
Just stare really hard.
Keep staring.
And thinking.
So there are a few things that I can do here. The problem statement that 12 is the smallest abundant number. So I updated my code to refelct this.
def generate_abundant_numbers(): numbers = [] for x in range(12, 28123):
The next thing I realized was a problem with my abundant_terms_for_sum function. When iterating through each of the ABUNDANT_NUMBERS I needed to do a better job of skipping throug the abundant numbers I knew for sure were not part of the solution.
def abundant_terms_for_sum(x): for num in ABUNDANT_NUMBERS: if num > x: return False difference = x - num if difference in ABUNDANT_NUMBERS: return True return False
With these changes, I noticed that the program was running much, much faster. I hadn't actually done anything to alter the time complexity of the implementation, but the minor changes I made helped improve the run-time for the average case that I was dealing with.
At this point, I actually decided to let the program run all the way through. I still hadn't actually verified that my implementation was correct, so it was kind of silly for me to be working on optimizing something that might not have been totally accurate.
So I let this rather slow code run for a little bit while I went out and pretended that I wasn't really a robo — errr, while I cleaned up my apartment.
Once it was done running, I pasted the answer I got into the checker and found out I was correct. What a relief! Now I can do some more optimizations without
The next thing I did was make some improvements to the way that proper_divisors and generate_abundant_numbers worked. Overall, these changes reduce the space complexity of the program since I'm directly computing the sum of the proper divisors instead of storing the divisors in an array and then summing them up. This helped a little bit because as it turns out the time complexity of the sum function in Python is O(n).
def get_proper_divisors(n): total = 0 for x in range(1, n + 1): if n % x == 0 and n != x: total += x return total def generate_abundant_numbers(): numbers = [] for x in range(12, 28123): sum_proper_divisors = get_proper_divisors(x) if sum_proper_divisors > x: numbers.append(x) return numbers
Side note: I know I'm using the words time complexity a lot and it might be scary if you are a new programmer. You can read more about what time complexity is here or here but basically it is just a fancy way of answering the question "How long will this program take to run?"
The next thing I did was refactor the non_abundant_sums function to take advantage of list comprehensions.
def non_abundant_sums(): return sum([x for x in range(28123) if not abundant_terms_for_sum(x)])
So, my current solution thus far looks like this.
def get_proper_divisors(n): total = 0 for x in range(1, n + 1): if n % x == 0 and n != x: total += x return total def generate_abundant_numbers(): numbers = [] for x in range(12, 28123): sum_proper_divisors = get_proper_divisors(x) if sum_proper_divisors > x: numbers.append(x) return numbers ABUNDANT_NUMBERS = generate_abundant_numbers() def abundant_terms_for_sum(x): for num in ABUNDANT_NUMBERS: if num > x: return False difference = x - num if difference in ABUNDANT_NUMBERS: return True return False def non_abundant_sums(): return sum([x for x in range(28123) if not abundant_terms_for_sum(x)]) print(non_abundant_sums())
To be honest, it is still pretty hecking slow.
First and formost, the get_proper_divisors function takes a really long time to run. I optimized it using a pretty common optimization for factorization algorithm that relies on one of the properties of the factors of a number.
def get_proper_divisors(n): limit = math.sqrt(n) if limit.is_integer(): total = -limit else: total = 1 for x in range(2, int(limit) + 1): if n % x == 0: total += x + int(n / x) return total
The next thing I did was remove the reliance on abundant_terms_for_sum and just use Python's any function to check if there were any abundant terms that added up to a particular sum.
def non_abundant_sums(): total = 0 for x in range(28123): if not any((x - i in ABUNDANT_NUMBERS) for i in ABUNDANT_NUMBERS): total += x return total
Despite these changes, the program was still running a bit slow. Specifically, there were two for-loops in the code that iterated up to 28,123, the one in non_abundant_sums and the one in generate_abundant_numbers. I decided to combine these two functions together and avoid pre-allocating the dependent numbers. I also ended up using a set to store the date because I realized that we don't care much to have duplicate summation entries in our data set.
def non_abundant_sums(): total = 0 numbers = set() for x in range(28123): if get_proper_divisors(x) > x: numbers.add(x) if not any((x - i in numbers) for i in numbers): total += x return total
Sweet! Now the program runs a little faster. Here's the final code for the curious.
import math def get_proper_divisors(n): limit = math.sqrt(n) if limit.is_integer(): total = -limit else: total = 1 for x in range(2, int(limit) + 1): if n % x == 0: total += x + int(n / x) return total def non_abundant_sums(): total = 0 numbers = set() for x in range(28123): if get_proper_divisors(x) > x: numbers.add(x) if not any((x - i in numbers) for i in numbers): total += x return total print(non_abundant_sums())
So basically, I started off writing a lot of very simple code then I shaved a ton of it off. This is usually how things go for me when I'm solving problems. Just dump whatever I can onto the screen and then see if I can make it better!
There's a big life lesson in there somewhere….
1 note · View note
blackkudos · 5 years ago
Text
Robert Hooks
Tumblr media
Robert Hooks (born Bobby Dean Hooks, April 18, 1937) is an American actor, producer, and activist. He is most recognizable to the public for his more than 100 roles in films, television, and stage. Most famously, Hooks, along with Douglas Turner Ward and Gerald S. Krone, founded The Negro Ensemble Company (NEC). The NEC is credited with the launch of the careers of many major black artists of all disciplines, while creating a body of performance literature over the last thirty years, providing the backbone of African-American theatrical classics. Additionally, Hooks is the sole founder of two significant black theatre companies: the D.C. Black Repertory Company, and New York's Group Theatre Workshop.
Biography
Early life
The youngest of five children, Hooks was born in Foggy Bottom, Washington, D.C. to Mae Bertha (née Ward), a seamstress, and Edward Hooks who had moved from Rocky Mount, North Carolina with their four other children, Bernice, Caroleigh, Charles Edward "Charlie", and James Walter "Jimmy". Named Bobby Dean Hooks at birth, Robert was their first child born "up-north" and the first to be born in a hospital. His father, Edward, died in a work accident on the railroad in 1939.
Hooks attended Stevens Elementary School. In 1945, at the insistence of his sister Bernice who was doing community arts outreach for youngsters at Francis Junior High School, he performed the lead in his first play, The Pirates of Penzance, at the age of nine. From the ages of 6 to 12, Bobby Dean journeyed with his siblings to Lucama, North Carolina to work the tobacco fields for his uncle's sharecropping farm as a way to help earn money for the coming school year in D.C.
In 1954, just as Brown vs. Board of Education was being implemented in the north, he moved to Philadelphia to be with his mother, her second husband, and his half-sister, Safia Abdullah (née Sharon Dickerson). Hooks experienced his first integrated school experience at West Philadelphia High School. Hooks soon joined the drama club and began acting in plays by William Shakespeare and Samuel Beckett. He was graduated in 1956, passing on a scholarship to Temple University in order to pursue a career as a stage actor at the Bessie V. Hicks School of Theatre (alongside Charles Dierkop and Bruce Dern, with whom he second-acted plays doing their pre-Broadway tryouts in Philadelphia) while working at Browning King, a men's tailor shop at Fourteenth and Chestnut streets.
Career
Having trained at the Bessie V. Smith School of Theatre in Philadelphia, and after seeing A Raisin in the Sun in its Philadelphia tryout in February 1959, Hooks moved to New York to pursue acting. In April 1960, as Bobby Dean Hooks, he made his Broadway debut in A Raisin in the Sun replacing Louis Gossett, Jr. who would be doing the film version. He then continued to do its national tour. He then stepped into the Broadway production of A Taste of Honey, replacing Billy Dee Williams; then repeating the same national tour trajectory as he had done for "Raisin..." the previous year. In early 1962 he next appeared as the lead in Jean Genet's The Blacks, replacing James Earl Jones as the male lead, leaving briefly that same year to appear on Broadway again in Tiger, Tiger, Burning Bright before stepping back into the lead role in The Blacks in 1963. He then returned to Broadway, first in Ballad for Bimshire and then in the short-lived 1964 David Merrick revival of The Milk Train Doesn't Stop Here Any More (as a character created by Tennessee Williams for this revival) and starring Tallulah Bankhead and Tab Hunter in his only stage performance. Immediately thereafter, in March 24, 1964 he originated the role of Clay in Amiri Baraka's Dutchman. With this play, on the advice of Roscoe Lee Brown, Hooks became known as, Robert Hooks. He also originated roles on the New York stage in Where's Daddy? for which he won the Theatre World Award and he was nominated for Best Male Lead in a Musical for Hallelujah Baby while he was simultaneously starring in David Susskind's N.Y.P.D.—the first African American lead on a television drama.
In 1968 Hooks was the host of the new public affairs television program, Like It Is.
Hooks was nominated for a Tony for his lead role in the musical, Hallelujah, Baby!, has received both the Pioneer Award and the NAACP Image Award for Lifetime Achievement, and has been inducted into the Black Filmmakers Hall of Fame. He also won an Emmy for his PBS special, Voices of Our People.
Significant roles for which Hooks is known include Reeve Scott in Hurry Sundown (1967), Mr. T. in the blaxploitation film Trouble Man (1972), grandpa Gene Donovan in the comedy Seventeen Again (2000), and Fleet Admiral Morrow in Star Trek III: The Search for Spock (1984). He also appeared on television in an episode of the NBC crime drama series The Eddie Capra Mysteries in 1978 and portrayed Doctor Walcott in the 1980s television series Dynasty.
Activism
Arts and Culture
In 1964, as a result of a speaking engagement at the Chelsea Civil Rights Committee (then connected to the Hudson Guild Settlement House) he founded The Group Theatre Workshop (GTW), a tuition-free environment for disadvantaged urban teens who expressed a desire to explore acting. Among the instructors were Barbara Ann Teer, Frances Foster, Hal DeWindt, Lonne Elder III, and Ronnie Mack. Alumni include Antonio Fargas, Hattie Winston, and Daphne Maxwell Reid.
The Group Theatre Workshop was folded into the tuition-free training arm of the The Negro Ensemble Company (NEC) founded in 1967 with Douglas Turner Ward and Gerald S. Krone with a $1.3 million grant from the Ford Foundation under the auspices of W. McNeil Lowry.
From 1969-1972, Hooks served as an original board member of Black Academy of Arts and Letters (BAAL) (located in New York) alongside C. Eric Lincoln, President; John O. Killens, Alvin F. Poussaint, and Charles White. Chartered by the State of New York, BAAL's mission was to bring together Black artists and scholars from around the world. Additional members included: Julian Adderley, Alvin Ailey, Margaret Walker, James Baldwin, Imamu Baraka, Romare Bearden, Harry Belafonte, Lerone Bennett, Arna Bontemps, Ossie Davis, Ruby Dee Davis, St. Clair Drake, Ernest Dunbar, Katherine Dunham, Lonne Elder III, Duke Ellington, Alex Haley, Ruth Inge Hardison, Vertis Hayes, Chester Himes, Lena Horne, Jacob Lawrence, Elma Lewis, Henry Lewis, Paule Marshall, Donald McKayle, Arthur Mitchell, Frederick O’Neal, Gordon Parks, Sidney Poitier, Benjamin Quarles, Lloyd Richards, Lucille D. Roberts, and Nina Simone.
In response to the violence in his home town of Washington, D.C. in the wake of the Rev. Dr. Martin Luther King, Jr.'s assassination, and aided by a small grant from the Eugene and Agnes E. Meyer Foundation, Hooks took a leave of absence from the Negro Ensemble Company to create The D.C. Black Repertory Company (DCBRC, 1970-1981). As Founder and Executive Director, the DCBRC was intended as a further exploration of the ability of the arts to create healing. The a capella group Sweet Honey in the Rock was created and developed within its workshop process.
The Inner Voices (Lorton Prison arts training program, 1971) proved to be a result of the beneficial effect of the DCBRC in the D.C. area. In response to a direct plea from an inmate, Rhozier "Roach" Brown, who was serving a life sentence in Lorton, Hooks' D.C. Black Repertory Company structured the first prison-based arts program in the United States. While it is the norm now, it was then a revolutionary attempt at rehabilitation through the arts. Eventually The Inner Voices performed more than 500 times in other prisons, including a Christmas special entitled, "Holidays, Hollowdays." Due to Roach's work, President Gerald Ford commuted his sentence on Christmas Day, 1975.
His relocation to the West Coast redirected Hooks' approach to parity in the arts with his involvement with The Bay Area Multicultural Arts Initiative (1988) as a board member and grant facilitator-judge. Funded by monies from a unique coalition made up of the San Francisco Foundation (a community foundation); Grants for the Arts of the San Francisco Hotel Tax Fund, and The National Endowment for the Arts, the function of this organization was the funding of deserving local multicultural arts organizations.
In 1992, Hooks co-founded (with writer Lonne Elder III) Arts in Action. Located in South Central Los Angeles, this was a film and television training center established to guide individuals who aspired to careers in film production. It formulated strategies and training for securing entry-level jobs. Courses included: career development workshops; pre-production and production for film and television; creative problem solving in production management; directing for stage and screen—principles and practices; also the craft of assistant directors, script supervisor, technicians, wardrobe, make-up, etc.
The Negro Ensemble Company of Los Angeles (NEC-LA) (1994-1997) was created because so many New York members and original members had relocated to the west coast. Hooks, as founder and executive director enlisted alumni from his New York Negro Ensemble Company to serve as board members: Denise Nicholas, Denzel Washington, James Earl Jones, Laurence Fishburne, Richard Roundtree, Samuel L. Jackson. NEC-LA's goal was to be a new and innovative multi-ethnic cultural project that strived to achieve the community effectiveness and professional success of its parent organization.
Personal life
Hooks is the father of actor, television and film director Kevin Hooks. He married Lorrie Gay Marlow (actress, author, artist) on June 15, 2008. Previously, he was married to Yvonne Hickman and Rosie Lee Hooks.
Awards
1966 - Theatre World Award (1965–66 ) for "Where's Daddy?" (The Billy Rose Theatre)
1979 - American Black Achievement Award - Ebony Magazine
1982 - Emmy Award for Producing (1982) Voices of Our People: In Celebration of Black Poetry (KCET-TV/PBS)
1966 - Tony Nomination, Lead Role in a Musical for Hallelujah, Baby
1985 - Inducted into The Black Filmmakers Hall of Fame, recipient Oscar Micheaux Award (1985)
1986 - March 2nd declared Robert Hooks Day by the City of Los Angeles, Mayor Tom Bradley
1987 - Excellence in Advertising and Communications to Black Communities from CEBA (Excellence in Advertising and Communications to Black Communities)
2000 - Honorary Doctor of Humane Letters, Honoris Causa honorary degree, Bowie State University
2000 - May 25th declared Robert Hooks Day in Washington, D.C.
2005 - Beverly Hills/Hollywood Chapter NAACP Image Award for Lifetime Achievement
2005 - Beverly Hills/Hollywood Chapter NAACP Trailblazer Award to the Negro Ensemble Company
2005 - Trailblazer Award – City of Los Angeles
2006 - The Black Academy of Arts and Letters (TBAAL), Lifetime Achievement Award (Dallas)
2007 - The Black Theatre Alliance Awards / Lifetime Achievement Award
2015 - Living Legend Award (2015) National Black Theatre Festival
2018 - October 18th proclaimed Robert Hooks Day by Mayor Muriel Bowser, Washington, D.C.
2018 - Hooks is entered into The Congressional Record by the Hon. Eleanor Holmes Norton, September 4, 2018, Vol. 164
2018 - Visionary Founder and Creator Award - D.C. Black Repertory Company on its 47th anniversary
Acting Credits
Film
Sweet Love, Bitter (1967) .... Keel Robinson
Hurry Sundown (1967) .... Reeve Scott
Last of the Mobile Hot Shots (1970) .... Chicken
Carter's Army (1970) .... Lt. Edward Wallace
Trouble Man (1972) .... Mr. T
Aaron Loves Angela (1975) .... Beau
Airport '77 (1977) .... Eddie
Fast-Walking (1982) .... William Galliot
Star Trek III: The Search for Spock (1984) .... Admiral Morrow
Passenger 57 (1992) .... Dwight Henderson
Posse (1993) .... King David
Fled (1996) .... Lt. Clark
10 notes · View notes
trendingnewsb · 8 years ago
Text
Four ideas to tackle coffee cup waste
Image copyright Getty creative
Image caption Is the price of our growing addiction to takeaway hot drinks an ever higher mountain of landfill?
Since last year, when we were all made aware of the UK’s unrecycled cup mountain, some of us have found it hard to buy a takeaway coffee without being wracked with guilt.
In the UK, we throw away an estimated 2.5 billion disposable coffee cups every year. In theory, they are “recyclable”, but in practice, only a tiny percentage is dealt with sustainably.
Yet so far, there’s no agreed way forward.
Parliament’s environmental audit committee has been hearing the latest thoughts from campaigners and industry on how we can improve on our record in this area.
A lot of the biggest names in takeaway beverages, including Caffe Nero, Costa Coffee, McDonald’s, Pret A Manger and Starbucks, have signed up to a scheme to collect and recycle more of the current type of cups. Costa is also collecting cups from rival brands in its shops.
But others believe a more fundamental rethink would work better.
Here are four ways the coffee cup waste problem might be tackled.
1. Frugalpac: ‘Just change the cups’
Conventional cups can be recycled, but only in special facilities, thanks to the lamination that makes them waterproof.
Frugalpac, based in Ipswich in the UK, manufactures cardboard cups that can be recycled in regular recycling plants.
Image copyright Frugalcup
“We looked at this three years ago: everyone was blaming someone else, the cup makers, the coffee shops, councils. We thought, why don’t we go out there and solve the problem?” says Frugalpac’s founder, Martin Myerscough.
He has a patent for his cup – made of recycled materials, with an only very lightly attached plastic lining (representing about 10% of the weight of the cup), that separates easily during recycling.
It’s a more pragmatic solution, he argues, than trying to set up specialist collection points for conventional cups, because we already have recycling bins.
He has done trials with independent coffee shops and is working with Starbucks.
Of course, consumers will still have to remember to put them in the right bin, and he is still working on replacing the plastic lid.
2. CupClub: ‘Like city bike rental for cups’
Safia Qureshi points to chai wallahs in India as one of her initial inspirations. There, tea is poured into glasses that are washed and reused. We all used to drink milk and Coca Cola from returnable, reusable bottles.
So why not coffee?
Image copyright Bailey-Oscar
“The current model for reusable cups is that the consumer needs to buy the cup and take it in. The ratio of consumers doing that is 2% of all the total coffee sold,” she points out.
Instead, she proposes that the customer joins Cup Club and picks up a reusable cup when they buy their coffee. It can be returned later to one of several collection points. Cup Club is responsible for collecting washing and redistributing the clean cups to participating retailers.
Because the cups are tagged and registered to your account – using RFID, the same technology that’s on an Oyster travel card – Cup Club can text you a reminder if you’ve forgotten to return a cup and charge you if you keep it.
Image copyright Cup Club
“I’m very passionate about putting an end to products that are only used one time,” says Ms Quereshi “It’s a selfish and arrogant stance.”
She’s starting with company offices and universities, but is aiming ultimately for a London-wide scheme.
Its success will rely on enough retailers subscribing, but she has received an Ellen MacArthur Circular Design Challenge award, which will support her in developing the idea further.
3. TrioCup: the origami cup
Tom Chan, an engineering student from Hong Kong studying in the US, said he saw the coffee cups piling up in the rubbish bins outside his university building and wanted to do something about it.
He has now patented his TrioCup, a triangular-shaped cardboard cup, with sticking up flaps “like bunny ears”. Those ears can be folded down and tucked in to close it.
The entire cup is recyclable and, without the need for a separate plastic lid, potentially cheaper than normal cups.
Image copyright TrioCup
“I decided if I were to make a new cup, it needed to have more features than just being eco-friendly,” he says.
So he aimed for some other selling points too, such as spill-resistance.
“From my anecdotal research, a lot more people spill their coffee than you think.”
He says you can drop a TrioCup from waist height and most of the coffee will stay in the cup.
He thinks the shape makes the cups easier to hold and gives them “a cool aesthetic”.
Even the origami folding technique is pretty simple, he says.
Image copyright TrioCup
Next month, Mr Chan, another recipient of an Ellen MacArthur award, will be making several thousand cups per week for use in the university coffee shop.
4. Cupffee: the edible cup
The ultimate waste-free cup, though, must be this: a coffee cup made of cereals that you can munch on like an ice cream cone, once you’ve downed your drink.
Image copyright Cupffee
Three friends from Plovdiv in Bulgaria, Miroslav Zaprjanov, Mladen Dzhalazov and Simeon Gavrilov, came up with their “waffle” recipe containing no preservatives, colourings or coatings a few years ago and have been working on commercialising it ever since.
Apparently slightly sweet and crisp, it will hold your coffee for up to 40 minutes. And if you decide not to snack on it, it will biodegrade within weeks.
They say they were inspired by a desire to change the world. They might only be changing the diets of a limited number of Bulgarian coffee drinkers, but they are ambitious.
The cups do have a limited shelf life, so it’s probably not one for the big coffee chains.
But many other firms are thinking along similar lines, at least when it comes to compostable cups.
Companies such as Bristol-based Planglow have successfully commercialised what they say is fully biodegradable food packaging, including coffee cups.
And they boast clients from restaurants to contract caterers, sandwich shops to Parliament, so policy makers presumably are familiar with this option.
View comments
Related Topics
Recycling
Read more: http://ift.tt/2hAy7xw
from Viral News HQ http://ift.tt/2hhneBh via Viral News HQ
0 notes
newsroom-digital-blogs · 8 years ago
Text
Things We Read This Week
Illustration by Kevin Zweerink for The New York Times
Welcome to Things We Read This Week, a weekly post featuring articles from around the internet recommended by New York Times team members. This is where we articles we read and liked, things that made us think and things we couldn’t stop talking about. Check back every Friday for a new post.
Accessibility Feedback from Twitter
Safia Abdalla recently started a thread on Twitter asking people with disabilities to share their biggest frustrations when navigating the web. The responses have been consolidated in this blog post and they share a unique and personal view on accessibility. When designing and building websites, we usually think about users with visual impairments and those who are hard of hearing or deaf, but this list reminds us the variety of access is much larger. - Recommended by John Schimmel, Senior Integration Engineer, NYT Beta
The App That Does Nothing
This is a great piece about Binky, a social networking app where comments are pre-generated and interactions are futile. Binky asks us to question the nature of our relationship to social media: is tapping and scrolling just as meaningful if the content is fake? - Recommended by Caroline Cox-Orrell, Project Manager for Data & Insights
Are Your Solving the Right Problems?
How do you figure out what your company’s real problems are? This great article from Harvard Business Review explains how reframing a problem can produce wildly different perspectives and gives practical steps to help find effective solutions. - Recommended by Modupe Akinnawonu, Product Manager, Android App
Things We Read This Week was originally published in Times Open on Medium, where people are continuing the conversation by highlighting and responding to this story.
from Times Open - Medium http://ift.tt/2sVGLtP via IFTTT
0 notes
captainsafia · 7 years ago
Text
Solving a problem then thinking too hard about how you solved the problem
Another Wednesday, another blog post!
Today, I'm gonna be working on a Project Euler problem. Gotta keep those problem-solving skills sharp! Know what I mean?
In my last blog post, I completed the 23rd challenge. So today, it's time to work on the 24th problem. The text for the problem is as follows.
A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are:
012 021 102 120 201 210
What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?
So as I mentioned in a previous post, my problem-solving strategy for these kinds of things (and many others) is just to implement the simplest thing that solves the problem. I'm not thinking about performance or elegance or whatever. I'm just getting it done! Anyway, in this situation, getting it done looks like this.
import itertools digits = "0123456789" permutations = list(itertools.permutations(digits)) print(permutations[999999])
So, what's the answer to the challenge?!!?
> ('2', '7', '8', '3', '9', '1', '5', '4', '6', '0')
As it turns out, this is the correct response!
There's one more thing though. Although this solution runs pretty quickly and produces the correct output, it takes up a lot of space. So, here's why. The itertools.permutations function returns an iterator. This is a Python object that computes and returns the values stored in it one by one. When I invoke list on that iterator, I'm asking it to invoke next repeatedly and save all the results in a list. This would make sense if I wanted to do some operation that involves storing all the permutations of digits but I don't. So, a more time-efficient and space-efficient (and correct) implementation of the solution would be as follows.
import itertools digits = "0123456789" permutations = itertools.permutations(digits) i = 0 for permutation in permutations: if i == 999999: print(permutation) break i += 1
It's a little bit more verbose. There are probably ways to reduce this verbosity, but I think what I have written here is fine. Let me know if you can come up with something less verbose but still easily understandable!
Side note: That's always the caveat isn't it. The "easily understandable" bit. It's one of the big reasons I've long left my "clever code" phase.
Now, if it ended here, this would be a pretty boring blog post. But I wanna talk a little bit about that "simplest possible solution" that I provided above.
I started working on Project Euler problems when I was about 14 years old. I did 20-odd of them before I stopped. At that time, my solutions used a lot of fundamental programming concepts like iteration and list-building. Several years later, instead of going to those ideas as my go-to solution for some problems, I can better leverage the Python standard library to solve them.
I'm pretty proud of myself for that.
It probably seems subtle and not-that-big-a-deal but, to me, that transformation represents expertise and the accumulation of intellectual capital. I think a big part of being a good programmer (or being a good anyone-who-does-something) is continuously pushing what you can produce when you utilize the lowest effort. How good is the thing that you create when you invest very little intellectual energy on your behalf? How efficient can you become at utilizing brain power?
I'm not going to pretend to be the first person who's had this revelation. If the Industrial Age represented humanity's efforts to utilize and allocate mechanical energy efficiently, then the Information Age is a representation of our efforts to more efficiently use and allocate intellectual energy.
That being said, if I were to describe the things that contributed the most to my ability to allocate intellectual energy to solving technical problems more efficiently, it would be the following:
Prior knowledge. Standing on the shoulders of giants. Collective intelligence. You catch the drill.
Practice. Pattern recognition. More practice. Developing habits.
Foresight acquired by experience.
The first point has been recognized and attributed to by many a person throughout history. Our ability to push our knowledge forward is dependent on our ability to leverage the amount of knowledge that was produced by those who came before us. Whether you're a software engineer using open source software or a mathematician utilizing an axiom proved by another person, the ability to look at the existing body of work in any field and leverage it appropriately has been extraordinary.
The second point has also been recognized. The more I do something, the better my brain gets at automating the "boring" parts of it. I'll admit that for the most part, a lot of programming tasks are pretty dull for me. It's not because I don't enjoy programming, it's because the amount of intellectual energy that I need to address a particular problem has been dramatically reduced.
The third point is one that I am still working on. I'm trying to get to a point where I can use my past experiences to develop an almost clairvoyant perception of future outcomes. I don't have a solid recipe for doing this yet because it's something that I'm still growing (and will probably continue to develop for the rest of my life), but I'm working on it.
So yeah, I think my own experiences with growing and learning to expand less intellectual energy on problems as a software programmer is part of a general trend that humanity is following. We are getting better at doing more with less. Pessimists might claim that this trend will push us to become lazy and disengaged with problems. Optimists might argue that this trend will drive us to take on bigger and bigger problems to challenge our intellectual abilities. I think the reality is probably somewhere in between.
Wow! This blog post took a sharp turn at some point, didn't it? It's just a showcase of how my mind thinks about things!
I promise the next one won't have any tangents...
EDIT: Someone reached out to me via email with a solution implementation that is slightly more performant. Here's a screencap of the solution and a brief explanation in my response of why it is.
0 notes
trendingnewsb · 8 years ago
Text
Four ideas to tackle coffee cup waste
Image copyright Getty creative
Image caption Is the price of our growing addiction to takeaway hot drinks an ever higher mountain of landfill?
Since last year, when we were all made aware of the UK’s unrecycled cup mountain, some of us have found it hard to buy a takeaway coffee without being wracked with guilt.
In the UK, we throw away an estimated 2.5 billion disposable coffee cups every year. In theory, they are “recyclable”, but in practice, only a tiny percentage is dealt with sustainably.
Yet so far, there’s no agreed way forward.
Parliament’s environmental audit committee has been hearing the latest thoughts from campaigners and industry on how we can improve on our record in this area.
A lot of the biggest names in takeaway beverages, including Caffe Nero, Costa Coffee, McDonald’s, Pret A Manger and Starbucks, have signed up to a scheme to collect and recycle more of the current type of cups. Costa is also collecting cups from rival brands in its shops.
But others believe a more fundamental rethink would work better.
Here are four ways the coffee cup waste problem might be tackled.
1. Frugalpac: ‘Just change the cups’
Conventional cups can be recycled, but only in special facilities, thanks to the lamination that makes them waterproof.
Frugalpac, based in Ipswich in the UK, manufactures cardboard cups that can be recycled in regular recycling plants.
Image copyright Frugalcup
“We looked at this three years ago: everyone was blaming someone else, the cup makers, the coffee shops, councils. We thought, why don’t we go out there and solve the problem?” says Frugalpac’s founder, Martin Myerscough.
He has a patent for his cup – made of recycled materials, with an only very lightly attached plastic lining (representing about 10% of the weight of the cup), that separates easily during recycling.
It’s a more pragmatic solution, he argues, than trying to set up specialist collection points for conventional cups, because we already have recycling bins.
He has done trials with independent coffee shops and is working with Starbucks.
Of course, consumers will still have to remember to put them in the right bin, and he is still working on replacing the plastic lid.
2. CupClub: ‘Like city bike rental for cups’
Safia Qureshi points to chai wallahs in India as one of her initial inspirations. There, tea is poured into glasses that are washed and reused. We all used to drink milk and Coca Cola from returnable, reusable bottles.
So why not coffee?
Image copyright Bailey-Oscar
“The current model for reusable cups is that the consumer needs to buy the cup and take it in. The ratio of consumers doing that is 2% of all the total coffee sold,” she points out.
Instead, she proposes that the customer joins Cup Club and picks up a reusable cup when they buy their coffee. It can be returned later to one of several collection points. Cup Club is responsible for collecting washing and redistributing the clean cups to participating retailers.
Because the cups are tagged and registered to your account – using RFID, the same technology that’s on an Oyster travel card – Cup Club can text you a reminder if you’ve forgotten to return a cup and charge you if you keep it.
Image copyright Cup Club
“I’m very passionate about putting an end to products that are only used one time,” says Ms Quereshi “It’s a selfish and arrogant stance.”
She’s starting with company offices and universities, but is aiming ultimately for a London-wide scheme.
Its success will rely on enough retailers subscribing, but she has received an Ellen MacArthur Circular Design Challenge award, which will support her in developing the idea further.
3. TrioCup: the origami cup
Tom Chan, an engineering student from Hong Kong studying in the US, said he saw the coffee cups piling up in the rubbish bins outside his university building and wanted to do something about it.
He has now patented his TrioCup, a triangular-shaped cardboard cup, with sticking up flaps “like bunny ears”. Those ears can be folded down and tucked in to close it.
The entire cup is recyclable and, without the need for a separate plastic lid, potentially cheaper than normal cups.
Image copyright TrioCup
“I decided if I were to make a new cup, it needed to have more features than just being eco-friendly,” he says.
So he aimed for some other selling points too, such as spill-resistance.
“From my anecdotal research, a lot more people spill their coffee than you think.”
He says you can drop a TrioCup from waist height and most of the coffee will stay in the cup.
He thinks the shape makes the cups easier to hold and gives them “a cool aesthetic”.
Even the origami folding technique is pretty simple, he says.
Image copyright TrioCup
Next month, Mr Chan, another recipient of an Ellen MacArthur award, will be making several thousand cups per week for use in the university coffee shop.
4. Cupffee: the edible cup
The ultimate waste-free cup, though, must be this: a coffee cup made of cereals that you can munch on like an ice cream cone, once you’ve downed your drink.
Image copyright Cupffee
Three friends from Plovdiv in Bulgaria, Miroslav Zaprjanov, Mladen Dzhalazov and Simeon Gavrilov, came up with their “waffle” recipe containing no preservatives, colourings or coatings a few years ago and have been working on commercialising it ever since.
Apparently slightly sweet and crisp, it will hold your coffee for up to 40 minutes. And if you decide not to snack on it, it will biodegrade within weeks.
They say they were inspired by a desire to change the world. They might only be changing the diets of a limited number of Bulgarian coffee drinkers, but they are ambitious.
The cups do have a limited shelf life, so it’s probably not one for the big coffee chains.
But many other firms are thinking along similar lines, at least when it comes to compostable cups.
Companies such as Bristol-based Planglow have successfully commercialised what they say is fully biodegradable food packaging, including coffee cups.
And they boast clients from restaurants to contract caterers, sandwich shops to Parliament, so policy makers presumably are familiar with this option.
View comments
Related Topics
Recycling
Read more: http://ift.tt/2hAy7xw
from Viral News HQ http://ift.tt/2hhneBh via Viral News HQ
0 notes
newsroom-digital-blogs · 8 years ago
Text
Things We Read This Week
Illustration by Kevin Zweerink for The New York Times
Welcome to Things We Read This Week, a weekly post featuring articles from around the internet recommended by New York Times team members. This is where we articles we read and liked, things that made us think and things we couldn’t stop talking about. Check back every Friday for a new post.
Accessibility Feedback from Twitter
Safia Abdalla recently started a thread on Twitter asking people with disabilities to share their biggest frustrations when navigating the web. The responses have been consolidated in this blog post and they share a unique and personal view on accessibility. When designing and building websites, we usually think about users with visual impairments and those who are hard of hearing or deaf, but this list reminds us the variety of access is much larger. - Recommended by John Schimmel, Senior Integration Engineer, NYT Beta
The App That Does Nothing
This is a great piece about Binky, a social networking app where comments are pre-generated and interactions are futile. Binky asks us to question the nature of our relationship to social media: is tapping and scrolling just as meaningful if the content is fake? - Recommended by Caroline Cox-Orrell, Project Manager for Data & Insights
Are Your Solving the Right Problems?
How do you figure out what your company’s real problems are? This great article from Harvard Business Review explains how reframing a problem can produce wildly different perspectives and gives practical steps to help find effective solutions. - Recommended by Modupe Akinnawonu, Product Manager, Android App
Things We Read This Week was originally published in Times Open on Medium, where people are continuing the conversation by highlighting and responding to this story.
from Times Open - Medium http://ift.tt/2sVGLtP via IFTTT
0 notes