/aocg/ - Advent of Code 2018 General #3

Previous thread: Read the instructions edition

adventofcode.com/
>Advent of Code is a series of small programming puzzles for a variety of skill levels. They are self-contained and are just as appropriate for an expert who wants to stay sharp as they are for a beginner who is just learning to code. Each puzzle calls upon different skills and has two parts that build on a theme.
You need to register with an account but you can appear as anonymous.

Private leaderboard join code: 368748-e33dcae3
People who are inactive for 5 days will be kicked, but other leaderboards can be made if desired.

Attached: read_the_instructions.png (717x558, 344K)

Other urls found in this thread:

stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
gist.github.com/CameronAavik/2cd37a899290da1e8ad43c6d51a28796
artima.com/weblogs/viewpost.jsp?thread=98196
pastebin.com/ZHCfLavQ
twitter.com/SFWRedditImages

You should put SICP in the picture.

Swift

func partOne(_ input: [String]) -> Int {
return input.map { Int(String($0)) ?? 0 }.reduce(0, +)
}

print(partOne(input))

func partTwo(_ input: [String]) {
let inputFixed = input.map { Int(String($0)) ?? 0 }
var already_seen = Set()
var freq = 0
var found_repeat = false
while !found_repeat {
for val in inputFixed {
freq += val
let (insertWasSuccessful, insertedValue) = already_seen.insert(freq)
if !insertWasSuccessful {
print(insertedValue)
found_repeat = !insertWasSuccessful
break
}
}
}
}

partTwo(input)

You should choke on a dick.

LITERALLY
SEE
THE
OP
IMAGE
YOU
DROOLING
RETARD

look at the OP picture you nigger.

>mixing camel case and snake case
That's what I get for "porting" my C++ solution I guess.

Nah, algos book much more represents the current situation.

tfw this is only point in the year where I am motivated to learn to code shit
I don't even browse chans anymore

Attached: u-xYG6DTedo_00:00:55.666_0002.png.jpg (1280x720, 113K)

sorry :c

public long Duplicate()
{
while (true)
{
foreach (var n in _input)
{
_curfreq += n;
if (!_seen.Add(_curfreq))
{
return _curfreq;
}
}
}
}


I made it work though :)

>>caring about normie conventions
ISHYGDDT.mp9