Unable to load image

rDramaAdvent of Code Day 4: Back on Track Edition

Summary for those just joining us:

Advent of Code is an annual Christmas themed coding challenge that runs from December 1st until christmas. Each day the coding problems get progressively harder. We have a leaderboard and pretty good turnout, so feel free to hop in at any time and show your stuff!

Whether you have a single line monstrosity or a beautiful phone book sized stack of OOP code, you can export it in a nice little image for sharing at https://carbon.vercel.app

What did you think about today's problem?

https://adventofcode.com/2023

Our Code is 2416137-393b284c (No need to share your profile, you have the option to join anonymously if you don't want us to see your github)

21
Jump in the discussion.

No email address required.

https://i.rdrama.net/images/17016793012168365.webp

Tried to use the new std::views std library which is kinda useful, but gives absolutely unhelpful error messages:

<g>\>[build] FAILED: day04/CMakeFiles/day04.dir/main.cpp.o </g>
[build] /usr/bin/ccache /usr/bin/clang++-17 -DINPUT_DIR=\"/home/ihsoy/adventofcode/inputs/\" -DSCN_HEADER_ONLY=0 -I/home/ihsoy/adventofcode/.cache/CPM/scn/ee384e4dfeb40efb93d1b2a397a81e8027027f77/include -stdlib=libc++ -g -std=c++23 -fcolor-diagnostics -MD -MT day04/CMakeFiles/day04.dir/main.cpp.o -MF day04/CMakeFiles/day04.dir/main.cpp.o.d -o day04/CMakeFiles/day04.dir/main.cpp.o -c /home/ihsoy/adventofcode/day04/main.cpp
[build] /home/ihsoy/adventofcode/day04/main.cpp:53:95: error: invalid operands to binary expression ('std::__1::ranges::transform_view<std::__1::ranges::filter_view<std::__1::ranges::split_view<std::__1::ranges::subrange<const char *>, std::__1::ranges::single_view<char>>, (lambda at /home/ihsoy/adventofcode/day04/main.cpp:42:89)>, (lambda at /home/ihsoy/adventofcode/day04/main.cpp:44:50)>' and 'int')
[build]    53 |         auto numbers_won = numbers_played | std::views::filter([](https://auto number) { return number%2==0; });
[build]       |                                                                                         ~~~~~~^~
[build] /usr/lib/llvm-17/bin/../include/c++/v1/__type_traits/invoke.h:337:10: note: in instantiation of function template specialization 'day03::solution(const std::vector<std::string> &)::(anonymous class)::operator()<std::__1::ranges::transform_view<std::__1::ranges::filter_view<std::__1::ranges::split_view<std::__1::ranges::subrange<const char *>, std::__1::ranges::single_view<char>>, (lambda at /home/ihsoy/adventofcode/day04/main.cpp:42:89)>, (lambda at /home/ihsoy/adventofcode/day04/main.cpp:44:50)>>' requested here
[build]   337 | decltype(std::declval<_Fp>()(std::declval<_Args>()...))
[build]       |          ^
[build] /usr/lib/llvm-17/bin/../include/c++/v1/__type_traits/invoke.h:347:19: note: while substituting deduced template arguments into function template '__invoke' [with _Fp = (lambda at /home/ihsoy/adventofcode/day04/main.cpp:53:64) &, _Args = <std::__1::ranges::transform_view<std::__1::ranges::filter_view<std::__1::ranges::split_view<std::__1::ranges::subrange<const char *>, std::__1::ranges::single_view<char>>, (lambda at /home/ihsoy/adventofcode/day04/main.cpp:42:89)>, (lambda at /home/ihsoy/adventofcode/day04/main.cpp:44:50)> &>]
[build]   347 |   static decltype(std::__invoke(std::declval<_XFp>(), std::declval<_XArgs>()...)) __try_call(int);
[build]       |                   ^
[build] /usr/lib/llvm-17/bin/../include/c++/v1/__type_traits/invoke.h:353:28: note: while substituting deduced template arguments into function template '__try_call' [with _XFp = (lambda at /home/ihsoy/adventofcode/day04/main.cpp:53:64) &, _XArgs = (no value)]
[build]   353 |   using _Result = decltype(__try_call<_Fp, _Args...>(0));
[build]       |                            ^
[build] /usr/lib/llvm-17/bin/../include/c++/v1/__type_traits/invoke.h:401:24: note: in instantiation of template class 'std::__invokable_r<void, (lambda at /home/ihsoy/adventofcode/day04/main.cpp:53:64) &, std::__1::ranges::transform_view<std::__1::ranges::filter_view<std::__1::ranges::split_view<std::__1::ranges::subrange<const char *>, std::__1::ranges::single_view<char>>, (lambda at /home/ihsoy/adventofcode/day04/main.cpp:42:89)>, (lambda at /home/ihsoy/adventofcode/day04/main.cpp:44:50)> &>' requested here
[build]   401 |     : public enable_if<__invokable<_Fp, _Args...>::value, typename __invokable_r<void, _Fp, _Args...>::_Result> {};
[build]       |                        ^
[build] /usr/lib/llvm-17/bin/../include/c++/v1/__type_traits/invoke.h:452:45: note: in instantiation of template class 'std::__invoke_of<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:53:64) &, std::__1::ranges::transform_view<std::__1::ranges::filter_view<std::__1::ranges::split_view<std::__1::ranges::subrange<const char *>, std::__1::ranges::single_view<char>>, (lambda at /home/ihsoy/adventofcode/day04/main.cpp:42:89)>, (lambda at /home/ihsoy/adventofcode/day04/main.cpp:44:50)> &>' requested here
[build]   452 | struct _LIBCPP_TEMPLATE_VIS invoke_result : __invoke_of<_Fn, _Args...> {};
[build]       |                                             ^
[build] /usr/lib/llvm-17/bin/../include/c++/v1/__type_traits/invoke.h:455:1: note: (skipping 39 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
[build]   455 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
[build]       | ^
[build] /usr/lib/llvm-17/bin/../include/c++/v1/__concepts/invocable.h:27:21: note: while substituting template arguments into constraint expression here
[build]    27 | concept invocable = requires(_Fn&& __fn, _Args&&... __args) {
[build]       |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]    28 |   _VSTD::invoke(_VSTD::forward<_Fn>(__fn), _VSTD::forward<_Args>(__args)...); // not required to be equality preserving
[build]       |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]    29 | };
[build]       | <del>
[build] /usr/lib/llvm-17/bin/../include/c++/v1/__ranges/range_adaptor.h:61:18: note: while checking the satisfaction of concept 'invocable<std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__filter::__fn, std::tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:53:64)>>>, std::__1::ranges::drop_view<std::__1::ranges::transform_view<std::__1::ranges::split_view<std::string_view, std::__1::ranges::single_view<char>>, std::__range_adaptor_closure_t<std::__compose_t<std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__transform::__fn, std::tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:44:50)>>>, std::__range_adaptor_closure_t<std::__compose_t<std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__filter::__fn, std::tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:42:89)>>>, std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__split_view::__fn, std::tuple<char>>>>>>>>> &>' requested here
[build]    61 |                  invocable<_Closure, _View>
[build]       |                  ^</del>~~~~~~~~~~~~~~~~~~~~~~~
[build] /usr/lib/llvm-17/bin/../include/c++/v1/__ranges/range_adaptor.h:61:18: note: while substituting template arguments into constraint expression here
[build]    61 |                  invocable<_Closure, _View>
[build]       |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /home/ihsoy/adventofcode/day04/main.cpp:53:43: note: while checking constraint satisfaction for template 'operator|<std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__filter::__fn, std::tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:53:64)>>>>' required here
[build]    53 |         auto numbers_won = numbers_played | std::views::filter([](https://auto number) { return number%2==0; });
[build]       |                                           ^
[build] /home/ihsoy/adventofcode/day04/main.cpp:53:43: note: in instantiation of function template specialization 'std::__1::operator|<std::__1::ranges::drop_view<std::__1::ranges::transform_view<std::__1::ranges::split_view<std::string_view, std::__1::ranges::single_view<char>>, std::__range_adaptor_closure_t<std::__compose_t<std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__transform::__fn, std::tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:44:50)>>>, std::__range_adaptor_closure_t<std::__compose_t<std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__filter::__fn, std::tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:42:89)>>>, std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__split_view::__fn, std::tuple<char>>>>>>>>> &, std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__filter::__fn, std::tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:53:64)>>>>' requested here
[build] /home/ihsoy/adventofcode/day04/main.cpp:53:43: error: invalid operands to binary expression ('invoke_result_t<__range_adaptor_closure_t<__bind_back_t<__fn, tuple<int>>>, transform_view<split_view<string_view, single_view<char>>, __range_adaptor_closure_t<__compose_t<__range_adaptor_closure_t<__bind_back_t<__fn, tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:44:50)>>>, __range_adaptor_closure_t<__compose_t<__range_adaptor_closure_t<__bind_back_t<__fn, tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:42:89)>>>, __range_adaptor_closure_t<__bind_back_t<__fn, tuple<char>>>>>>>> &>' (aka 'std::__1::ranges::drop_view<std::__1::ranges::transform_view<std::__1::ranges::split_view<std::string_view, std::__1::ranges::single_view<char>>, std::__range_adaptor_closure_t<std::__compose_t<std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__transform::__fn, std::tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:44:50)>>>, std::__range_adaptor_closure_t<std::__compose_t<std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__filter::__fn, std::tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:42:89)>>>, std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__split_view::__fn, std::tuple<char>>>>>>>>>') and '__range_adaptor_closure_t<__bind_back_t<__fn, tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:53:64)>>>' (aka 'std::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__filter::__fn, std::tuple<(lambda at /home/ihsoy/adventofcode/day04/main.cpp:53:64)>>>'))
``
Jump in the discussion.

No email address required.

>c++

>New library

Brought it on yourself tbh :marseyboo#mer:

Jump in the discussion.

No email address required.

K

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.