If you're trying to iterate all combinations of k=5 on n=36, this is how you loop through them.
int k = 5;
int n = 36;
int count = 0;
for (int i1=1; i1 <= n-k+1; i1++)| def print_target_moves(aTimeCapacity, bTimeCapacity, targetTime): | |
| ''' | |
| Given two hourglasses with respective time capacities, | |
| print out a process for measuring the given target time | |
| without going over that time. | |
| An hour glass can only be flipped when any of them have run out. | |
| TODO: generalize to multiple hour-glasses | |
| ''' | |
| moves = [] |
| % the tile width of the rectangular map | |
| #const width=4. | |
| positions(0..11). | |
| rotations(0..3). | |
| % piece(number, side, side type [g=grass, w=water, c=city, r=road]). | |
| piece( 1,0,g ;; 1,1,g ;; 1,2,g ;; 1,3,w). | |
| piece( 2,0,g ;; 2,1,g ;; 2,2,g ;; 2,3,w). | |
| piece( 3,0,g ;; 3,1,w ;; 3,2,g ;; 3,3,w). |
| entries = getListOfTableEntriesSomeWhere() | |
| entryTree = MyTree(entries) | |
| ################################ | |
| def group_entries(groupclass, entries, keyfunc): | |
| return [groupclass(k,g) for k,g in itertools.groupby(entries,keyfunc)] | |
| key_sys = lambda x: x.sys | |
| key_subsys = lambda x: x.subsys |
item 1
item 2
item 3
// code here
should be equivalent to...
| /* | |
| You can use this script with Google Swiffy to produce SVG frames from an SWF animation. | |
| 1. Upload your SWF file to Google Swiffy --> https://www.google.com/doubleclick/studio/swiffy/ | |
| 2. Save the swiffy output HTML page locally. | |
| 3. Edit the page to include this script with <script src="getSvgFrames.js"></script> | |
| 4. Open the page in Firefox to see the SVG download links appear for each frame. | |
| */ | |
| (function(){ | |
| var url = window.location.pathname; |
| /* | |
| 2D Angle Interpolation (shortest distance) | |
| Parameters: | |
| a0 = start angle | |
| a1 = end angle | |
| t = interpolation factor (0.0=start, 1.0=end) | |
| Benefits: | |
| 1. Angles do NOT need to be normalized. |
| // source: http://java.dzone.com/articles/using-lambda-expression-sort | |
| // sort by first name | |
| people.sort((p1, p2) -> p1.firstName.compareTo(p2.firstName)); | |
| // sort by full name | |
| String fullName(Person p) { return p.firstName + " " + p.lastName; } | |
| people.sort((p1, p2) -> fullName(p1).compareTo(fullName(p2))); |
| ; Suggested in Om Basic Tutorial for making strings work as cursors | |
| (extend-type string | |
| ICloneable | |
| (-clone [s] (js/String. s))) | |
| (extend-type js/String | |
| ICloneable | |
| (-clone [s] (js/String. s)) | |
| om/IValue | |
| (-value [s] (str s))) |
| (def initial-app-state | |
| {:page "search" | |
| :market nil | |
| :market-strategies [] | |
| :market-filter (default-filter) | |
| :edit-strategy nil}) |