id
stringlengths
11
14
content
stringlengths
424
1.17M
apps_data_1700
The Dynamic Connectivity Problem Given a set of of N objects, is there a path connecting the two objects? Implement an class that implements the following API: * Takes n as input, initializing a data-structure with N objects (0...N-1) * Implements a Union command that adds a connection between point p and poin...
apps_data_1701
The Stack Arithmetic Machine --------------------------- This time we're going to be writing a stack arithmetic machine, and we're going to call it Sam. Essentially, Sam is a very small virtual machine, with a simple intruction set, four general registers, and a stack. We've already given a CPU class, which gives you ...
apps_data_1702
Given a Sudoku data structure with size `NxN, N > 0 and √N == integer`, write a method to validate if it has been filled out correctly. The data structure is a multi-dimensional Array, i.e: ``` [ [7,8,4, 1,5,9, 3,2,6], [5,3,9, 6,7,2, 8,4,1], [6,1,2, 4,3,8, 7,5,9], [9,2,8, 7,1,5, 4,6,3], [3,5,7, ...
apps_data_1703
Introduction Brainfuck is one of the most well-known esoteric programming languages. But it can be hard to understand any code longer that 5 characters. In this kata you have to solve that problem. Description In this kata you have to write a function which will do 3 tasks: Optimize the given Brainfuck code. Check i...
apps_data_1704
A famous casino is suddenly faced with a sharp decline of their revenues. They decide to offer Texas hold'em also online. Can you help them by writing an algorithm that can rank poker hands? ## Task Create a poker hand that has a method to compare itself to another poker hand: ```python compare_with(self, other_han...
apps_data_1705
Spider-Man ("Spidey") needs to get across town for a date with Mary Jane and his web-shooter is low on web fluid. He travels by slinging his web rope to latch onto a building rooftop, allowing him to swing to the opposite end of the latch point. Write a function that, when given a list of buildings, returns a list of o...
apps_data_1706
# Task A rectangle with sides equal to even integers a and b is drawn on the Cartesian plane. Its center (the intersection point of its diagonals) coincides with the point (0, 0), but the sides of the rectangle are not parallel to the axes; instead, they are forming `45 degree` angles with the axes. How many points ...
apps_data_1707
----- __CLEAR CUTTER'S NEEDS YOUR HELP!__ ----- The logging company Clear Cutter's makes its money by optimizing the price-to-length of each log they cut before selling them. An example of one of their price tables is included: ```python # So a price table p p = [ 0, 1, 5, 8, 9, 10] # Can be imagined as: # lengt...
apps_data_1708
One of the services provided by an operating system is memory management. The OS typically provides an API for allocating and releasing memory in a process's address space. A process should only read and write memory at addresses which have been allocated by the operating system. In this kata you will implement a simul...
apps_data_1709
Given an array of positive or negative integers I= [i1,..,in] you have to produce a sorted array P of the form [ [p, sum of all ij of I for which p is a prime factor (p positive) of ij] ...] P will be sorted by increasing order of the prime numbers. The final result has to be given as a string in Java, C#, C, C+...
apps_data_1710
![alt text](https://2.bp.blogspot.com/-DNNiOXduuvQ/Vh-FR-qbKXI/AAAAAAAAEOA/HT0IzJ36zW4/s1600/voz.jpg) Create a class called `Warrior` which calculates and keeps track of their level and skills, and ranks them as the warrior they've proven to be. Business Rules: - A warrior starts at level 1 and can progress all the ...
apps_data_1711
### Context and Definitions You are in charge of developing a new cool JavaScript library that provides functionality similar to that of [Underscore.js](http://underscorejs.org/). You have started by adding a new **list data type** to your library. You came up with a design of a data structure that represents an [al...
apps_data_1712
# Overview The goal here is to solve a puzzle (the "pieces of paper" kind of puzzle). You will receive different pieces of that puzzle as input, and you will have to find in what order you have to rearrange them so that the "picture" of the puzzle is complete. ## Puzzle pieces All the pieces of the puzzle will be ...
apps_data_1713
The aim of this kata is to determine the number of sub-function calls made by an unknown function. You have to write a function named `count_calls` which: * takes as parameter a function and its arguments (args, kwargs) * calls the function * returns a tuple containing: * the number of function calls made inside it...
apps_data_1714
### The Problem Consider a flat board with pegs sticking out of one side. If you stretched a rubber band across the outermost pegs what is the set of pegs such that all other pegs are contained within the shape formed by the rubber band? ![alt text](https://upload.wikimedia.org/wikipedia/commons/b/bc/ConvexHull.png) ...
apps_data_1715
Your task in this Kata is to emulate text justification in monospace font. You will be given a single-lined text and the expected justification width. The longest word will never be greater than this width. Here are the rules: * Use spaces to fill in the gaps between words. * Each line should contain as many word...
apps_data_1716
This is the simple version of [Fastest Code : Equal to 24](http://www.codewars.com/kata/574e890e296e412a0400149c). ## Task A game I played when I was young: Draw 4 cards from playing cards, use ```+ - * / and ()``` to make the final results equal to 24. You will coding in function ```equalTo24```. Function accept 4...
apps_data_1717
Write a function that, given a string of text (possibly with punctuation and line-breaks), returns an array of the top-3 most occurring words, in descending order of the number of occurrences. Assumptions: ------------ - A word is a string of letters (A to Z) optionally containing one or more apostrophes (') in ASCII...
apps_data_1718
Kate constantly finds herself in some kind of a maze. Help her to find a way out!. For a given maze and Kate's position find if there is a way out. Your function should return True or False. Each maze is defined as a list of strings, where each char stays for a single maze "cell". ' ' (space) can be stepped on, '#' m...
apps_data_1719
### The problem How many zeroes are at the **end** of the [factorial](https://en.wikipedia.org/wiki/Factorial) of `10`? 10! = 3628800, i.e. there are `2` zeroes. 16! (or 0x10!) in [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) would be 0x130777758000, which has `3` zeroes. ### Scalability Unfortunately, ma...
apps_data_1720
## Task Create a RomanNumerals class that can convert a roman numeral to and from an integer value. It should follow the API demonstrated in the examples below. Multiple roman numeral values will be tested for each helper method. Modern Roman numerals are written by expressing each digit separately starting with th...
apps_data_1721
Your task in this kata is to implement the function `create_number_class` which will take a string parameter `alphabet` and return a class representing a number composed of this alphabet. The class number will implement the four classical arithmetic operations (`+`, `-`, `*`, `//`), a method to convert itself to strin...
apps_data_1722
# The learning game - Machine Learning #1 Growing up you would have learnt a lot of things like not to stand in fire, to drink food and eat water and not to jump off very tall things But Machines have it difficult they cannot learn for themselves we have to tell them what to do, why don't we give them a chance to learn...
apps_data_1723
## Bezier curves When a shape is described using vector graphics, its outline is often described as a sequence of linear, quadratic, and cubic Bezier curves. You can read about [Bézier curves](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) on Wikipedia. You don't need to know much about Bezier curves to solve this...
apps_data_1724
This kata is inspired by Space Invaders (Japanese: スペースインベーダー), an arcade video game created by Tomohiro Nishikado and released in 1978. Alien invaders are attacking Earth and you've been conscripted to defend. The Bad News: You performed poorly in the manual training. As a result, you're ranked low priority and you're...
apps_data_1725
# Problem Description Let's imagine a function `F(n)`, which is defined over the integers in the range of `1 <= n <= max_n`, and `0 <= F(n) <= max_fn` for every `n`. There are `(1 + max_fn) ** max_n` possible definitions of `F` in total. Out of those definitions, how many `F`s satisfy the following equations? Since ...
apps_data_1726
## Task You are at position [0, 0] in maze NxN and you can **only** move in one of the four cardinal directions (i.e. North, East, South, West). Return `true` if you can reach position [N-1, N-1] or `false` otherwise. Empty positions are marked `.`. Walls are marked `W`. Start and exit positions are empty in all tes...
apps_data_1727
Write a function that determines whether a string is a valid guess in a Boggle board, as per the rules of Boggle. A Boggle board is a 2D array of individual characters, e.g.: ```python [ ["I","L","A","W"], ["B","N","G","E"], ["I","U","A","O"], ["A","S","R","L"] ] ``` Valid guesses are strings which can be formed ...
apps_data_1728
Task Create a top-down movement system that would feel highly responsive to the player. In your Update method you have to check for the keys that are currently being pressed, the keys correspond to the enum Direction shown below, based on which key is pressed or released your method should behave this way: 1) When a ...
apps_data_1729
Hey, Path Finder, where are you? ## Path Finder Series: - [#1: can you reach the exit?](https://www.codewars.com/kata/5765870e190b1472ec0022a2) - [#2: shortest path](https://www.codewars.com/kata/57658bfa28ed87ecfa00058a) - [#3: the Alpinist](https://www.codewars.com/kata/576986639772456f6f00030c) - ...
apps_data_1730
### Please also check out other katas in [Domino Tiling series](https://www.codewars.com/collections/5d19554d13dba80026a74ff5)! --- # Task A domino is a rectangular block with `2` units wide and `1` unit high. A domino can be placed on a grid in two ways: horizontal or vertical. ``` ## or # # ``` You have in...
apps_data_1731
Esoteric languages are pretty hard to program, but it's fairly interesting to write interpreters for them! Your task is to write a method which will interpret Befunge-93 code! Befunge-93 is a language in which the code is presented not as a series of instructions, but as instructions scattered on a 2D plane; your poin...
apps_data_1732
To almost all of us solving sets of linear equations is quite obviously the most exciting bit of linear algebra. Benny does not agree though and wants to write a quick program to solve his homework problems for him. Unfortunately Benny's lack of interest in linear algebra means he has no real clue on how to go about th...
apps_data_1733
Given two different positions on a chess board, find the least number of moves it would take a knight to get from one to the other. The positions will be passed as two arguments in algebraic notation. For example, `knight("a3", "b5")` should return 1. The knight is not allowed to move off the board. The board is 8x8. ...
apps_data_1734
Write a class called User that is used to calculate the amount that a user will progress through a ranking system similar to the one Codewars uses. ##### Business Rules: * A user starts at rank -8 and can progress all the way to 8. * There is no 0 (zero) rank. The next rank after -1 is 1. * Users will complete acti...
apps_data_1735
Ever heard about Dijkstra's shallowest path algorithm? Me neither. But I can imagine what it would be. You're hiking in the wilderness of Northern Canada and you must cross a large river. You have a map of one of the safer places to cross the river showing the depths of the water on a rectangular grid. When crossing t...
apps_data_1736
> "7777...*8?!??!*", exclaimed Bob, "I missed it again! Argh!" Every time there's an interesting number coming up, he notices and then promptly forgets. Who *doesn't* like catching those one-off interesting mileage numbers? Let's make it so Bob **never** misses another interesting number. We've hacked into his car...
apps_data_1737
Your task is to implement a function that calculates an election winner from a list of voter selections using an [Instant Runoff Voting](http://en.wikipedia.org/wiki/Instant-runoff_voting) algorithm. If you haven't heard of IRV, here's a basic overview (slightly altered for this kata): - Each voter selects several can...
apps_data_1738
For a new 3D game that will be released, a team of programmers needs an easy function. (Then it will be processed as a method in a Class, forget this concept for Ruby) We have an sphere with center O, having in the space the coordinates `[α, β, γ]` and radius `r` and a list of points, `points_list`, each one with coo...
apps_data_1739
Part of Series 2/3 This kata is part of a series on the Morse code. Make sure you solve the [previous part](/kata/decode-the-morse-code) before you try this one. After you solve this kata, you may move to the [next one](/kata/decode-the-morse-code-for-real). In this kata you have to write a Morse code decoder for w...
apps_data_1740
We need a system that can learn facts about family relationships, check their consistency and answer queries about them. # The task ~~~if:javascript Create a class `Family` with the following methods. All arguments are strings: names of persons. Upon the first use of a name, that name is added to the family. * `male...
apps_data_1741
### Please also check out other katas in [Domino Tiling series](https://www.codewars.com/collections/5d19554d13dba80026a74ff5)! --- # Task A domino is a rectangular block with `2` units wide and `1` unit high. A domino can be placed on a grid in two ways: horizontal or vertical. ``` ## or # # ``` You have in...
apps_data_1742
Jon and Joe have received equal marks in the school examination. But, they won't reconcile in peace when equated with each other. To prove his might, Jon challenges Joe to write a program to find all possible number combos that sum to a given number. While unsure whether he would be able to accomplish this feat or not,...
apps_data_1743
# Background The famous Collatz Sequence is generated with the following rules: * Start with a positive integer `a[0] = n`. * If `a[i]` is even, `a[i+1] = a[i] / 2`. * Otherwise, `a[i+1] = a[i] * 3 + 1`. However, for the purpose of this Kata, I give a **slightly modified definition**: * If `a[i]` is even, `a[i+1] =...
apps_data_1744
This Kata is a continuation of [Part 1](http://www.codewars.com/kata/the-fusc-function-part-1). The `fusc` function is defined recursively as follows: fusc(0) = 0 fusc(1) = 1 fusc(2n) = fusc(n) fusc(2n + 1) = fusc(n) + fusc(n + 1) Your job is to produce the code for the `fusc` function. In this ka...
apps_data_1745
This calculator takes values that could be written in a browsers route path as a single string. It then returns the result as a number (or an error message). Route paths use the '/' symbol so this can't be in our calculator. Instead we are using the '$' symbol as our divide operator. You will be passed a string of an...
apps_data_1746
# Let's play some games! A new RPG called **_Demon Wars_** just came out! Imagine the surprise when you buy it after work, go home, start you _GameStation X_ and it happens to be too difficult for you. Fortunately, you consider yourself a computer connoisseur, so you want to build an AI that tells you every step you h...
apps_data_1747
Print an ordered cross table of a round robin tournament that looks like this: ``` # Player 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Pts SB ========================================================================== 1 Nash King 1 0 = 1 0 = 1 1 0 1 1 1 0 8.0 52.25 2 Karsyn Ma...
apps_data_1748
This kata is inspired by Tower Defense (TD), a subgenre of strategy video games where the goal is to defend a player's territories or possessions by obstructing enemy attackers, usually by placing defensive structures on or along their path of attack. Objective It's the future, and hostile aliens are attacking our pla...
apps_data_1749
A factorial (of a large number) will usually contain some trailing zeros. Your job is to make a function that calculates the number of trailing zeros, in any given base. Factorial is defined like this: ```n! = 1 * 2 * 3 * 4 * ... * n-2 * n-1 * n``` Here's two examples to get you started: ```python trailing_zeros(15,...
apps_data_1750
The `mystery` function is defined over the non-negative integers. The more common name of this function is concealed in order to not tempt you to search the Web for help in solving this kata, which most definitely would be a very dishonorable thing to do. Assume `n` has `m` bits. Then `mystery(n)` is the number whose ...
apps_data_1751
“"Forward!", he cried from the rear And the front rank died The general sat and the lines on the map Moved from side to side”Us and Them -- Pink Floyd A few army battalions from warring nations have met on an even battlefield. Each nation has one battalion present and all battalions have an equal number of soldiers. Ev...
apps_data_1752
Alright, detective, one of our colleagues successfully observed our target person, Robby the robber. We followed him to a secret warehouse, where we assume to find all the stolen stuff. The door to this warehouse is secured by an electronic combination lock. Unfortunately our spy isn't sure about the PIN he saw, when R...
apps_data_1753
You are in the capital of Far, Far Away Land, and you have heard about this museum where the royal family's crown jewels are on display. Before you visit the museum, a friend tells you to bring some extra money that you'll need to bribe the guards. You see, he says, the crown jewels are in one of 10 rooms numbered from...
apps_data_1754
A group of N golfers wants to play in groups of G players for D days in such a way that no golfer plays more than once with any other golfer. For example, for N=20, G=4, D=5, the solution at Wolfram MathWorld is ``` Mon: ABCD EFGH IJKL MNOP QRST Tue: AEIM BJOQ CHNT DGLS FKPR Wed: AGKO ...
apps_data_1755
This is the second part of a two-part challenge. See [part I](https://www.codewars.com/kata/587387d169b6fddc16000002) if you haven't done so already. The problem is the same, only with longer lists and larger values. Imagine you have a number of jobs to execute. Your workers are not permanently connected to your netwo...
apps_data_1756
We all know how to handle exceptions in Python. Just use: try: num = float(input()) except ValueError: print("That's not a number!") else: print(num) Code such as this def factorial(x, n = 1): if x == 0: raise ValueError(n) factorial(x - 1, n * x) re...
apps_data_1757
## A Knight's Tour A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. https://en.wikipedia.org/wiki/Knight%27s_tour Traditional chess boards are 8x8 grids, but for this kata we are interested in generating tours for any square board sizes. You will...
apps_data_1758
In this kata you have to create all permutations of an input string and remove duplicates, if present. This means, you have to shuffle all letters from the input in all possible orders. Examples: ```python permutations('a'); # ['a'] permutations('ab'); # ['ab', 'ba'] permutations('aabb'); # ['aabb', 'abab', 'abba', '...
apps_data_1759
_yet another easy kata!_ _Bored of usual python katas? me too;_ ## Overview      As you have guessed from the title of the kata you are going to implement a class that supports ***function overloading***. You might be thinking python doesn't support that thing... Of course python doesn't support that! So you have ...
apps_data_1760
# Task You are given a `chessBoard`, a 2d integer array that contains only `0` or `1`. `0` represents a chess piece and `1` represents a empty grid. It's always square shape. Your task is to count the number of squares made of empty grids. The smallest size of the square is `2 x 2`. The biggest size of the square is...
apps_data_1761
_Yet another easy kata!_ # Task: - Let's write a sequence starting with `seq = [0, 1, 2, 2]` in which - 0 and 1 occurs 1 time - 2 occurs 2 time and sequence advances with adding next natural number `seq[natural number]` times so now, 3 appears 2 times and so on. ### Input - You ...
apps_data_1762
Above: An overhead view of the house in one of the tests. The green outline indicates the path taken by K A mouse named K has found a new home on Ash Tree Lane. K wants to know the size of the interior of the house (which consists of just one room). K is able to measure precise distances in any direction he runs. But K...
apps_data_1763
# Disclaimer This Kata is an insane step-up from [GiacomoSorbi's Kata](https://www.codewars.com/kata/total-increasing-or-decreasing-numbers-up-to-a-power-of-10/python), so I recommend to solve it first before trying this one. # Problem Description A positive integer `n` is called an *increasing number* if its digits...
apps_data_1764
In this kata you must determine the lowest floor in a building from which you cannot drop an egg without it breaking. You may assume that all eggs are the same; if one egg breaks when dropped from floor `n`, all eggs will. If an egg survives a drop from some floor, it will survive a drop from any floor below too. You...
apps_data_1765
An integer partition of n is a weakly decreasing list of positive integers which sum to n. For example, there are 7 integer partitions of 5: [5], [4,1], [3,2], [3,1,1], [2,2,1], [2,1,1,1], [1,1,1,1,1]. Write a function named partitions which returns the number of integer partitions of n. The function should be able...
apps_data_1766
#SKRZAT Geek Challenge [SKRZAT] is an old, old game from Poland that uses a game console with two buttons plus a joy stick. As is true to its name, the game communicates in binary, so that one button represents a zero and the other a one. Even more true to its name, the game chooses to communicate so that the base o...
apps_data_1767
### **[Mahjong Series](/collections/mahjong)** **Mahjong** is based on draw-and-discard card games that were popular in 18th and 19th century China and some are still popular today. In each deck, there are three different suits numbered `1` to `9`, which are called **Simple tiles**. To simplify the problem, we talk a...
apps_data_1768
pre.handle{ height: 2em; width: 4em; margin: auto; margin-bottom: 0 !important; background: none !important; border-radius: 0.5em 0.5em 0 0; border-top: 5px solid saddlebrown; border-left: 5px solid saddlebrown; border-right: 5px solid saddlebrown; } ta...
apps_data_1769
The professional Russian, Dmitri, from the popular youtube channel FPSRussia has hired you to help him move his arms cache between locations without detection by the authorities. Your job is to write a Shortest Path First (SPF) algorithm that will provide a route with the shortest possible travel time between waypoint...
apps_data_1770
## Task You are at position `[0, 0]` in maze NxN and you can **only** move in one of the four cardinal directions (i.e. North, East, South, West). Return the minimal number of steps to exit position `[N-1, N-1]` *if* it is possible to reach the exit from the starting position. Otherwise, return `false` in **JavaScrip...
apps_data_1771
Given a set of integers _S_, the _closure of S under multiplication_ is the smallest set that contains _S_ and such that for any _x, y_ in the closure of _S_, the product _x * y_ is also in the closure of _S_. Example 1: Given `S = {2}`, the closure of `S` is the set `{2, 4, 8, 16, 32, 64, ... }`. Example 2: Given `...
apps_data_1772
The Vigenère cipher is a classic cipher originally developed by Italian cryptographer Giovan Battista Bellaso and published in 1553. It is named after a later French cryptographer Blaise de Vigenère, who had developed a stronger autokey cipher (a cipher that incorporates the message of the text into the key). The cip...
apps_data_1773
### Sudoku Background Sudoku is a game played on a 9x9 grid. The goal of the game is to fill all cells of the grid with digits from 1 to 9, so that each column, each row, and each of the nine 3x3 sub-grids (also known as blocks) contain all of the digits from 1 to 9. (More info at: http://en.wikipedia.org/wiki/Sudoku...
apps_data_1774
# Task Your task is to create a `Funnel` data structure. It consists of three basic methods: `fill()`, `drip()` and `toString()/to_s/__str__`. Its maximum capacity is 15 data. Data should be arranged in an inverted triangle, like this: ``` \1 2 3 4 5/ \7 8 9 0/ \4 5 6/ \2 3/ \1/ ``` The string me...
apps_data_1775
table { width: 236px; } table, tr, td { border: 0px; } In a grid of 4 by 4 squares you want to place a skyscraper in each square with only some clues: The height of the skyscrapers is between 1 and 4 No two skyscrapers in a row or column may have the same number of floors A clue is the nu...
apps_data_1776
Stacey is a big [AD&D](https://en.wikipedia.org/wiki/Dungeons_%26_Dragons) games nerd. Moreover, she's a munchkin. Not a [cat breed](https://en.wikipedia.org/wiki/Munchkin_cat), but a person who likes to get maximum efficiency of their character. As you might know, many aspects of such games are modelled by rolling di...
apps_data_1777
# Task IONU Satellite Imaging, Inc. records and stores very large images using run length encoding. You are to write a program that reads a compressed image, finds the edges in the image, as described below, and outputs another compressed image of the detected edges. A simple edge detection algorithm sets an output...
apps_data_1778
[The Vigenère cipher](https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher) is a classic cipher that was thought to be "unbreakable" for three centuries. We now know that this is not so and it can actually be broken pretty easily. **How the Vigenère cipher works**: The basic concept is that you have a `message` and a `...
apps_data_1779
Write a function which makes a list of strings representing all of the ways you can balance `n` pairs of parentheses ### Examples ```python balanced_parens(0) => [""] balanced_parens(1) => ["()"] balanced_parens(2) => ["()()","(())"] balanced_parens(3) => ["()()()","(())()","()(())","(()())","((()))"] ``` def balanc...
apps_data_1780
From wikipedia In number theory and combinatorics, a partition of a positive integer n, also called an integer partition, is a way of writing n as a sum of positive integers. Two sums that differ only in the order of their summands are considered the **same** partition. For example, 4 can be partitioned in five d...
apps_data_1781
## Description Beggar Thy Neighbour is a card game taught to me by my parents when I was a small child, and is a game I like to play with my young kids today. In this kata you will be given two player hands to be played. And must return the index of the player who will win. ## Rules of the game - Special cards are...
apps_data_1782
The Challenge ------------- You'll need to implement a simple lexer type. It should take in an input string through the constructor (or the parameter, for Javascript), and break it up into typed-tokens (in python, C# and Java, you'll have to manage `null/None` input too, resulting in the same behavior than an empty str...
apps_data_1783
A famous casino is suddenly faced with a sharp decline of their revenues. They decide to offer Texas hold'em also online. Can you help them by writing an algorithm that can rank poker hands? Task: Create a poker hand that has a constructor that accepts a string containing 5 cards: ```python hand = PokerHand("KS 2H ...
apps_data_1784
[Currying and partial application](http://www.2ality.com/2011/09/currying-vs-part-eval.html) are two ways of transforming a function into another function with a generally smaller arity. While they are often confused with each other, they work differently. The goal is to learn to differentiate them. ## Currying > Is ...
apps_data_1785
A pixmap shall be turned from black to white, turning all pixels to white in the process. But for optical reasons this shall *not* happen linearly, starting at the top and continuing line by line to the bottom: ```python for y in range(height): for x in range(width): setBit(x, y) ``` Instead it shall be done ...
apps_data_1786
Let's say you have a bunch of points, and you want to round them all up and calculate the area of the smallest polygon containing all of the points (nevermind why, you just want a challenge). What you're looking for is the area of the *convex hull* of these points. Here is an example, delimited in blue : ## Your tas...
apps_data_1787
Your task is to build a model^(1) which can predict y-coordinate. You can pass tests if predicted y-coordinates are inside error margin. You will receive train set which should be used to build a model. After you build a model tests will call function ```predict``` and pass x to it. Error is going to be calculated ...
apps_data_1788
This kata explores writing an AI for a two player, turn based game called *NIM*. The Board -------------- The board starts out with several piles of straw. Each pile has a random number of straws. ``` Pile 0: |||| Pile 1: || Pile 2: ||||| Pile 3: | Pile 4: |||||| ...or more concisely: [4,2,5,1,6] ``` The Rule...
apps_data_1789
As [breadcrumb menùs](https://en.wikipedia.org/wiki/Breadcrumb_%28navigation%29) are quite popular today, I won't digress much on explaining them, leaving the wiki link to do all the dirty work in my place. What might not be so trivial is instead to get a decent breadcrumb from your current url. For this kata, your pu...
apps_data_1790
A "graph" consists of "nodes", also known as "vertices". Nodes may or may not be connected with one another. In our definition below the node "A0" is connected with the node "A3", but "A0" is not connected with "A1". The connecting line between two nodes is called an edge. If the edges between the nodes are undirecte...
apps_data_1791
_That's terrible! Some evil korrigans have abducted you during your sleep and threw you into a maze of thorns in the scrubland D: But have no worry, as long as you're asleep your mind is floating freely in the sky above your body._ > **Seeing the whole maze from above in your sleep, can you remember the list of movem...
apps_data_1792
### Please also check out other katas in [Domino Tiling series](https://www.codewars.com/collections/5d19554d13dba80026a74ff5)! --- # Task A domino is a rectangular block with `2` units wide and `1` unit high. A domino can be placed on a grid in two ways: horizontal or vertical. ``` ## or # # ``` You have in...
apps_data_1793
If you like cryptography and playing cards, have also a look at the kata [Card-Chameleon, a Cipher with Playing cards](http://www.codewars.com/kata/card-chameleon-a-cipher-with-playing-cards). As a secret agent, you need a method to transmit a message to another secret agent. But an encrypted text written on a noteb...
apps_data_1794
Alice, Samantha, and Patricia are relaxing on the porch, when Alice suddenly says: _"I'm thinking of two numbers, both greater than or equal to 2. I shall tell Samantha the sum of the two numbers and Patricia the product of the two numbers."_ She takes Samantha aside and whispers in her ear the sum so that Patricia c...
apps_data_1795
This is a classic needing (almost) no further introduction. Given a N x N chess board, place N queens on it so none can attack another: I.e. no other queens can be found horizontally, vertically or diagonally to the current. On the board below, no further queens can be positioned. +-+-+ |Q| | +-+-+ | | | +-+-+ In t...
apps_data_1796
Construct a function that, when given a string containing an expression in infix notation, will return an identical expression in postfix notation. The operators used will be `+`, `-`, `*`, `/`, and `^` with standard precedence rules and left-associativity of all operators but `^`. The operands will be single-digit i...
apps_data_1797
A *[Hamming number][1]* is a positive integer of the form 2*i*3*j*5*k*, for some non-negative integers *i*, *j*, and *k*. Write a function that computes the *n*th smallest Hamming number. Specifically: - The first smallest Hamming number is 1 = 2^(0)3^(0)5^(0) - The second smallest Hamming number is 2 = 2^(1)3^...
apps_data_1798
Given a 2D array and a number of generations, compute n timesteps of [Conway's Game of Life](http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life). The rules of the game are: 1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation. 2. Any live cell with more than three live neighbou...
apps_data_1799
Based on the well known ['Eight Queens' problem](https://en.wikipedia.org/wiki/Eight_queens_puzzle). #### Summary Your challenge is to place N queens on a chess board such that none of the queens are attacking each other. #### Details A standard 8x8 chess board has its rows (aka ranks) labelled 1-8 from bottom to top...