Skip to content

Instantly share code, notes, and snippets.

@amuradyan
amuradyan / MigratoryBirds.scala
Created December 30, 2020 12:17
Hackerrank `Migratory Birds` problem
// https://www.hackerrank.com/challenges/migratory-birds/problem
//
// Input Output
// +-----------------------+----------+
// | 6 | 4 |
// | 1 4 4 4 5 3 | |
// +-----------------------+----------+
// | 11 | 3 |
// | 1 2 3 4 5 4 3 2 1 3 4 | |
// +-----------------------+----------+
@amuradyan
amuradyan / DayOfTheProgrammer.scala
Created December 29, 2020 19:46
Hackerrank `Day of the Programmer` problem
import scala.io._
trait Date {
def toDDMMYYYY: String = ???
}
case class ConcreteDate(day: Int, month: String, year: Int) extends Date {
override def toDDMMYYYY = s"$day.$month.$year"
}
case object EmptyDate extends Date
@amuradyan
amuradyan / TheBirthdayBar.scala
Created December 12, 2020 11:49
Hackerrank `The Birthday Bar` problem
// https://www.hackerrank.com/challenges/the-birthday-bar/problem
import scala.io._
import scala.annotation.tailrec
object Solution {
// Complete the birthday function below.
def birthday(s: Array[Int], d: Int, m: Int): Int = {
@amuradyan
amuradyan / BreakingTheRecords.scala
Last active December 10, 2020 22:02
Hackerrank `Breaking the Records` problem
import java.io._
import java.math._
import java.security._
import java.text._
import java.util._
import java.util.concurrent._
import java.util.function._
import java.util.regex._
import java.util.stream._
@amuradyan
amuradyan / NumberLineJumps.scala
Created December 9, 2020 16:24
Hackerrank `Number Line Jumps` problem
import java.io._
import java.math._
import java.security._
import java.text._
import java.util._
import java.util.concurrent._
import java.util.function._
import java.util.regex._
import java.util.stream._
@amuradyan
amuradyan / ApplesAndOranges.scala
Created December 9, 2020 15:49
Hackerrank `Apples and oranges` problem
import java.io._
import java.math._
import java.security._
import java.text._
import java.util._
import java.util.concurrent._
import java.util.function._
import java.util.regex._
import java.util.stream._
// If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
// Find the sum of all the multiples of 3 or 5 below 1000.
void doShit() {
Integer currentValue = 1;
Integer acc = 0;
while(currentValue < 1000) {
boolean imot = ((currentValue / 3) == (currentValue / 3.0));
boolean imof = ((currentValue / 5) == (currentValue / 5.0));
@amuradyan
amuradyan / հմմմ.java
Created December 28, 2019 11:00
հմմմ
((ClassType)((com.sun.tools.javac.code.Symbol)((com.sun.tools.javac.code.Scope.Entry[])((com.sun.tools.javac.code.Scope.ScopeImpl)((com.sun.tools.javac.code.Symbol.PackageSymbol)((JCTree.JCCompilationUnit)cu).packge).members_field).table)[2].sym).type).supertype_field
@amuradyan
amuradyan / Scala .gitignore
Last active August 22, 2019 15:34 — forked from owainlewis/.gitignore
Scala gitignore
*.class
*.log
# sbt specific
.cache/
.history/
.lib/
dist/*
target/
lib_managed/
from datetime import datetime
from math import ceil
import calendar
def dates(d1: datetime, d2: datetime) -> list:
middle = []
for year in range(d1.year, d2.year):
middle.append(datetime(year, 12, 31))