|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "## Programming Problem\n", |
| 8 | + "\n", |
| 9 | + "Continue with the previous [USACO problem](http://usaco.org/index.php?page=viewproblem2&cpid=1180).\n", |
| 10 | + "\n", |
| 11 | + "Finish the `iscycle(A, B, C)` function that checks whether dice `A`, `B`, and `C` form a cycle. A cycle is formed if no two dice tie and no dice beats the other two.\n", |
| 12 | + "\n", |
| 13 | + "NOTE: I didn't implement the `iscycle(A, B, C)` function in my original solution. The implementation is below." |
| 14 | + ] |
| 15 | + }, |
| 16 | + { |
| 17 | + "cell_type": "code", |
| 18 | + "execution_count": null, |
| 19 | + "metadata": {}, |
| 20 | + "outputs": [], |
| 21 | + "source": [ |
| 22 | + "# NOTE: beats(A, B) function is not implemented here\n", |
| 23 | + "\n", |
| 24 | + "def iscycle(A, B, C):\n", |
| 25 | + " \"\"\"Assumes that A beats B. This establishes an order so we don't have to test\n", |
| 26 | + " cycles going two ways. This function tests what that B->C and C->A. \"\"\"\n", |
| 27 | + " return beats(B, C) > 0 and beats(C, A) > 0" |
| 28 | + ] |
| 29 | + } |
| 30 | + ], |
| 31 | + "metadata": { |
| 32 | + "interpreter": { |
| 33 | + "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" |
| 34 | + }, |
| 35 | + "kernelspec": { |
| 36 | + "display_name": "Python 3.9.10 64-bit", |
| 37 | + "language": "python", |
| 38 | + "name": "python3" |
| 39 | + }, |
| 40 | + "language_info": { |
| 41 | + "codemirror_mode": { |
| 42 | + "name": "ipython", |
| 43 | + "version": 3 |
| 44 | + }, |
| 45 | + "file_extension": ".py", |
| 46 | + "mimetype": "text/x-python", |
| 47 | + "name": "python", |
| 48 | + "nbconvert_exporter": "python", |
| 49 | + "pygments_lexer": "ipython3", |
| 50 | + "version": "3.9.10" |
| 51 | + }, |
| 52 | + "orig_nbformat": 4 |
| 53 | + }, |
| 54 | + "nbformat": 4, |
| 55 | + "nbformat_minor": 2 |
| 56 | +} |
0 commit comments