Range-v3's zip function works with temporaries coming from other Range-v3's functions but not with others
(This is kind of a follow up to this other question.)
Original question
The following code works just fine
#include <boost/range/adaptor/transformed.hpp>
#include <cmath>
#include <range/v3/view/zip.hpp>
#include <string>
#include <vector>
int main() {
auto vec1 = std::vector<int>{1,2,3};
auto vec2 = std::vector<std::string>{"uno","due","tre"};
auto sqrt = [](auto x){ return std::sqrt(x); };
auto vec3 = vec1 | boost::adaptors::transformed(sqrt);
for (auto const& i : ranges::views::zip(vec1, vec2, vec3)) {
// whatever
}
}
but what if I want to avoid storing the result in vec3
? Ok, without | to_vector
vec3
is just a view (right?), so storing it is not a big memory usage concern, but bear with me. Chaging the for
line to the following does not work
for (auto const& i : ranges::views::zip(vec1, vec2, vec1 | boost::adaptors::transformed(sqrt))) {
The answer from a comment
Based on a comment, I just didn't think much about the problem before posting the question, as the solution as simple as using ranges::views::transform
instead of boost::adaptors::transformed
.
I'd still like to understand what was going on
At this point, however, I'm honestly still interested in understanding what's wrong with the former solution.
I initially I thought that ranges::views::zip
couldn't work with temporaries, but the solution above (in italic) proves me wrong, as vec1 | ranges::views::transform(sqrt)
is still a temporary, not an lvalue.
On the other hand, it's also true that ranges::views::zip(vec1, vec2, std::move(vec3))
fails, where std::move(vec3)
is also not an lvalue, but an xvalue.
It'd be good if someone could help me understand the peculiarities of ranges::views::zip
and why it works with some temporaries (I'd say those coming from other Range-v3 functions) but not others (e.g. xvalues coming std::move
or a true temporary coming from boost::...
).
See also questions close to this topic
-
How to trim last four character from the input in bash shell?
I intend to automate compile and run process in C++, I wrote the following code as
compile-run.sh
#! /bin/bash clang++ $1.cpp -o $1.out && ./$1.out
I put this compile-run.sh in /usr/local/bin for global usage, and when I type the command
compile-run.sh XXX.cpp
, it intend to compile and run the specified cpp file. But the problem now is I have to manually removed ".cpp
" in the command.Is there any way to trim the last X number of character and assign to a variable in general?
Is there any way to trim the.cpp
and apply trimmed $1 in the code?
Is there better way to automate compile and run process? -
c++ segmentation fault and Trace/breakpoint trap when using Dynamic memory allocation
I am practicing Dynamic memory allocation in C++. I wanna enter some word which length is less than 10, and when I enter "-1", it will print the word I have entered before.
But when I enter more than three words, it will give me an Trace/breakpoint trap or segmentation fault. I use gdb-peda to check my code, it said "double free detected in tcache 2", I think the problem is the "delete" part in my code, but I dont know how to correct it.
this is my code:
#include <iostream> #include <limits> using namespace std; int counter = 0; //be used to count how many times we have entered char **ins(); int main() { auto dict = ins(); //Total list for ( int i = 0; i < counter; i++ ) { for ( int j = 0; j < 10; j++ ) { if ( *( *( dict + i ) + j ) == '\0' ) //if the word is null,print the word and go to next word break; cout << *( *( dict + i ) + j ); } cout << endl; } for ( int i = 0; i < counter; i++ ) delete[] dict[i]; //delete the total list system( "pause" ); return 0; } char **ins() { auto dict = new char *[1](); //total list auto cpdict = new char *[1](); //copy list while ( 1 ) { auto word = new char[10](); //a list be used to store the entered word (length<10) cout << "input word: "; cin.get( word, 10, '\n' ); //get the entered word in the list if ( word[0] == '-' && word[1] == '1' ) { //if enter "-1" , delete the copy list and return the total list delete[] cpdict; return dict; } counter++; //plus one of the times of entering delete[] dict; //delete the old total list auto dict = new char *[counter](); //create a new total list, the lenth is one more than the old total list for ( int i = 0; i < counter - 1; i++ ) *( dict + i ) = *( cpdict + i ); //copy the stuffs in old copy list to new total list *( dict + counter - 1 ) = word; //copy the word we just enter into total list delete[] cpdict; //delter the old copy list auto cpdict = new char *[counter](); //create a new copy list for ( int i = 0; i < counter; i++ ) *( cpdict + i ) = *( dict + i ); //copy the stuffs in new total list to new copy list cin.clear(); cin.ignore( numeric_limits<std::streamsize>::max(), '\n' ); } }
My imagine input and output is like:
input word: aaa input word: bbb input word: ccc input word: ddd input word: -1
output:
aaa bbb ccc ddd
-
Qt Linux to Windows transition: Error in macro substitution
I have a Qt project (Version 5.14.2), which is building just fine under Linux. Now I would like to provide it on Windows as well. However, I have some trouble getting it built. The following error is thrown:
Error: Cannot find = after : in macro substitution.
And then a line in the makefile. When I go to the line there is this command:
443 {C:\Users\Alex\Documents\GitHub\control-station\src\aircraft}.cpp{obj\}.obj:: 444 $(CXX) -c $(CXXFLAGS) $(INCPATH) -Foobj\ @<< 445 $< 446 <<
I have no prior experience with windows, so this error leaves me clueless. There is another error following:
Kit Desktop Qt 5.14.2 MSVC2017 64bit has configuration problems.
It looks like this is consecutive of the one prior, but I am not sure. Do you have any suggestions what to check? It seems to be a macro error, but I don't know where to start looking?
-
What is the difference between a higher-order function and a class?
I was going through the basics of functional programming, and eventually came accross the concept of higher-order functions. I saw an example in this video by Corey Schafer (starts at 11:00), which shows a Python function that can wrap messages in arbitrary HTML tags:
def html_tag(tag): def wrap_text(msg): print('<{0}>{1}</{0}>'.format(tag, msg)) return wrap_text print_h1 = html_tag('h1') print_h1('Test Headline!') print_h1('Another Headline!') print_p = html_tag('p') print_p('Test Paragraph!')
Output:
<h1>Test Headline!</h1> <h1>Another Headline!</h1> <p>Test Paragraph!</p>
I get that it gives you the flexibility of re-using the same function for different purposes (different tags, in this example). But you could achieve the same result using Python classes, too:
class HTML_tag: def __init__(self, tag): self.tag = tag def wrap_text(self, msg): print('<{0}>{1}</{0}>'.format(self.tag, msg)) print_h1 = HTML_tag('h1') print_h1.wrap_text('Test Headline!') print_h1.wrap_text('Another Headline!') print_p = HTML_tag('p') print_p.wrap_text('Test Paragraph!')
Output:
<h1>Test Headline!</h1> <h1>Another Headline!</h1> <p>Test Paragraph!</p>
The higher-order function approach definitely looks cleaner, but apart from the aesthetics, are there any other reasons I might want to prefer a higher-order function over a class? E.g., regarding aspects like
- Performance
- Memory
- ...
-
Scala function body definition help wanted
I'm trying making a scala dsl with this syntax:
val a = Agent() setup { agent => // agent reference. agent add "Hello World!" } a add "Not allowed" // Atm this is allowed.
where I can call method add outside the setup function body and to call add method I have to write
agent =>
at the beginning of setup function body.What I've done atm is a trait Agent:
trait Agent { def setup(f: Agent => Unit): Agent def add(s: String): Agent } case class AgentImpl(strings: Seq[String]) extends Agent { override def setup(f: Agent => Unit): Agent = { f(this) this } override def add(s: String): Agent = copy(strings = strings:+s) } object Agent { def apply(): Agent = AgentImpl(Seq.empty) }
What I have to do is this:
val a = Agent() setup { // No more references to agent add "Hello World!" } a add "Not allowed" // This mustn't be allowed. Compilation error.
where I haven't a reference to agent with
agent =>
at the start of setup function body and if I try to do an add outside the setup function body I get an error.Is this possible in Scala?
I can change every part of the code, add any number of traits/classes/objects and other things but not change the syntax of my DSL.
-
How can I modify std::adjacent_difference to only give the diffs?
The documentation for
std::adjacent_difference
says that the first element written to the output is the first element of the input, unchanged. For my use case, I want to remove this first element. My question is, what is the most readable way to do this that is also maximally efficient?For example, given
[1, 3, 7]
,std::adjacent_difference
will give[1, 2, 4]
but that first element isn't actually a difference, it is just the first 1 we already had.Currently, I have copied the reference implementation and modified it to not write the first element, and to perform the write in the loop before incrementing the output iterator instead of after:
template<class InputIt, class OutputIt> constexpr OutputIt adjacent_difference(InputIt first, InputIt last, OutputIt d_first) { if (first == last) return d_first; typedef typename std::iterator_traits<InputIt>::value_type value_t; value_t acc = *first; while (++first != last) { value_t val = *first; *d_first++ = val - std::move(acc); // <-- previously *++d_first = ... acc = std::move(val); } return d_first; }
This works, but of course isn't very satisfying since it copies over code from an existing algorithm. Is it possible to make an inserter that ignores the first write and increment? What performance cost would that incur?
-
Is the dynamic initialization of the non-local variable thread-safe
I have following code in one of the source file of my application:
// file1.cpp #include <memory> static auto global_variable = std::make_unique<int>(123); int get_global_variable() { return *global_variable; }
Let assume that my application has some threads which call the
get_global_variable
. Is the initialization of theglobal_variable
thread-safe?As far as I know, the
global_variable
is dynamically initialized. I also know that the initialization of static local variables is thread-safe since C++11. So, I wonder to know if that exception proves the rule that the other types of variables are not thread-safe initialized or it is also thread-safe and does not produce data races.I've found this answer, but after reading, I'm more confused because the answerer suggested using such pattern:
const T& f() { static T t(a,b,c); return t; }
which supposedly guarantees the thread-safe initialization.
I also found this answer. It states that all globals are initialized before main, so there is only one thread (Peter rightly pointed out that it is not true - or not every time). However, what if my piece of code is a shared library loaded by
dlopen
function to a program where there is more than one thread? -
Compiling Kevlin Henney's Fizzbuzz with the use of lambdas in C++17 using Visual Studio 2017's compiler
I was following Kevlin Henney's Youtube video on Lambdas in programming. At about 20:30 - 20:40 in his video he gives this code snippet:
string fizzbuzz(int n) { auto fizz = [=](function<string(string)> f) { return n % 3 == 0 ? [=](auto) {return "Fizz" + f("");} : f; }; auto buzz = [=](function<string(string)> f) { return n % 5 == 0 ? [=](auto) {return "Buzz" + f("");} : f; }; auto id = [](auto s) { return s; }; return fizz(buzz(id))(to_string(n)); }
Here is my actual code within my IDE:
#include <functional> #include <iostream> #include <string> std::string fizzbuzz(int n) { auto fizz = [=](std::function<std::string(std::string)> f) { return n % 3 == 0 ? [=](auto) { return "Fizz" + f(""); } : f; }; auto buzz = [=](std::function<std::string(std::string)> f) { return n % 5 == 0 ? [=](auto) { return "Buzz" + f(""); } : f; }; auto id = [](auto s) { return s; }; return fizz(buzz(id))(std::to_string(n)); } int main() { for (int i = 1; i <= 100; i++) std::cout << fizzbuzz(i) << '\n'; return 0; }
However, when I try to compile this Visual Studio is generating these compiler errors:
1>------ Build started: Project: Data Structure Samples, Configuration: Debug x64 ------ 1>main.cpp 1>c:\...\main.cpp(62): error C2445: result type of conditional expression is ambiguous: types 'fizzbuzz::<lambda_9027e592dd51e6f4c5342b61ff8c23f0>::()::<lambda_2463463a8046fa170a40e78d59e9f461>' and 'std::function<std::string (std::string)>' can be converted to multiple common types 1>c:\...\main.cpp(62): note: could be 'fizzbuzz::<lambda_9027e592dd51e6f4c5342b61ff8c23f0>::()::<lambda_2463463a8046fa170a40e78d59e9f461>' 1>c:\...\main.cpp(62): note: or 'std::function<std::string (std::string)>' 1>c:\...\main.cpp(65): error C2445: result type of conditional expression is ambiguous: types 'fizzbuzz::<lambda_c18a2fee5ba13240be9b86f815911a7c>::()::<lambda_2774da13f447e3dfb583778d4ea6d5bd>' and 'std::function<std::string (std::string)>' can be converted to multiple common types 1>c:\...\main.cpp(65): note: could be 'fizzbuzz::<lambda_c18a2fee5ba13240be9b86f815911a7c>::()::<lambda_2774da13f447e3dfb583778d4ea6d5bd>' 1>c:\...\main.cpp(65): note: or 'std::function<std::string (std::string)>' 1>c:\...\main.cpp(68): error C2664: 'void fizzbuzz::<lambda_9027e592dd51e6f4c5342b61ff8c23f0>::operator ()(std::function<std::string (std::string)>) const': cannot convert argument 1 from 'void' to 'std::function<std::string (std::string)>' 1>c:\...\main.cpp(68): note: Expressions of type void cannot be converted to other types 1>Done building project "Data Structure Samples.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
When I check this against CompilerExplorer found here, This code compiles with all three of the major compilers: GCC, Clang, and MSVC...
I know that C++17 supports both
lambdas
andstd::function<T>
, but is this type of implementation or usage specific to a newer version of the compiler? Meaning is this technique or usage only available with say C++20 and later? If so, what can be done to this code snippet so that it can be compiled under Visual Studio 2017 using C++17 that will provide the same semantics and behavior?
Edit
Here are all of my Compiler's Command-Line Settings in regards to the C/C++ Language section:
/JMC /permissive- /GS /W3 /Zc:wchar_t /Qspectre /ZI /Gm- /Od /sdl /Fd"x64\Debug\vc141.pdb" /Zc:inline /fp:precise /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /MDd /std:c++latest /FC /Fa"x64\Debug\" /EHsc /nologo /Fo"x64\Debug\" /Fp"x64\Debug\Data Structure Samples.pch" /diagnostics:classic
-
Explicit template instantiation using typedef
I am trying to explicitly instantiate a class with multiple different parameters.
// This is the class I want to explicitly instantiate template <typename arg1, typename arg2> class Foo{}; // This a helper meta-function to compute the template parameters for the above class template <typename helper1, typename helper2> class instantiation_helper{ using arg1 = helper1; // actually some_constexpr_function(helper1, helper2) using arg2 = helper2; // actually some_constexpr_function(helper1 , helper2) };
One trivial solution is verbose:
using helper0 = instantiation_helper<int, int>; template class Foo<helper0::arg1, helper0::arg2>; using helper1 = instantiation_helper<float, int>; template class Foo<helper1::arg1, helper1::arg2>; using helper2 = instantiation_helper<int, float>; template class Foo<helper2::arg1, helper2::arg2>; using helper3 = instantiation_helper<float, float>; template class Foo<helper3::arg1, helper3::arg2>;
So I am storing the type of the Foo class in the helper meta-function itself and then instantiating using that:
template <typename helper1, typename helper2> class instantiation_helper{ using arg1 = helper1; // actually some_constexpr_function(helper1, helper2) using arg2 = helper2; // actually some_constexpr_function(helper1, helper2) using Foo_type = Foo<arg1, arg2>; }; template instantiation_helper<int, int>::Foo_type; template instantiation_helper<int, float>::Foo_type; template instantiation_helper<float, int>::Foo_type; template instantiation_helper<float, float>::Foo_type;
But this errors out with:
prog.cpp:13:50: error: expected unqualified-id before ‘;’ token template instantiation_helper<int, int>::Foo_type;
I guess this is because Foo_type does not qualify as simple-template-id (using typedef in template instantiation and extern template declaration).
So I am trying to instead store the template arguments as a tuple and then expand them later when explicitly instantiating:
template <typename helper1, typename helper2> class instantiation_helper{ using arg1 = helper1; // actually some_constexpr_function(helper1, helper2) using arg2 = helper2; // actually some_constexpr_function(helper1, helper2) using Foo_template_params = std::tuple<arg1, arg2>; }; using arg_list1 = instantiation_helper<int, int>::Foo_template_params; template class Foo<std::tuple_element<0, arg_list1>::type, std::tuple_element<1, arg_list1>::type>; using arg_list2 = instantiation_helper<float, int>::Foo_template_params; template class Foo<std::tuple_element<0, arg_list2>::type, std::tuple_element<1, arg_list2>::type>; using arg_list3 = instantiation_helper<int, float>::Foo_template_params; template class Foo<std::tuple_element<0, arg_list3>::type, std::tuple_element<1, arg_list3>::type>; using arg_list4 = instantiation_helper<float, float>::Foo_template_params; template class Foo<std::tuple_element<0, arg_list4>::type, std::tuple_element<1, arg_list4>::type>;
This obviously again is verbose and I am not even sure if tuple is the right way of doing this.
So my question is:
- How would one go about achieving this?
- What if Foo had a third variadic template parameter like
template <typename arg1, typename arg2, typename ...arg3> class Foo{};
-
Validity and/or lifetime extension of mem-initializer in aggregate initialization
CWG 1815 asked (with minor edits):
struct A {}; struct B { A&& a = A{}; }; B b1; // #1 B b2{A{}}; // #2 B b3{}; // #3
[...]
#2
is aggregate initialization, which bindsB::a
to the temporary in the initializer forb2
and thus extends its lifetime to that ofb2
.#3
is aggregate initialization, but it is not clear whether the lifetime of the temporary in the non-static data member initializer forB::a
should be lifetime-extended like#2
or not, like#1
.Per the Notes on that issue, at Issaquah (2014-02) CWG intended to make
#3
behave like#2
; that is, well-formed, and performing lifetime extension of the temporary to whichb3.a
binds. But at the next ISO meeting (Rapperswil, 2014-06) the resolution to CWG 1696 was adopted, ostensibly resolving CWG 1815 but adopting language that appears to make#3
ill-formed:11 - A temporary expression bound to a reference member from a default member initializer is ill-formed.
However, the example immediately under that clause does not consider aggregate initialization (as in CWG 1815) but only initialization by constructor; specifically, a default constructor defined as defaulted:
struct A { A() = default; // OK A(int v) : v(v) { } // OK const int& v = 42; // OK }; A a1; // error: ill-formed binding of temporary to reference A a2(1); // OK, unfortunately
So although the wording seems clear, it would also seem contrary to the intent of the Committee, which could be reason to consider the wording defective.
In terms of implementation practice, we can see that there is considerable variance:
gcc clang MSVC ICC #1
❌ destroy ✅ reject ☠️ leak ❌ destroy #2
✅ extend ✅ extend ✅ extend ✅ extend #3
❌ extend ❌ extend ❌ extend ❌ destroy (Here, "destroy" means the temporary is destructed at the end of the declaration i.e. not lifetime-extended. ✅ indicates conformance, ❌ non-conformance, ☠️ a clear defect.) However, other than ICC, the compilers agree on extending lifetime in
#3
, contrary to the current wording. Oddly, despite performing lifetime extension, Clang warns that it is unable to do so, indicating that the developers consider lifetime extension to be required by the Standard in this case:warning: sorry, lifetime extension of temporary created by aggregate initialization using default member initializer is not supported; lifetime of temporary will end at the end of the full-expression [-Wdangling]
Question
Given the expressed intent of CWG, and implementation variance, is it reasonable to consider the current wording as defective and to rely on lifetime extension occurring in
#3
? Are the Committee aware of this discrepancy and is there prospect of it being resolved in the near or medium term (as a DR to C++20, say)? -
Are the addresses of two temporaries guaranteed to be different in the same expression?
Consider the following program:
#include <iostream> int const * f(int const &i) { return &i; } int main() { std::cout << f(42); // #1 std::cout << f(42); // #2 std::cout << f(42) << f(42); // #3 }
Depending on the compiler, and optimization level that is set, the addresses printed on lines
#1
and#2
may or may not be different from one another.However, regardless of choice of compiler, or optimization levels, the 2 addresses printed on line
#3
are always different from one another.Here's a demo to play around with.
So what are the rules for what
f
returns in each of these cases? -
gcc warning about unitialized values caused by turning optimization on
Consider the following code
#include <iostream> template<typename Value> struct Wrapper { Value m_value; Wrapper() {} Wrapper(const Wrapper<Value> ©_from) : m_value(copy_from.m_value) {} }; template<typename Value> struct DefaultContainer { Value m_default; DefaultContainer(const Value& def) : m_default(def) {} }; template<typename Value> struct DefaultContainerUser : public DefaultContainer<Value> { DefaultContainerUser() : DefaultContainer<Value>(Value()) {} }; int main() { DefaultContainerUser<Wrapper<double>> user; std::cout << user.m_default.m_value << std::endl; }
When I compile this with
c++ -O1 -Werror -Wall test.cpp
, I get the following error:test.cpp: In function ‘int main()’: test.cpp:8:63: error: ‘<anonymous>.Wrapper<double>::m_value’ is used uninitialized in this function [-Werror=uninitialized] 8 | Wrapper(const Wrapper<Value> ©_from) : m_value(copy_from.m_value) {} | ~~~~~~~~~~^~~~~~~ cc1plus: all warnings being treated as errors
If I disable optimizations using
-O0
, everything works fine. Adding-Wno-error=maybe-uninitialized
with optimizations still turned on doesn't help. What am I doing wrong here?The compiler that I'm using is
c++ (GCC) 10.2.1 20201016 (Red Hat 10.2.1-6)
. -
Automatically unpack a tuple in a function call in C++
I am using range-v3 and sometimes I used
ranges::views::enumerate
to have the id of the value that I'm iterating on.enumerate
view returns a tuple containing the id and the value, so I would like to know if its possible to unpack directly that tuple. This would be an example:samplers | ranges::views::enumerate | ranges::views::transform([](const auto samplerId, const auto &jSampler){...} | ranges::to_vector;
-
Month of day with sequence in one for loop or range-v3 lib
I try to take month of day with sequence like this: for january it will print 1 with 31 time, in february will print 2 with 28 time etc.
std::vector<int> list = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int count = 0; for(int k = 0; k < 12; k++){ for(int i = 0; i < list[k]; i++) cout << count + 1; count++; }
list keep the month's total days.
I can do with this for loops but I want to do in 1 loop or range-v3 lib. In range-v3 lib I try to use accumulate function but I cannot do.
Any idea?
-
Programming paradigms c++ range-v3 library question
I need help about 1 question. I need to use just range-v3 library to write this code and i couldn't solve it.
You can see all rules below. Please help me to solve this.
I cannot use any include, "if","for","for_each","while",mutable lambda. I have no idea how to solve it.Is there anyone who can write the answer?
#include <iostream> #include <vector> #include <array> #include <string> #include <tuple> // printer for a tuple of 4 int dimensions. you will need this in Q4 for easily sending tuples to the console. // this must be defined before including range lib here to make it compatible with clang. std::ostream& operator<<(std::ostream& str, const std::tuple<int, int, int, int>& tpl) { auto [v1, v2, v3, v4] = tpl; str << " d" << v1 << "w" << v2 << "=" << v3 << "/" << v4; return str; } // YOU CANNOT CHANGE THE GIVEN CODE TEMPLATE. USE ONLY THE LOCATIONS UNDER THE QUESTION REGIONS. // YOU CANNOT USE "if" statement. ranges::find_if and ranges::find_if_not are allowed. // YOU CANNOT USE "for" statement. // YOU CANNOT USE "for_each" statement of range library. // YOU CANNOT USE "while" or "do-while" statement. // YOU CANNOT USE A MUTABLE LAMBDA (you can use non-mutable lambdas as many times as you want). // YOU CANNOT INSTANTIATE vector<T> or array<T, sz> yourself. You can use "to<vector<T>>" of range library. // i.e. auto v = vector<int>{...} is forbidden. // i.e. auto a = array<int, 10>{...} is forbidden. // YOU CANNOT ADD new "#include" directives. // YOU CANNOT ADD new "class" or "struct" declarations/definitions. // USE ONLY range-v3 library and allowed C++ facilities. cout << "Q4_full) range of (Day, Week, DayOfMonth, Month) tuples:" << endl; //CODE HERE //OUTPUT SHOULD BE LIKE THIS: Q4_full) range of (Day, Week, DayOfMonth, Month) tuples: [[ d1w1=1/1, d2w1=2/1, d3w1=3/1, d4w1=4/1, d5w1=5/1],[ d6w2=6/1, d7w2=7/1, d8w2=8/1, d9w2=9/1, d10w2=10/1, d11w2=11/1, d12w2=12/1],[ d13w3=13/1, d14w3=14/1, d15w3=15/1, d16w3=16/1, d17w3=17/1, d18w3=18/1, d19w3=19/1],[ d20w4=20/1, d21w4=21/1, d22w4=22/1, d23w4=23/1, d24w4=24/1, d25w4=25/1, d26w4=26/1],[ d27w5=27/1, d28w5=28/1, d29w5=29/1, d30w5=30/1, d31w5=31/1],[ d32w5=1/2, d33w5=2/2],[ d34w6=3/2, d35w6=4/2, d36w6=5/2, d37w6=6/2, d38w6=7/2, d39w6=8/2, d40w6=9/2],[ d41w7=10/2, d42w7=11/2, d43w7=12/2, d44w7=13/2, d45w7=14/2, d46w7=15/2, d47w7=16/2],[ d48w8=17/2, d49w8=18/2, d50w8=19/2, d51w8=20/2, d52w8=21/2, d53w8=22/2, d54w8=23/2],[ d55w9=24/2, d56w9=25/2, d57w9=26/2, d58w9=27/2, d59w9=28/2, d60w9=29/2],[ d61w9=1/3],[ d62w10=2/3, d63w10=3/3, d64w10=4/3, d65w10=5/3, d66w10=6/3, d67w10=7/3, d68w10=8/3],[ d69w11=9/3, d70w11=10/3, d71w11=11/3, d72w11=12/3, d73w11=13/3, d74w11=14/3, d75w11=15/3],[ d76w12=16/3, d77w12=17/3, d78w12=18/3, d79w12=19/3, d80w12=20/3, d81w12=21/3, d82w12=22/3],[ d83w13=23/3, d84w13=24/3, d85w13=25/3, d86w13=26/3, d87w13=27/3, d88w13=28/3, d89w13=29/3],[ d90w14=30/3, d91w14=31/3],[ d92w14=1/4, d93w14=2/4, d94w14=3/4, d95w14=4/4, d96w14=5/4],[ d97w15=6/4, d98w15=7/4, d99w15=8/4, d100w15=9/4, d101w15=10/4, d102w15=11/4, d103w15=12/4],[ d104w16=13/4, d105w16=14/4, d106w16=15/4, d107w16=16/4, d108w16=17/4, d109w16=18/4, d110w16=19/4],[ d111w17=20/4, d112w17=21/4, d113w17=22/4, d114w17=23/4, d115w17=24/4, d116w17=25/4, d117w17=26/4],[ d118w18=27/4, d119w18=28/4, d120w18=29/4, d121w18=30/4],[ d122w18=1/5, d123w18=2/5, d124w18=3/5],[ d125w19=4/5, d126w19=5/5, d127w19=6/5, d128w19=7/5, d129w19=8/5, d130w19=9/5, d131w19=10/5],[ d132w20=11/5, d133w20=12/5, d134w20=13/5, d135w20=14/5, d136w20=15/5, d137w20=16/5, d138w20=17/5],[ d139w21=18/5, d140w21=19/5, d141w21=20/5, d142w21=21/5, d143w21=22/5, d144w21=23/5, d145w21=24/5],[ d146w22=25/5, d147w22=26/5, d148w22=27/5, d149w22=28/5, d150w22=29/5, d151w22=30/5, d152w22=31/5],[ d153w23=1/6, d154w23=2/6, d155w23=3/6, d156w23=4/6, d157w23=5/6, d158w23=6/6, d159w23=7/6],[ d160w24=8/6, d161w24=9/6, d162w24=10/6, d163w24=11/6, d164w24=12/6, d165w24=13/6, d166w24=14/6],[ d167w25=15/6, d168w25=16/6, d169w25=17/6, d170w25=18/6, d171w25=19/6, d172w25=20/6, d173w25=21/6],[ d174w26=22/6, d175w26=23/6, d176w26=24/6, d177w26=25/6, d178w26=26/6, d179w26=27/6, d180w26=28/6],[ d181w27=29/6, d182w27=30/6],[ d183w27=1/7, d184w27=2/7, d185w27=3/7, d186w27=4/7, d187w27=5/7],[ d188w28=6/7, d189w28=7/7, d190w28=8/7, d191w28=9/7, d192w28=10/7, d193w28=11/7, d194w28=12/7],[ d195w29=13/7, d196w29=14/7, d197w29=15/7, d198w29=16/7, d199w29=17/7, d200w29=18/7, d201w29=19/7],[ d202w30=20/7, d203w30=21/7, d204w30=22/7, d205w30=23/7, d206w30=24/7, d207w30=25/7, d208w30=26/7],[ d209w31=27/7, d210w31=28/7, d211w31=29/7, d212w31=30/7, d213w31=31/7],[ d214w31=1/8, d215w31=2/8],[ d216w32=3/8, d217w32=4/8, d218w32=5/8, d219w32=6/8, d220w32=7/8, d221w32=8/8, d222w32=9/8],[ d223w33=10/8, d224w33=11/8, d225w33=12/8, d226w33=13/8, d227w33=14/8, d228w33=15/8, d229w33=16/8],[ d230w34=17/8, d231w34=18/8, d232w34=19/8, d233w34=20/8, d234w34=21/8, d235w34=22/8, d236w34=23/8],[ d237w35=24/8, d238w35=25/8, d239w35=26/8, d240w35=27/8, d241w35=28/8, d242w35=29/8, d243w35=30/8],[ d244w36=31/8],[ d245w36=1/9, d246w36=2/9, d247w36=3/9, d248w36=4/9, d249w36=5/9, d250w36=6/9],[ d251w37=7/9, d252w37=8/9, d253w37=9/9, d254w37=10/9, d255w37=11/9, d256w37=12/9, d257w37=13/9],[ d258w38=14/9, d259w38=15/9, d260w38=16/9, d261w38=17/9, d262w38=18/9, d263w38=19/9, d264w38=20/9],[ d265w39=21/9, d266w39=22/9, d267w39=23/9, d268w39=24/9, d269w39=25/9, d270w39=26/9, d271w39=27/9],[ d272w40=28/9, d273w40=29/9, d274w40=30/9],[ d275w40=1/10, d276w40=2/10, d277w40=3/10, d278w40=4/10],[ d279w41=5/10, d280w41=6/10, d281w41=7/10, d282w41=8/10, d283w41=9/10, d284w41=10/10, d285w41=11/10],[ d286w42=12/10, d287w42=13/10, d288w42=14/10, d289w42=15/10, d290w42=16/10, d291w42=17/10, d292w42=18/10],[ d293w43=19/10, d294w43=20/10, d295w43=21/10, d296w43=22/10, d297w43=23/10, d298w43=24/10, d299w43=25/10],[ d300w44=26/10, d301w44=27/10, d302w44=28/10, d303w44=29/10, d304w44=30/10, d305w44=31/10],[ d306w44=1/11],[ d307w45=2/11, d308w45=3/11, d309w45=4/11, d310w45=5/11, d311w45=6/11, d312w45=7/11, d313w45=8/11],[ d314w46=9/11, d315w46=10/11, d316w46=11/11, d317w46=12/11, d318w46=13/11, d319w46=14/11, d320w46=15/11],[ d321w47=16/11, d322w47=17/11, d323w47=18/11, d324w47=19/11, d325w47=20/11, d326w47=21/11, d327w47=22/11],[ d328w48=23/11, d329w48=24/11, d330w48=25/11, d331w48=26/11, d332w48=27/11, d333w48=28/11, d334w48=29/11],[ d335w49=30/11],[ d336w49=1/12, d337w49=2/12, d338w49=3/12, d339w49=4/12, d340w49=5/12, d341w49=6/12],[ d342w50=7/12, d343w50=8/12, d344w50=9/12, d345w50=10/12, d346w50=11/12, d347w50=12/12, d348w50=13/12],[ d349w51=14/12, d350w51=15/12, d351w51=16/12, d352w51=17/12, d353w51=18/12, d354w51=19/12, d355w51=20/12],[ d356w52=21/12, d357w52=22/12, d358w52=23/12, d359w52=24/12, d360w52=25/12, d361w52=26/12, d362w52=27/12],[ d363w53=28/12, d364w53=29/12, d365w53=30/12, d366w53=31/12]]