Skip to content

Instantly share code, notes, and snippets.

namespace EBT.SOF.DTO
{
public class SessionDto
{
public long Id { get; set; }
....
public ValidationResultDto ValidationResult { get; set; }
}

The knight is the piece in the game of chess that, in one turn, can move two squares horizontally and one square vertically or two squares vertically and one square horizontally.

An infinite chessboard is given. All of its squares are empty except for the square with coordinates (0,0), where a knight stands.

Write a function:

def solution(A, B)

that, given two numbers A and B, returns the minimum number of turns required for the knight to move from square (0,0) to square (A,B). The function should return -1 if the knight cannot reach the given square. The function should return -2 if the required number of turns exceeds 100,000,000.

An integer X and a non-empty zero-indexed array A consisting of N integers are given. We are interested in which elements of A are equal to X and which are different from X. The goal is to split array A into two parts, such that the number of elements equal to X in the first part is the same as the number of elements different from X in the other part. More formally, we are looking for an index K such that:

  • 0 ≤ K < N and
  • the number of elements equal to X in A[0..K−1] is the same as the number of elements different from X in A[K..N−1]. (For K = 0, A[0..K−1] does not contain any elements. For K = N, A[K..N-1] does not contain any elements.)

For example, given integer X = 5 and array A such that:

A = [5, 5, 1, 7, 2, 3, 5]

K equals 4, because:

### Keybase proof
I hereby claim:
* I am u3k on github.
* I am u3k (https://keybase.io/u3k) on keybase.
* I have a public key whose fingerprint is 3F03 84E5 7E67 5727 54F3 457F 3B35 191A E950 7B8D
To claim this, I am signing this object:
@u3k
u3k / designer.html
Created July 20, 2014 11:50
designer
<link rel="import" href="../core-animated-pages/core-animated-pages.html">
<link rel="import" href="../core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../core-animated-pages/transitions/cross-fade.html">
<link rel="import" href="../core-animated-pages/transitions/slide-down.html">
<link rel="import" href="../core-animated-pages/transitions/slide-up.html">
<link rel="import" href="../core-animated-pages/transitions/tile-cascade.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/iconsets/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../paper-button/paper-button.html">
@u3k
u3k / promises.md
Last active December 27, 2015 20:59 — forked from calvinmetcalf/promises.md
/*

#Promises

This file is both legal JavaScript and markdown, so if there are a few quirks like that open comment up there, that is why.

This code is from a [promise library called 'lie'][lie]. You can install it from npm with npm install lie.

The intent of this code is to implement promises in a straightforward way that is as close to the spec as possible while also being readable and performance. The version of promises that ended up being settled on is (as of 10/27/13) a simple constructor which takes as its sole argument a function with 2 arguments, 'fulfill' and 'reject'. Gone are the earlier notions of promises and deferred objects (which is good a I kept trying to spell deferred with 2 Fs and 1 R).