Python Challenge, Level 9

Python Challenge

Continuing on our journey through the challenges at PythonChallenge.com, here are the next few levels that we completed during the last meet.

SPOILERS! As stated in our last post, We will discuss the challenges, the clues, and how we solved each level. We discovered other sites have done the same thing but chose to solve these on our own. It’s more fun that way. Afterward, it’s interesting to go back and see how others have solved the same problem, but we recommend you solve the problems on your own.

On the page for this challenge is a photo which shows a view of a lake and a tree. The outline of the tree is marked with some square dots. As it wasn’t immediately apparent what the dots were for, we looked for further hints by inspecting the page code. Inside we found the following hint:

<!--
first+second=?

first:
146,399,163,403,170,393,169,391,166,386,170,...

second:
156,141,165,135,169,131,176,130,187,134,191,...
-->
READ MORE...

Python Challenge, Level 8

Python Challenge

Continuing on our journey through the challenges at PythonChallenge.com, here are the next few levels that we completed during the last meet.

SPOILERS! As stated in our last post, We will discuss the challenges, the clues, and how we solved each level. We discovered other sites have done the same thing but chose to solve these on our own. It’s more fun that way. Afterward, it’s interesting to go back and see how others have solved the same problem, but we recommend you solve the problems on your own.

This challenge starts at http://www.pythonchallenge.com/pc/def/integrity.html. There’s a picture of a bee on a flower with a sub-title asking, “Where is the missing link?” When you hover around the picture you can see the cursor changes to a pointer and there’s a link to http://www.pythonchallenge.com/pc/return/good.html. If you actually select it, you’ll get a pop-up that requests a user name and password.

If you search through the source, there’s the following in an HTML comment:

<!--
un: 'BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084'
pw: 'BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08'
-->
READ MORE...

Python Challenge, Part IV

Python Challenge

Continuing on our journey through the challenges at PythonChallenge.com, here are the next few levels that we completed during the last meet.

SPOILERS! As stated in our last post, We will discuss the challenges, the clues, and how we solved each level. We discovered other sites have done the same thing but chose to solve these on our own. It’s more fun that way. Afterward, it’s interesting to go back and see how others have solved the same problem, but we recommend you solve the problems on your own.

Level 7

Level seven begins with a pretty obvious feature, a photo with a stripe running across the middle comprised of a series of grayscale boxes. One can process the photo directly from the URL (similar to how we handled the last challenge), or one could download the file and process it locally. The following code follows the latter approach.

READ MORE...

Python Challenge, Part III

Python Challenge

Continuing on our journey through the challenges at PythonChallenge.com, here are the next few levels that we completed during the last meet.

SPOILERS! As stated in our last post, We will discuss the challenges, the clues, and how we solved each level. We discovered other sites have done the same thing but chose to solve these on our own. It’s more fun that way. Afterwards, it’s interesting to go back and see how others have solved the same problem, but we recommend you solve the problems on your own.

Level 6

So we left the green hill to an interesting shot of some unzipped jeans. For some of these, I think we had a tendency to way over think the problem. In this case, we hit on the idea that it may have something to do with zip files pretty quick, but it took a minute before someone suggested we just try renaming the URL from channel.html to channel.zip.

READ MORE...

Python Challenge, Part II

Python Challenge

Continuing on our journey through the challenges at PythonChallenge.com, here are the next few levels that we completed during the last meet.

SPOILERS! As stated in our last post, We will discuss the challenges, the clues, and how we solved each level. We discovered other sites have done the same thing, but chose to solve these on our own. It’s more fun that way. Afterwards, it’s interesting to go back and see how others have solved the same problem, but we recommend you solve the problems on your own.

Level 4

If you’re following along from the last post, and you entered linkedlist.html, you were probably taken to a page simply saying “linkedlist.php.” You’ll see a picture of a wooden toy and the hint is in the source. The hint recommends, “urllib may help. DON’T TRY ALL NOTHINGS, since it will never end. 400 times is more than enough.”

READ MORE...

Python Challenge, Part I

Python Challenge

Exercism.io was down during our last meeting as they were upgrading to a new and improved version of their site. As such, we decided to try some of the challenges that can be found at PythonChallenge.com. It’s a clever site that creates a series of riddle-like puzzles that challenge users to figure out what question needs to be answered before you think of how to start writing code to solve it. There are currently 33 levels so we’ve started working through the challenges and thought we’d share our progress.

SPOILERS! We will discuss the challenges, the clues, and how we solved each level. We discovered other sites have done the same thing, but chose to solve these on our own. It’s more fun that way. Afterwards, it’s interesting to go back and see how others have solved the same problem, but we recommend you solve the problems on your own.

Level 0

The first challenge starts at http://www.pythonchallenge.com/pc/def/0.html. The URLs seem to be a big part of these challenges and often require manipulation. The hint for this level is to “try to change the URL.” The photo shows a in the middle of the screen. It’s entitled “warm up” so we took this one right to the console and entered:

2**23
>>> 274877906944

After that, you change the URL from 0.html to 274877906944.html and you’re off to the next!

READ MORE...

Exercism.io, Part I

Code Challenge

In our most recent MeetUp we added some challenges to the mix. We decided to start working our way through the exercises at exercism.io. Everyone broke off into groups and here are a couple examples of what people came up with. We will continue to add a few new entries every month and work through all of the examples. Feel free to try them yourselves or come out to the next meet up and try them with the group.

Challenge 01

Challenge one, write a function that reverses a string. If you input “python,” you’ll get “nohtyp.”

Group 1


def reverse(input=''):
    return input[::-1]

READ MORE...

New Mailing List

Mailing List

Sorry all. We’ve fallen a little behind in posting content from our meetups. There will be some coming soon. In the mean time, we have a new mailing list! The Luxembourg and Greater Region community mailing list focuses on Luxembourg, Trier, and the surrounding area. If you would like to keep up on what’s new in our group or you would like to join the conversation, go ahead and sign up. With time we hope to see many more individuals as well as other local groups join. Happy coding!

Pandas Primer, Part II

Here we continue our look into Pandas. I created a profit calculator that merged data frames gathered from online sources and merged them with a data frame that I set up offline for offline analysis. The datasets used in these slides can be found at the Python Trier GitHub. Check it out and give it a try yourself.

Pandas Primer, Part I

Here we begin with part one in our look into data analytics with Pandas. We start with some of the basics of importing data, doing some basic cleaning up manipulation of data sets, and then move to visualization.

Up and Running with Virtual Environments, Part II

Virtual environments

One of the problems I encountered working with Brew, was how to select which versions of Python are used when I installed a virtual environment. You can check which versions you currently have on your system by executing brew info <desired forumla>. As you can see in my example, I have 3.5.1, 3.5.2, 3.6.0, and 3.6.1 on my system. You will also notice that version 3.6.1 is starred as the currently selected version.

➜  ~ brew info python3
python3: stable 3.6.1 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python3/3.5.1 (3,628 files, 53.6MB)
 Poured from bottle on 2016-05-29 at 22:21:58
/usr/local/Cellar/python3/3.5.2_1 (3,571 files, 54.7MB)
 Poured from bottle on 2016-08-08 at 21:48:40
/usr/local/Cellar/python3/3.5.2_3 (3,686 files, 55.4MB)
 Poured from bottle on 2016-11-12 at 21:33:29
/usr/local/Cellar/python3/3.6.0 (3,704 files, 57.5MB)
 Poured from bottle on 2017-02-25 at 20:16:45
/usr/local/Cellar/python3/3.6.1 (3,778 files, 57.5MB) *
 Poured from bottle on 2017-04-08 at 00:22:46
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python3.rb

Using mkvirtualenv <env name> will install the starred version. But what if I’m working on a project that uses an older version of Python? If you have the version that you want in your cellar, then you can use brew switch <formula> <version>.

➜  ~ brew switch python3 3.5.1
Cleaning /usr/local/Cellar/python3/3.5.1
Cleaning /usr/local/Cellar/python3/3.5.2_1
Cleaning /usr/local/Cellar/python3/3.5.2_3
Cleaning /usr/local/Cellar/python3/3.6.0
Cleaning /usr/local/Cellar/python3/3.6.1
23 links created for /usr/local/Cellar/python3/3.5.1

Here you can see that I successfully switched to version 3.5.1. When I enter brew info python3 again, it now shows that my starred version is indeed 3.5.1.

READ MORE...

Discounted airfare for Euro Python 2017

Euro Python 2017

Euro Python 2017 is partnering with different organizations to provide discounted travel to Rimini this July. They’ve partnered with Lufthansa Group (Lufthansa, Swiss, Eurowings, Austrian, and Brussels Airlines) as their preferred airline partner, offering a 5-10% discount on airfare to Bologna and Florence. You can also get discounted tickets for the shuttle that runs from the airport to Rimini. For more details and the codes for the discounts, check out the travel section of the EuroPython website for further details.

Up and Running with Virtual Environments, Part I

Virtual environments

If you’ve ever tried to upgrade your Mac’s system installed Python, you know that it can be a pain, and it’s not at all recommended. Apple and other third-party installers rely on the installed version to operate correctly, so changing it can cause complications. There is a better way to safely install different versions of Python while maintaining the integrity of the system installed version; enter, virtual environments. Using virtual environments allows you to install multiple different versions while keeping a healthy separation between your system and your projects.

I use Homebrew as my package manager so pip and python commands have been symlinked to my brew library. Per their instructions simply paste

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

into your terminal and it will guide you through the rest.

Note: It’s been a little while, but you may need to install XCode command-line tools. If you need to do that you can enter xcode-select --install and that should do the trick.

From there, the first thing I do is brew install python python3.

After that, getting started with virtualenv is pretty simple. I would also recommend adding virtualenvwrapper, which helps keep all of your environments in one place. Install them both with pip:

pip install virtualenv virtualenvwrapper
READ MORE...

Pattern Matching

Last month we discussed some of the pattern matching capabilities found in Python. Below are some examples with explanation text. The Python version used for this presentation is 3.5.1.

Upcoming Events

There are a few conferences in Europe over the next year, but the next two are right here in Germany. This weekend is the PythonCamp in Cologne, though it’s probably a little late if you haven’t already made plans to go. There’s still an opportunity to checkout PyConWeb in Munich at the end of May. The focus of this conference will be web development within the Python ecosystem. Early bird prices are in effect through the 30th of April, after which, full prices go in effect. You can find more information on their ticket page. Other conferences are listed on the sidebar of our page. As always, if anyone is interested in going, feel free to contact the group through our MeetUp page or join our Slack channel and we’ll see if we can coordinate ride-shares with other interested members.

Regular Expressions

This article was was translated and adapted with permission by the original author. His original article can be found at Tutorial Reguläre Ausdrücke.

Tutorial Regular expressions

“Regular expressions” are a kind of language that can be used when programming for various problem-solving tasks, especially when it comes to examining strings or searching for something inside them.

And because the name “Regular Expressions” is a little bulky, they are often simply reduced to “RegEx(s)”.

Introduction

Here is a small tutorial on these esoterically appealing but incredibly powerful strings, which trigger a child-like wonder as one makes his first attempts at the keyboard.

What are regular expressions? As I have said, string expressions can be tested for a particular composition using regular expressions. This can be important for applications that expect user input.
READ MORE...

Python 3.6

Python 3.6

The code for 3.6.0 has been frozen, and baring anything critical popping up, the next Python release is scheduled for the 16th of December. After that, starting in January 2017, it will follow the normal update cycle with bug-fixes every three to six months for the next 18 months until the release of 3.7. Following the final bug-fix, it is expected that security updates will continue through December 2021.

The Python Software Foundation has provided some excellent descriptions of what’s to come. Further documentation and the following write-ups can be found at Python.org.

So what’s new in 3.6?

PEP 468 - Preserving the order of **kwargs in a function

**kwargs in a function signature is now guaranteed to be an insertion-order-preserving mapping.

The dict type now uses a “compact” representation pioneered by PyPy. The memory usage of the new dict() is between 20% and 25% smaller compared to Python 3.5.
READ MORE...

Python Video

Pyvideo Logo

If you’ve never been to a python event, or you wanted to go but something came up, there is a video repository just for you. Pyvideo.org is a free volunteer-driven resource which indexes video from events all over the world. You can get a glimpse of what they have already at their events page.

From 2016 alone, they’ve posted videos to PyData Berlin, PyCon DE, PyCon UK, PyCon US, DjangoCon Europe, and many more. Again, they’re volunteer driven so, if you’re interested in helping out, you can find more information on their wiki page.


Pi and More 2017

Pi and More Logo Pi and More just recently announced its Raspberry Jam will be held on the 14th of January 2017 at the Hochschule Niederrhein in Krefeld. The indicates this will be one of their smaller, but equally interesting, winter events.Never been to an event before? Checkout some of the past events to see pictures, schedules, and other information from previous Jams.

Krefeld is about a three hour drive from Trier, so if you’re interested in going and would like to carpool, please contact us at PythonTrier@gmail.com so we can coordinate transportation.

The schedule has yet to be published; however, they are soliciting for contributions.

“We are looking for persons or groups who are interested in presenting a project or a topic. We welcome presentations of own or other projects (e.g., hardware and software projects), or a presentation of general topics, like first steps with the Raspberry Pi, programming, system internals, hardware tutorials, etc. Contributions about the Raspberry Pi are as welcome as contributions about other embedded systems or microcontrollers. The event aims at beginners and experts alike. Therefore, simple and small projects fit as well as workshops for experts.”

You can find more details on their page so check it out. Hope to see you there!


Code Challenge

Challenge 09

Code Challenge

and the sum of its digits is . What is the sum of the digits of the number ?

Challenge 10

means . For example, , and the sum of the digits in the number is . Find the sum of the digits in the number

Want to give it a try?

We have a Jupyter notebook where code challenges are presented for the group to try. The link can be found at https://srv.derpy.ws:55523/tree/Challenges. There is a password so if you haven’t received it already, please feel free to contact me on MeetUp and I’ll send you the current password.

Past solutions will remain in each challenge notebook. Feel free to add your own solution at any time. Consider commenting your code to help others understand your approach. If you can’t understand why you wrote something after not looking at it for a while, it could probably benefit from a little extra commenting. A few new challenges will be posted every month.


Book Club

Book Club

During last month’s MeetUp, we discussed the idea of introducing a technical book club. The idea being that we each read through selected chapters, attempt the tutorials or code discussed, and discuss that during the meetings. Any recommended titles are appreciated; however, we have three good ones to start with. They are:



Dive into Python 3

by Mark Pilgrim

Available for free at http://www.diveintopython3.net/ (freePDF and HTML version available)

Natural Language Processing with Python

by Steven Bird, Ewan Klein, and Edward Loper

Available to read for free at http://www.nltk.org/book/
READ MORE...

Code Challenge

Challenge 07

Code Challenge

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?


Challenge 08

The four adjacent digits in the 1000-digit number that have the greatest product are .

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?

Want to give it a try?

We have a Jupyter notebook where code challenges are presented for the group to try. The link can be found at https://srv.derpy.ws:55523/tree/Challenges. There is a password so if you haven’t received it already, please feel free to contact me on MeetUp and I’ll send you the current password.

Past solutions will remain in each challenge notebook. Feel free to add your own solution at any time. Consider commenting your code to help others understand your approach. If you can’t understand why you wrote something after not looking at it for a while, it could probably benefit from a little extra commenting. A few new challenges will be posted every month.


Code Challenge

Challenge 05

Code Challenge

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is . Find the largest palindrome made from the product of two 3-digit numbers.


Challenge 06

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

Want to give it a try?

We have a Jupyter notebook where code challenges are presented for the group to try. The link can be found at https://srv.derpy.ws:55523/tree/Challenges. There is a password so if you haven’t received it already, please feel free to contact me on MeetUp and I’ll send you the current password.

Past solutions will remain in each challenge notebook. Feel free to add your own solution at any time. Consider commenting your code to help others understand your approach. If you can’t understand why you wrote something after not looking at it for a while, it could probably benefit from a little extra commenting. A few new challenges will be posted every month.


Code Challenge

Challenge 03

Code Challenge

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, … By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.


Challenge 04

The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143?

Want to give it a try?

We have a Jupyter notebook where code challenges are presented for the group to try. The link can be found at https://srv.derpy.ws:55523/tree/Challenges. There is a password so if you haven’t received it already, please feel free to contact me on MeetUp and I’ll send you the current password.

Past solutions will remain in each challenge notebook. Feel free to add your own solution at any time. Consider commenting your code to help others understand your approach. If you can’t understand why you wrote something after not looking at it for a while, it could probably benefit from a little extra commenting. A few new challenges will be posted every month.


Code Challenge

Challenge 01

Code Challenge

Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line.


Challenge 02

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.

Want to give it a try?

We have a Jupyter notebook where code challenges are presented for the group to try. The link can be found at https://srv.derpy.ws:55523/tree/Challenges. There is a password so if you haven’t received it already, please feel free to contact me on MeetUp and I’ll send you the current password.

Past solutions will remain in each challenge notebook. Feel free to add your own solution at any time. Consider commenting your code to help others understand your approach. If you can’t understand why you wrote something after not looking at it for a while, it could probably benefit from a little extra commenting. A few new challenges will be posted every month.