Coder Social home page Coder Social logo

elv's People

Contributors

kpagacz avatar

Stargazers

 avatar

Watchers

 avatar

elv's Issues

Prevent submitting an answer to an already solved day

╰─⠠⠵ elv -y 2020 -d 4 s two 111   
♻️  You submitted this answer before and the result was...


That's the right answer! You are one gold star closer to saving your vacation.


╭─konradpagacz@konrads-macbook-pro /Users/konradpagacz/projects/comp-programming/advent-of-code/2020/day-4                                                                                         main
╰─⠠⠵ elv -y 2020 -d 4 s two 110
Your submission result...


You don't seem to be solving the right level. Did you already complete it? [Return to Day 4]


╭─konradpagacz@konrads-macbook-pro /Users/konradpagacz/projects/comp-programming/advent-of-code/2020/day-4                                                                                         main
╰─⠠⠵ elv -y 2020 -d 4 s two 111
♻️  You submitted this answer before and the result was...


That's the right answer! You are one gold star closer to saving your vacation.

Upgrade `html2text` dependency

0.4.5 fixes a bug where empty lines in

 block would get deleted.

elv code needs to be updates because right now it inserts <br> at the end of all lines in <pre> blocks to work around this bug.

When submitting an answer for the first time

─⠠⠵ elv -y 2020 -d 3 s one 228    
Error: Cache file not found: /Users/konradpagacz/Library/Caches/aoc-elf/submissions/2020-3
The application will not have any memory of this submission.
Your submission result:
"That's the right answer! You are one gold star closer to saving your vacation. [Continue to Part Two]\n"

Reddit comment

This redditor took time to review elv source code:

Oh, nice. My preference is for library functions rather than a CLI tool - I can just call input_for_day(13) to get day 13's input, downloading if necessary (2022 being baked in), but this is pretty cool.

You've got automated submission, too, though! It was on my maybe-todo list, but I run and rerun things often enough that I didn't want to accidentally lock myself out for future problems. Does the API accept solutions for previously-solved problems? Otherwise I imagine it would be tricky to test.

You're even checking the timing to avoid requesting unreleased problems, which is cool. That's something I do too, though I chose not to mention above. I think US Eastern is UTC-5 right now - you might want to double-check that the let now = chrono::Utc::now() - chrono::Duration::hours(4); is right (I assume that's why you did it). I did it a little differently, feel free to steal (this assumes day and YEAR are known, if not you could get them from now):

let eastern_tz = chrono_tz::US::Eastern;
let opening_time = eastern_tz.ymd(YEAR, 12, day as u32).and_hms(0, 0, 0);
let now = Utc::now().with_timezone(&eastern_tz);

Guessing the part is buggy

kpagacz@konrads-macbook-pro-2 ~/p/c/a/2/day-01> elv s -y 2021 -d 1 3329926                                                                                                                                                                                                           main?
thread 'main' panicked at /Users/kpagacz/.cargo/registry/src/index.crates.io-6f17d22bba15001f/elv-0.13.1/src/application/cli.rs:85:26:
called `Result::unwrap()` on an `Err` value: ❌ Could not guess the riddle part. Provide it manually as an argument

Caused by:
    Both parts answered
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Fix the wrong time zone when checking whether the input is available

From #9

You're even checking the timing to avoid requesting unreleased problems, which is cool. That's something I do too, though I chose not to mention above. I think US Eastern is UTC-5 right now - you might want to double-check that the let now = chrono::Utc::now() - chrono::Duration::hours(4); is right (I assume that's why you did it). I did it a little differently, feel free to steal (this assumes day and YEAR are known, if not you could get them from now):

let eastern_tz = chrono_tz::US::Eastern;
let opening_time = eastern_tz.ymd(YEAR, 12, day as u32).and_hms(0, 0, 0);
let now = Utc::now().with_timezone(&eastern_tz);

Show stars page

It would be nice to show the stars page under some command

Expose the width of the output to users

Right now, the width of the output (in characters) is fixed to 120 characters.

Expose the width of the output as a flag to commands and as a configuration

Investigate the cache behaviour

In this scenario:

  • submit an answer to part 2 of a riddle when you have not solved part 1
  • solve part 1
  • submit an answer to part 2

What will the cache do?

Change the order of the arguments in the cli

Right now the user has to input year, day and token arguments even for commands that don't need them. Fix it and make it so that the arguments follow the verb instead of doing it the other way.

`elv` does not show the user's answers to the puzzle when printing the description

As an example:


As the expedition finally reaches the extraction point, several large hot air balloons drift down to meet you. Crews
quickly start unloading the equipment the balloons brought: many hot air balloon kits, some fuel tanks, and a fuel
heating machine.

The fuel heating machine is a new addition to the process. When this mountain was a volcano, the ambient temperature was
more reasonable; now, it's so cold that the fuel won't work at all without being warmed up first.

The Elves, seemingly in an attempt to make the new machine feel welcome, have already attached a pair of googly eyes and
started calling it "Bob".

To heat the fuel, Bob needs to know the total amount of fuel that will be processed ahead of time so it can correctly
calibrate heat output and flow rate. This amount is simply the sum of the fuel requirements of all of the hot air
balloons, and those fuel requirements are even listed clearly on the side of each hot air balloon's burner.

You assume the Elves will have no trouble adding up some numbers and are about to go back to figuring out which balloon
is yours when you get a tap on the shoulder. Apparently, the fuel requirements use numbers written in a format the Elves
don't recognize; predictably, they'd like your help deciphering them.

You make a list of all of the fuel requirements (your puzzle input), but you don't recognize the number format either.
For example:

1=-0-2
12111
2=0=
21
2=01
111
20012
112
1=-1=
1-12
12
1=
122

Fortunately, Bob is labeled with a support phone number. Not to be deterred, you call and ask for help.

"That's right, just supply the fuel amount to the-- oh, for more than one burner? No problem, you just need to add
together our Special Numeral-Analogue Fuel Units. Patent pending! They're way better than normal numbers for--"

You mention that it's quite cold up here and ask if they can skip ahead.

"Okay, our Special Numeral-Analogue Fuel Units - SNAFU for short - are sort of like normal numbers. You know how
starting on the right, normal numbers have a ones place, a tens place, a hundreds place, and so on, where the digit in
each place tells you how many of that value you have?"

"SNAFU works the same way, except it uses powers of five instead of ten. Starting from the right, you have a ones place,
a fives place, a twenty-fives place, a one-hundred-and-twenty-fives place, and so on. It's that easy!"

You ask why some of the digits look like - or = instead of "digits".

"You know, I never did ask the engineers why they did that. Instead of using digits four through zero, the digits are 2,
1, 0, minus (written -), and double-minus (written =). Minus is worth -1, and double-minus is worth -2."

"So, because ten (in normal numbers) is two fives and no ones, in SNAFU it is written 20. Since eight (in normal
numbers) is two fives minus two ones, it is written 2=."

"You can do it the other direction, too. Say you have the SNAFU number 2=-01. That's 2 in the 625s place, =
(double-minus) in the 125s place, - (minus) in the 25s place, 0 in the 5s place, and 1 in the 1s place. (2 times 625)
plus (-2 times 125) plus (-1 times 25) plus (0 times 5) plus (1 times 1). That's 1250 plus -250 plus -25 plus 0 plus 1.
976!"

"I see here that you're connected via our premium uplink service, so I'll transmit our handy SNAFU brochure to you now.
Did you need anything else?"

You ask if the fuel will even work in these temperatures.

"Wait, it's how cold? There's no way the fuel - or any fuel - would work in those conditions! There are only a few
places in the-- where did you say you are again?"

Just then, you notice one of the Elves pour a few drops from a snowflake-shaped container into one of the fuel tanks,
thank the support representative for their time, and disconnect the call.

The SNAFU brochure contains a few more examples of decimal ("normal") numbers and their SNAFU counterparts:

  Decimal          SNAFU
        1              1
        2              2
        3             1=
        4             1-
        5             10
        6             11
        7             12
        8             2=
        9             2-
       10             20
       15            1=0
       20            1-0
     2022         1=11-2
    12345        1-0---0
314159265  1121-1110-1=0

Based on this process, the SNAFU numbers in the example above can be converted to decimal numbers as follows:

 SNAFU  Decimal
1=-0-2     1747
 12111      906
  2=0=      198
    21       11
  2=01      201
   111       31
 20012     1257
   112       32
 1=-1=      353
  1-12      107
    12        7
    1=        3
   122       37

In decimal, the sum of these numbers is 4890.

As you go to input this number on Bob's console, you discover that some buttons you expected are missing. Instead, you
are met with buttons labeled =, -, 0, 1, and 2. Bob needs the input value expressed as a SNAFU number, not in decimal.

Reversing the process, you can determine that for the decimal number 4890, the SNAFU number you need to supply to Bob's
console is 2=-1=0.

The Elves are starting to get cold. What SNAFU number do you supply to Bob's console?

--- Part Two ---

The hot air balloons quickly carry you to the North Pole. As soon as you land, most of the expedition is escorted
directly to a small building attached to the reindeer stables.

The head smoothie chef has just finished warming up the industrial-grade smoothie blender as you arrive. It will take 50
stars to fill the blender. The expedition Elves turn their attention to you, and you begin emptying the fruit from your
pack onto the table.

As you do, a very young Elf - one you recognize from the expedition team - approaches the table and holds up a single
star fruit he found. The head smoothie chef places it in the blender.

Only 49 stars to go.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.