Skip to content

Instantly share code, notes, and snippets.

use aoc_runner_derive::aoc;
use aoc_runner_derive::aoc_generator;
use regex::Regex;
use std::cmp;
use rand::prelude::*;
#[derive(Debug, Clone)]
pub struct NanoBot {
x: i64,
y: i64,
const LOOKUP : [u32; 64] = [38195, 38195, 38195, 38195, 4403, 13107, 54743, 48059, 5393, 39219, 21847, 39355, 37137, 47411, 21973, 39355, 4403, 13107, 22391, 48059, 46899, 46899, 46899, 46899, 5427, 47411, 22391, 48059, 37171, 47923, 22007, 48059, 5427, 13107, 22391, 39867, 5939, 14195, 55287, 48059, 38773, 38773, 38773, 38773, 38193, 47923, 21973, 39867, 37171, 47923, 22519, 48059, 45875, 47923, 57343, 48059, 38193, 47547, 22519, 48059, 46521, 46521, 46521, 46521];
pub fn solve_part1_faster(input: &str) -> usize {
let input = input.as_bytes();
let mut ret = 0;
let mut index = 0;
while index < input.len() {
if input[index] != b'B' { break; }
pub fn solve_part1_fast2(input: &str) -> usize {
let mut lines = input.lines();
let mut ret = 0;
let lookup : Vec<u32> = vec![38195, 38195, 38195, 38195, 4403, 13107, 54743, 48059, 5393, 39219, 21847, 39355, 37137, 47411, 21973, 39355, 4403, 13107, 22391, 48059, 46899, 46899, 46899, 46899, 5427, 47411, 22391, 48059, 37171, 47923, 22007, 48059, 5427, 13107, 22391, 39867, 5939, 14195, 55287, 48059, 38773, 38773, 38773, 38773, 38193, 47923, 21973, 39867, 37171, 47923, 22519, 48059, 45875, 47923, 57343, 48059, 38193, 47547, 22519, 48059, 46521, 46521, 46521, 46521];
while let Some(line) = lines.next() {
if line.is_empty() || line.as_bytes()[0] != b'B' { break; }
let before = line.as_bytes();
let op = lines.next().unwrap().as_bytes();
@fryguy1013
fryguy1013 / realtime.html
Created April 30, 2012 22:32
Realtime simplegraph
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://jquery-json.googlecode.com/files/jquery.json-2.2.min.js"></script>
<script type="text/javascript" src="http://jquery-websocket.googlecode.com/files/jquery.websocket-0.0.1.js"></script>