This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Passengers in a Railroad Compartment | |
Six passengers sharing a train compartment are from Moscow, Leningrad, Tula, | |
Kiev, Kharkov, and Odessa. | |
1. A and the man from Moscow are physicians | |
2. E and the Leningrader are teachers. | |
3. The man from Tula and C are engineers. | |
4. B and F are WWII veterans, but the man from Tula has never served in the | |
armed forces. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Solver for "Jumping Checkers" problem. | |
Place 3 white checkers in squares 1, 2, and 3 of the figure, and 3 black ones | |
on swuares 5, 6, 7. Shift the white checkers to the squares occupied by the | |
black ones, and vice versa. | |
Board |0|0|0| |1|1|1| | |
Square # 1 2 3 4 5 6 7 | |
You may move a checker forward to an adjacent unoccupied square, if any. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Blacksmith Khecho's Ingenuity | |
[...] | |
Khecho, calmly looking around, climbed the steps to the tower's upper | |
part and glanced out the window. He realized it would be impossible to | |
jump out and survive. But he saw a rope, forgotten by the masons, hanging | |
near the window. The rope was thrown over a rusty tackle fastned to the | |
tower wall above the window. Empty baskets were tied to each end of the | |
rope. Those baskets had been used by the masons to lift bricks and lower |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import random | |
def weighted_draw(items, target): | |
"""Draw item from iterable based on probability distribution of items. | |
Args | |
items: tuple of (item: float of probability) pairs where the. | |
sum probability has been normalized to 1 | |
target: float, random number between 0 and 1 used to determine | |
the item to draw from items |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let product = List.fold (*) 1 | |
let product = List.fold (fun acc x -> acc * x) 1 | |
let fold1 f items = | |
List.fold f (List.head items) (List.tail items) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
### Test | |
def test_predecessor(): | |
"""Basic unit tests for find_predecessor.""" | |
assert main('1432', 0) == '1423' | |
assert main('04123', 0) == '03421' | |
assert main('315426', 0) == '315264' | |
assert main('315246', 0) == '314652' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""River Fording Puzzle. | |
3 girls, each with her father, go for a stroll. They come to a small river. | |
One boat, able to carry 2 persons at a time, is at their disposal. | |
Crossing would be simple for everyone except the girls. None is willing to be | |
in the boat or ashore with 1 or 2 strange fathers, unless her own father is | |
present too. How do they all get across? | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""River Fording Puzzle. | |
3 girls, each with her father, go for a stroll. They come to a small river. | |
One boat, able to carry 2 persons at a time, is at their disposal. | |
Crossing would be simple for everyone except the girls. None is willing to be | |
in the boat or ashore with 1 or 2 strange fathers, unless her own father is | |
present too. How do they all get across? | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""River Fording Puzzle. | |
3 girls, each with her father, go for a stroll. They come to a small river. | |
One boat, able to carry 2 persons at a time, is at their disposal. | |
Crossing would be simple for everyone except the girls. None is willing to be | |
in the boat or ashore with 1 or 2 strange fathers, unless her own father is | |
present too. How do they all get across? | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Plugins https://github.com/tpope/vim-pathogen | |
execute pathogen#infect() | |
""" General UI | |
" line numbers | |
set number | |
" Turn on the WiLd menu |
OlderNewer