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 advent-of-code-2020.day4 | |
(:require [clojure.string :as str] | |
[clojure.set :as set])) | |
(def path "./resources/day4-input") | |
(def required-data | |
#{"byr" "iyr" "eyr" "hgt" "hcl" "ecl" "pid"}) | |
(defn valid-byr? [byr] |
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 advent-of-code-2020.day3 | |
(:require [clojure.string :as str])) | |
(def path "./resources/day3-input") | |
(defn wire-vec->map [map-vec] | |
{:path map-vec | |
:width (-> map-vec first count) | |
:height (count map-vec)}) |
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 advent-of-code-2020.day2 | |
(:require [clojure.string :as str])) | |
;;part 1 | |
(def path "./resources/day2-input") | |
(defn wire->policy+password [path] | |
(->> path | |
slurp | |
str/split-lines |
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 advent-of-code-2019.day-3 | |
(:require [clojure.string :as str] | |
[clojure.set :as set])) | |
(def letter->direction {"R" :right "L" :left "U" :up "D" :down}) | |
(defn str->direction+distance [[dir & dists]] | |
{:direction (letter->direction (str dir)) | |
:distance (Integer/parseInt (str/join dists))}) |
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 advent-of-code-2019.day-2 | |
(:require [clojure.string :as str])) | |
(defn halt? [[op & _]] (= op :halt)) | |
(defn pointer+memory->instruction [pointer memory] | |
(let [int->opcode {1 + 2 * 99 :halt} | |
op (nth memory pointer) | |
in1 (nth memory (inc pointer) 0) | |
in2 (nth memory (+ 2 pointer) 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
public class Proposal : Entity | |
{ | |
public Guid CandidateId { get; } | |
public Guid JobListingId { get; } | |
} | |
public class Proposal : Entity | |
{ | |
public Candidate CandidateId { get; } | |
public JobListing JobListingId { get; } |
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 Proposal | |
{ | |
private List<Comments> _comments; | |
public IReadOnlyList<Comments> Comments => _comments.AsReadOnly(); | |
private bool IsOpenForDiscussion => Status != ProposalStatus.Pending; | |
public void Discuss(Guid userId, string content) | |
{ | |
if(!IsOpenForDiscussion) | |
throw new DomainException("Can't discuss about an closed proposal"); |
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
const acceptProposal => (id, db, bus, logger) => { | |
const proposal = db.get(id); | |
proposal.acceptedAt = moment.now(); | |
proposal.status = ACCEPTED; | |
db.save(proposal); | |
bus.send({ type: ACCEPTED, payload: proposal.id}); | |
logger.sucess("Proposal accepted"); | |
} |
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 ProposalService | |
{ | |
public void AcceptProposal(Guid proposalId) | |
{ | |
var proposal = _repository.Find(proposalId); | |
//calling Accept method instead of changing its properties | |
if(DateTime.Now.Substract(proprosal.SentAt).TotalDays > 15) | |
throw new DomainException("This proprosal has expired"); | |
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 ProposalService | |
{ | |
public void AcceptProposal(Guid proposalId) | |
{ | |
var proposal = _repository.Find(proposalId); | |
proposal.Accept(domainService); | |
_repository.Save(proposal); | |
NewerOlder