Skip to content

Instantly share code, notes, and snippets.

@Odomontois
Odomontois / ctfp.md
Last active February 16, 2023 16:36
Теория категорий для программистов

Теория категорий для программистов

Книга о математике для нематематиков от нематематика , которую он никогда не писал

Домашняя работа для курса "Как «работает» cовременная литература"

Только что закончилась эпоха, когда востребованность IT и в частности программистов бесперебойно росла.

В образовавшемся вокруг спроса огромном сообществе людей с разным прошлым, но примерно одинаковой формой настоящего, проросло множество субкультурных веток. Появились свои "селебрити" - авторы блогов и книг разгуливающие по конференциям и университетам с лекциями, и похоже, что зарабатывающие исключительно своим авторитетом, переходя в качестве "консультанта" из корпорации в корпорацию. Такие как "Дядя Боб", Мартин Фаулер, Алан Кэй

@Odomontois
Odomontois / earlyAction.go
Created December 6, 2022 08:54
Early return action
func conds(){
earlyReturn := true
defer func(){
if earlyReturn{
action2()
}
}()
prepareForCond1()
if !cond1{

Ресурсы для изучения scala

На русском языке

Книги

Онлайн-курсы

Stepik

@Odomontois
Odomontois / plan.md
Last active September 30, 2021 12:13

План

  1. Intro
    1. Mystery shit
    2. Нормальное интро
  2. История
    1. Rust
    2. Scala
    3. Tinkoff
      1. Найм
  3. Сравнение rust и scala
[
{
"id": 725581,
"title": "[Python] 2 Pointers O(n^2) solution, explained",
"taskUrl": "https://leetcode.com/problems/3sum",
"post": {
"id": 1337818,
"content": "This problem is similar to **2Sum** problem, but here we need to find sums of three elements. We can use similar idea with hash-tables, but the problem here is that we can have duplicates, and it is a bit painful to deal with them, using hash-tables, we need to count frequencies, make sure, we did not use the same elements and so on.\\n\\nAnother approach is to use **2 Pointers** approach. Let us sort our data first and choose element number `i`. What we need to find now is some elements with indexes `beg` and `end`, such that `i \u003c beg \u003c end` and `nums[beg] + nums[end] = target = -nums[i]`. Here times come to use our **2 Pointers** approach: we start from `beg, end = i + 1, n - 1`, and move `beg` to the right and `end` to the left, comparing `nums[beg] + nums[end]` with our target
{
"data": {
"userRecentTopics": [
{
"id": 1134197,
"title": "[Python] 4 lines solution, explained",
"commentCount": 4,
"post": {
"creationDate": 1617104975,
"voteCount": 22,
use std::iter::successors;
lazy_static! {
static ref POWS: Vec<u64> = (0..30).map(|x| 1 << x).map(digit_map).collect();
}
impl Solution {
pub fn reordered_power_of2(n: i32) -> bool {
POWS.contains(&digit_map(n))
}
@Odomontois
Odomontois / FromPublisher.scala
Created February 11, 2021 12:22
FromPublisher
package healer.reactive
import java.util.concurrent.atomic.{AtomicBoolean, AtomicReference}
import cats.effect.Concurrent
import cats.syntax.foldable._
import cats.syntax.monoid._
import cats.{Monad, Monoid}
import healer.reactive.impl._
import io.iteratee.Enumerator
import collection.immutable.TreeSet
object Solution {
case class Item(cur: Int, next: List[Int], id: Int)
implicit val itemOrdering: Ordering[Item] = Ordering.by(i => (i.cur,i.next.headOption, i.id))
def go(s: TreeSet[Item]): LazyList[Vector[Int]] =
Vector(s.head.cur, s.last.cur) #:: (s.head match {
case Item(_, x :: rest, id) => go(s.tail + Item(x, rest, id))
case _ => LazyList.empty
})
def smallestRange(nums: List[List[Int]]): Array[Int] =
# noinspection PyPep8Naming
class Solution:
def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int:
d = defaultdict(list)
for word in wordList:
for i in range(len(word)):
d[word[:i], word[i + 1:]].append(word)
seen = {beginWord}
q = [beginWord]
steps = 1