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 OrderCreationController { | |
private final OrderRepository orderRepository; | |
private final ProductCatalog productCatalog; | |
public OrderCreationController(OrderRepository orderRepository, ProductCatalog productCatalog) { | |
this.orderRepository = orderRepository; | |
this.productCatalog = productCatalog; | |
} | |
public Response post(List<Item> requests) { |
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
~ cat .gitconfig-personal | |
[user] | |
signingkey = XXXXXXXXXX | |
name = Renan Reis Martins de Paula | |
email = renanreismartins@gmail.com | |
[core] | |
sshCommand = "ssh -i ~/.ssh/id_rsa_personal" | |
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
object BestSum extends App { | |
def bestSum(n: Int, coins: Array[Int]): Array[Int] = { | |
if (n == 0) return Array[Int]() | |
if (n < 0) return null | |
var shortest: Array[Int] = null; | |
for (coin <- coins) { |
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
object HowSum extends App { | |
def howSum(n: Int, coins: Array[Int]): Array[Int] = { | |
if (n == 0) return Array[Int]() | |
if (n < 0) return null | |
for (coin <- coins) { | |
val rest = n - coin | |
val ints = howSum(rest, coins) |
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
object CanSum extends App { | |
def canSum(n: Int, coins: Array[Int]): Boolean = { | |
if (n == 0) return true | |
if (n < 0) return false | |
for (coin <- coins) { | |
val rest = n - coin | |
return canSum(rest, coins) |
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
object CanSum extends App { | |
def canSum(n: Int, coins: Array[Int]): Boolean = { | |
if (n == 0) return true | |
for (coin <- coins) { | |
val rest = n - coin | |
if (rest >= 0) return canSum(rest, coins) | |
} |
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
object MissingPositive extends App { | |
def missingPositive(nums: Array[Int]): Int = { | |
val found: Map[Int, Int] = nums.foldLeft(Map[Int, Int]())((m, i) => if (i >= 0) m + (i -> 1) else m) | |
val min = nums | |
.filter(e => e > 0) | |
.foldLeft(Integer.MAX_VALUE)((m, i) => i.min(m)) | |
if (min >= 0) { | |
var count = 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
object MissingPositive extends App { | |
def missingPositive(nums: Array[Int]): Int = { | |
//val m1: Map[Int, Int] = (0 until nums.length).foldLeft(Map[Int, Int]())((m, i) => if (nums(i) > 0) m + (i -> 1) else m) | |
val found = scala.collection.mutable.Map[Int, Int]() | |
var min = Integer.MAX_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
object MissingNumber extends App { | |
def missingNumber(nums: Array[Int]): Int = { | |
val found = new Array[Int](nums.length) | |
for (n <- nums) { | |
if (n < nums.length) found(n) = 1 | |
} | |
val missing = found.indexOf(0) |
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
(ns griffin.spec.journal-entry | |
(:require [clojure.spec.alpha :as s])) | |
(s/def ::id uuid?) | |
(s/def ::account-id uuid?) | |
(s/def ::type #{:credit :debit}) | |
(s/def ::amount pos-int?) | |
(s/def ::line-item (s/keys :req-un [::account-id ::amount ::type])) | |
(s/def ::line-items (s/coll-of ::line-item :min-count 2)) | |
(s/def ::journal-entry (s/keys :req-un [::id ::line-items])) |
NewerOlder