Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#include <Arduino.h> | |
int pins[] = {2, 3, 4, 5}; | |
int numPins = sizeof pins / sizeof pins[0]; | |
void setup() { | |
for (int i = 0; i < numPins; ++i) | |
pinMode(pins[i], OUTPUT); | |
} |
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
for n in range(10): | |
print('hello') | |
print('world!') | |
for n in range(1, 11): | |
print(n) | |
# Display the integers from -2 to 2 | |
for n in range(-2, 3): | |
print(n) |
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
for n in range(1, 11): | |
print(n) | |
# Display -5 to +5 | |
for n in range(-5, 6, 1): | |
print(n) | |
# Display even numbers from -2 to 6 | |
# Experiment with that 3rd argument |
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 pathlib | |
# Really old way | |
wf2 = open('words.txt') | |
lines = wf2.readlines() | |
wf2.close() | |
# Old way, closes file automatically | |
with open('words.txt') as words_file: |
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
package examples.maps; | |
import java.util.Arrays; | |
import java.util.stream.IntStream; | |
public class HashMap<K, V> { | |
public static class Bucket<K, V> { | |
public static class KeyAndValue<K, V> { | |
public K key; | |
public V value; |
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
package com.davebsoft | |
import scala.collection.mutable | |
import scala.io.Source | |
import scala.util.Using | |
case class FieldRanges(line: String) { | |
private val re = "([\\w ]+): (\\d+)-(\\d+) or (\\d+)-(\\d+)".r | |
private val m = re.findFirstMatchIn(line).get | |
val name: String = m.group(1) |
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
use std::collections::HashMap; | |
use regex::Regex; | |
use std::fs::File; | |
use std::io::{BufRead, BufReader}; | |
fn main() { | |
let mut memory: HashMap<u64, u64> = HashMap::new(); | |
let mut or_mask: u64 = 0; | |
let mut and_mask: u64 = 0; | |
let rx_mask = Regex::new(r"mask = ([X10]{36})").unwrap(); |
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
public class HasTeen { | |
public static boolean hasTeen(int a, int b, int c) { | |
return (a >= 13 && a <= 19) || (b >= 13 && b <= 19) || (c >= 13 && c <= 19); | |
} | |
public static void main(String[] args) { | |
assert hasTeen(13, 20, 10); | |
assert hasTeen(20, 19, 10); | |
assert hasTeen(20, 10, 13); | |
assert !hasTeen(20, 10, 10); |
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
void setup() { | |
size(1024, 768, P2D); | |
background(0); | |
} | |
void draw () { | |
stroke(255, 0, 0); | |
line(0, 0, mouseX, mouseY); | |
} |
NewerOlder