• Use Math Constants to Tiling Dominos and Handling Exceptions while Coding in ChatGPT

Hello, checkiomates🐱‍👤!

This week we have a bunch of news for you!

From today we allow users to assign hotkeys to "Run Code", "Check Solution" and stop code. You may see current combinations on buttons and change them in editor menu.

Also, we are pleased to announce that all missions on the "Strings and Integers" station (easy difficulty) have now been translated into simplified Chinese! 另外,我们很高兴地宣布,"Strings and Integers" 站的所有任务(简单难度)现在已经被翻译成了简体中文

Did you know, that you may click on any mission tag and see all missions, where this tag is present! If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!

🏁 MISSIONS:

Today's missions are about representing a number as a string expression of "pi" and "e" constants and fitting a mutilated room with 2x1 blank tiles! Sounds interesting, isn't it?! 🧠🧩

e+pi by dig - In this challenge, you will be given a result, and your task is to find an arithmetic expression that uses only the numbers pi and e to yield that result. You can use addition, subtraction, multiplication, division, and exponentiation operations, and each number (pi and e) can appear at most two times. Parentheses are not allowed. If there are multiple solutions, return the one that requires fewer operations. If there are still multiple solutions, return the one that comes first alphabetically (without spaces). The calculated result must be equal with an error smaller than 1 x 10-10. If there is no solution for the input, return None. Non negative/positive symbol at the beginning is allowed.

checkio(5.85987448205) == "e+pi"
checkio(18.2958548951) == "e**e+pi"
checkio(47.6085189284) == "e**e*pi"

Count Domino Tilings by freeman_lex - In domino tiling problem, a room of contiguous unit squares is to be tessellated with blank 2-by-1 domino tiles, each such tile placed either vertically or horizontally. In our version of domino tiling, the shape of the room consists of vertically stacked rows that all share the common straight line left wall. The list of rows contains the length of the individual rows, as measured in squares. Of course, the task of domino tiling can be solved only for even room sizes. But this necessary condition by itself does not yet guarantee the existence of some tiling on the mutilated rooms, like in this mission.

domino_tile([2, 2]) == 2
domino_tile([4, 3, 2, 1]) == 0
domino_tile([5, 3, 4, 2]) == 7

💡ARTICLES:

The articles we have prepared for you are about an art of raising exceptions, proposition of a new keyword and fuctionality in Python and generating code with ChatGPT.

Python's raise: Effectively Raising Exceptions in Your Code - In your Python journey, you’ll come across situations where you need to signal that something is going wrong in your code. For example, maybe a file doesn’t exist, a network or database connection fails, or your code gets invalid input. A common approach to tackle these issues is to raise an exception, notifying the user that an error has occurred. That’s what Python’s raise statement is for. Learning about the raise statement allows you to effectively handle errors and exceptional situations in your code. This way, you’ll develop more robust programs and higher-quality code.

Proposing a struct syntax for Python - The author proposes an analogy to other languages is C structs, Rust structs, and Go structs with syntax that will keep people from using collections.namedtuple() just for its attribute API and ignoring/regretting its index API. In other words, syntax to replace the simple, data-only uses of dataclasses.

Generating Code without Generating Technical Debt? - GPT and other large language models can produce huge volumes of code quickly. This allows for faster prototyping and iterative development, trying out multiple solutions. But it can also leave us with a bigger amount of mess code to maintain. This article explores several ways how to improve the code generated by these powerful tools and how to fit it into your project.

Good luck in your Python Journey!

🙌 Thanks for your attention! Hope to meet you at CheckiO. We are really interested in your thoughts! Please, leave a comment below! ⤵

Welcome to CheckiO - games for coders where you can improve your codings skills.

The main idea behind these games is to give you the opportunity to learn by exchanging experience with the rest of the community. Every day we are trying to find interesting solutions for you to help you become a better coder.

Join the Game