Our education system
11 year(s) ago uolter comments
our education system pic.twitter.com/FvApBGi5o9
— banksy (@thereaIbanksy) February 17, 2015
team calendaring system
11 year(s) ago uolter comments
You have been given a team calendaring system where a meeting is stored as a tuple of integers (start_time, end_time) . These integers represent the number of 30-minute blocks past 9:00am. You have been tasked with working out times when the whole team is busy.
For example: (2, 3) # meeting from 10:00 – 10:30 am (6, 9) # meeting from 12:00 – 1:30 pm
Write a function condense_meeting_times() that takes an array of meeting time ranges and returns an array of condensed ranges.
For example, given:
[(0, 1), (3, 5), (4, 8), (10, 12), (9, 10)] your function would return:
[(0, 1), (3, 8), (9, 12)]
Do not assume the meetings are in order. The meeting times are coming from multiple teams.
In this case the possibilities for start_time and end_time are bounded by the number of 30-minute slots in a day. But soon you plan to refactor it to store times as Unix timestamps (which are big numbers). Write something that's efficient even when we can't put a nice upper bound on the numbers representing our time ranges.
1. | import unittest |
Zen
11 year(s) ago uolter comments
1. | import this |
- Beautiful is better than ugly.
- Explicit is better than implicit.
- Simple is better than complex.
- Complex is better than complicated.
- Flat is better than nested.
- Sparse is better than dense.
- Readability counts.
- Special cases aren't special enough to break the rules.
- Although practicality beats purity.
- Errors should never pass silently.
- Unless explicitly silenced.
- In the face of ambiguity, refuse the temptation to guess.
- There should be one-- and preferably only one --obvious way to do it.
- Although that way may not be obvious at first unless you're Dutch.
- Now is better than never.
- Although never is often better than *right* now.
- If the implementation is hard to explain, it's a bad idea.
- If the implementation is easy to explain, it may be a good idea.
- Namespaces are one honking great idea -- let's do more of those!
palindrome check
11 year(s) ago uolter comments
1. | is_palindrome = lambda x: ''.join([x[i] for i in range(len(x)-1,-1, -1)]) == x |
Italy the Extraordinary Commonplace
11 year(s) ago uolter comments
