Python Labs
-
Write a countdown timer that counts for 120 seconds (ticks every second), printing the remaining seconds to wait in each tick
-
Change your countdown timer to show remaining time like a watch, i.e.: 2:00 1:59 1:58 ... 1:20
defmodule Day1 do | |
def read_input do | |
File.read!("input/day1.txt") | |
|> String.split("\n", trim: true) | |
|> Enum.map(&String.to_integer/1) | |
end | |
def part1 do | |
values = read_input() | |
for a <- values, b <- values, a + b == 2020, do: a * b |
text = "some string (with parentheses (and also inner parentheses)) (yay) hi" | |
stack = [] | |
for i in range(len(text)): | |
char = text[i] | |
if char == "(": | |
stack.append(char) | |
elif char == ")": | |
stack.pop() | |
if len(stack) == 0: |
#!/usr/bin/env ruby | |
require 'csv' | |
require 'json' | |
def print_as_json(data) | |
$/ = "\n" | |
csv = CSV.new(data, :headers => true, liberal_parsing: true) | |
puts csv.to_a.map {|row| row.to_hash }.to_json | |
$/ = "---===---" |
from PyQt5.QtCore import * | |
from PyQt5.QtWidgets import * | |
from ui_mainwindow import Ui_MainWindow | |
from functools import partial | |
import sys | |
class MainWindow(QMainWindow): | |
def __init__(self): | |
super().__init__() |
Python Labs
Write a countdown timer that counts for 120 seconds (ticks every second), printing the remaining seconds to wait in each tick
Change your countdown timer to show remaining time like a watch, i.e.: 2:00 1:59 1:58 ... 1:20
(defn power | |
[serial x y] | |
(let [ | |
rack-id (+ x 10) | |
] | |
(- | |
(Math/floor |
(ns aoc2018.day5 | |
(:require [clojure.string :as s])) | |
(def letters (map char (concat (range 97 123)))) | |
(def reactions | |
(re-pattern | |
(s/join "|" | |
(for [letter letters] | |
(str |
(ns aoc2018.day4 | |
(:require [clojure.math.combinatorics :as combo])) | |
(defn add-guard-sleep-time | |
[guards-map current-guard last-sleep-time line] | |
(let [ | |
wake-up-time (first (drop 1 (re-find #"\d+-\d+-\d+ \d+:(\d+)" line))) | |
nwake-up-time (Integer/parseInt wake-up-time) | |
nsleep-time (Integer/parseInt last-sleep-time)] |
rails new feeder --webpack=react --skip-turbolinks | |
--- Setup | |
1. Install devise and create a user model | |
* rails generate devise:install | |
* rails generate devise User | |
2. Create a Post model: | |
./bin/rails g scaffold post user:references text:text color:string |