This file contains hidden or 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
| use itertools::Itertools; | |
| use std::convert::From; | |
| use std::fs::File; | |
| use std::io::{self, BufRead}; | |
| use std::ops::BitAnd; | |
| fn main() { | |
| let backpacks = get_data("./input"); | |
| println!("Part1: {}", part1(&backpacks)); | |
| println!("Part2: {}", part2(&backpacks)); |
This file contains hidden or 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
| defmodule Mandel do | |
| defp mandel(x0, y0, zoom, iter_max) do | |
| loop = fn | |
| (_, _, _, ^iter_max) -> 0 | |
| (self, x, y, iter) -> | |
| x_x = x * x |> div(zoom) | |
| y_y = y * y |> div(zoom) | |
| if x_x + y_y > 4 * zoom do | |
| iter |