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 Comment | |
{ | |
public Guid ProposalId { get; } | |
public Guid UserId { get; } | |
public string Content { get; private set; } | |
public Comment(Guid proposalId, Guid userId, string content) | |
{ | |
if(String.IsNullOrWhiteSpace(content)) | |
throw new DomainException("Empty comments not allowed"); |
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 IsOpenForComments => Status == ProposalStatus.Pending; | |
public Guid CandidateId { get; } | |
public Guid JobListingId { get; } | |
public ProposaStatus Status { get; private set; } | |
public DateTime ClosedAt { get; private set; } |
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
var proposal = _proposalRepository.Find(id); | |
proposal.Candidate.Ban(); | |
proposal.JobListing.AddPreRequisite(PreRequisite.Clojure); | |
proposalRepository.Save(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
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
var inconsistentComment = new Comment(closedProposalId, anyCandidateIdIWant, content); | |
_commentsRepository.Save(comment); |
NewerOlder