Van der Waerden number – on a specific type of sequence

Here is the problem, as given

Let $ R_k$ be the set of increasing sequences $ \{x_1<x_2<\ldots<x_k\}$ of length $ k$ such that there are integers $ a_3, a_4,\ldots,a_k$ (depending on the sequence) such that $ $ x_3=a_3x_2+(1-a3)x_1, \ x_4=a_4x_3+(1-a_4)x_2,\ldots, \ x_k=a_kx_{k-1}+(1-a_k)x_{k-2}$ $ Prove that every $ 2$ colouring of $ [n]$ with $ n \geq 7(k + 1)!/24$ contains a monochromatic member of $ R_k$ .

Notations

We denote $ [n]=\{1,2,\ldots,n\}$

For simplicity, to compare with Van der Wearden numbers $ W(2,k)$ , I’ll call $ P(k)$ the minimum $ n$ such that every $ 2$ colouring of $ [n]$ contains a monochromatic sequence of $ R_k$ .

Comments

We can first notice that the case $ a_i=2$ for all $ i$ induces all artithmetic progressions. Therefore $ P(k)<W(2,k)$ .

We can also rewrite $ R_k$ (I found it easier to read as follow, it might not be the case for everyone). In such a sequence $ x_i$ ‘s, the difference between two consecutive term $ x_i-x_{i-1}$ is a divisor of the difference $ x_i-x_{i-2}$ . All numbers in the sequence can be written in the $ $ x_i=x_1+d\cdot r_i$ $ with some constraints on the $ r_i$ . More precisely $ R_k$ is a set of sequence of the form $ \{x_1,x_2,\ldots,x_k\}$ with :

  • $ x_1$ is the initialisation
  • $ x_2$ defines the difference $ d=x_2-x_1$
  • and then there exist a set of constants $ k_i\geq 1$ such that each $ x_i$ can be written as $ $ x_i = x_{i-1}+d\cdot \prod_{j_3}^{i}k_j$ $

Proof Now working on the actual problem, I think that induction might be a good way to start. Looking then at the base case, $ k=3$ . I need to show that for $ n\geq 7$ , for every colouring $ $ \chi:[n]\rightarrow 2$ $ There exist a monochromatric sequence from $ R_3=\{(x,x+d,x+rd)\mid x\in[n],\ d\geq1, \ r\geq2\}$ . This is easy enough by elimination (I don’t write the details here, but noting that having two consecutive numbers with the same colouring is “bad”, we know that 1,2,3,4 have alternating colors, then 5 must be colored as 2 and 4, 6 must be colored as 1,3, and whatever color for 7 will lead to a monochromatic sequence from $ R_3$ )

Induction This is where I fail. Suppose we have a colouring of $ n’=\frac{7(k+2)!}{24}$ . I think a good way to start is to split $ [n’]$ as follow $ $ \underbrace{[n], \ [n]+n, \ [n]+2n,\ldots, \ [n]+(k+1)n}_{(k+2)\text{ terms}}$ $ With $ =\frac{7(k+1)!}{24}$ . Therefore in each term, I know that there exist a monochromatic sequence from $ R_k$ . I should be able to construct the sequence from $ R_{k+1}$ from theses sequences but I’m not sure to see how.

what the ‘check the type’ mean and why it need to do that?

I was practice this question on a website. it says that ”Add an .add_grade() method to Student that takes a parameter, grade. .add_grade() should verify that grade is of type Grade and if so, add it to the Student‘s .grades

could anyone please explain to me what “check the type” mean? and when I wrote below coding, the question didnt get checked and pop up a line saying "Does .add_grade() add grade to the instance’s .grades list?". I took a look at the answer, it shows code should write like if type(grade) == Grade:. I could not figure out why

class Grade:   minimum_passing = 65     def add_grade(self, grade):     if type(grade) == type(Grade):       self.grades.append(grade) 

enter image description here

Is there a way enforce use of a custom content type for drag&drop and for File/New Folder button?

I created a custom content type called PIN Folder. The content type has 3 attributes – title (required), ms (optional), and comment (optional). In my library I created a default view for PIN Folders which use this content type. As desired, now when I add folders through the File/New Document/PIN Folder button, a folder is created with the PIN Folder attributes.

The problem is that when I drag/drop folders via the Explorer view, or add a folder using the File/New Folder button, the only attribute applied is title. Based on this, my assumption is that drag/drop and New Folder use the standard folder content type rather than my custom content type.

There are going to be numerous picture libraries with hundreds of PIN folders in each library, so drag/drop is the best method for initial creation for the library content.

Is there a way without code to enforce use of my folder custom content type when dragging/dropping or using New Folder? (I do have SP Designer.)

Note: I considered creating a subsite and changing the default folder content type for that subsite. Would that be viable?

proc_macro derive for generatting getters in a struct for each type it contains

This is also on github: https://github.com/theypsilon/getters-by-type-rs

#[proc_macro_derive(GettersByType)] pub fn getters_by_type(input: TokenStream) -> TokenStream {     ImplContext::new(input, "GettersByType", false).transform_ast() }  #[proc_macro_derive(GettersMutByType)] pub fn getters_mut_by_type(input: TokenStream) -> TokenStream {     ImplContext::new(input, "GettersByMutType", true).transform_ast() }  struct ImplContext {     ast: syn::DeriveInput,     derive_name: &'static str,     with_mutability: bool, }  impl ImplContext {     fn new(input: TokenStream, derive_name: &'static str, with_mutability: bool) -> ImplContext {         ImplContext {             ast: syn::parse(input).expect("Could not parse AST."),             derive_name,             with_mutability,         }     }      fn transform_ast(&self) -> TokenStream {         let fields_by_type = match self.ast.data {             syn::Data::Struct(ref class) => self.read_fields(&class.fields),             _ => panic!(                 "The type '{}' is not a struct but tries to derive '{}' which can only be used on structs.",                 self.ast.ident, self.derive_name             ),         };         let mut methods = Vec::<TokenTree>::new();         for (type_pieces, fields_sharing_type) in fields_by_type.into_iter() {             let return_type = MethodReturnType {                 ty: fields_sharing_type.ty,                 name: make_type_name_from_type_pieces(type_pieces),             };             methods.extend(self.make_method_tokens("get_fields", &return_type, false, fields_sharing_type.immutable_fields));             if self.with_mutability {                 methods.extend(self.make_method_tokens("get_mut_fields", &return_type, true, fields_sharing_type.mutable_fields));             }         }         let (ty, generics) = (&self.ast.ident, &self.ast.generics);         let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();         let tokens = quote! {             impl #impl_generics #ty #ty_generics                 #where_clause             {                 #(#methods)                 *             }         };         tokens.into()     }      fn read_fields<'a>(&self, fields: &'a syn::Fields) -> HashMap<Vec<TypePart<'a>>, FieldsSharingType<'a>> {         let mut fields_by_type = HashMap::<Vec<TypePart>, FieldsSharingType>::new();         for field in fields.iter() {             if let Some(ref ident) = field.ident {                 let info = get_info_from_type(&field.ty);                 match make_idents_from_type(&field.ty) {                     Ok(type_pieces) => {                         let fields_by_type = fields_by_type.entry(type_pieces).or_insert_with(|| FieldsSharingType::new(info.ty));                         if info.is_mutable && self.with_mutability {                             fields_by_type.mutable_fields.push(ident);                         }                         fields_by_type.immutable_fields.push(ident);                     }                     Err(err) => {                         eprintln!("[WARNING::{}] Field '{}' of struct '{}' not covered because: {}", self.derive_name, ident, self.ast.ident, err);                     }                 }             }         }         fields_by_type     }      fn make_method_tokens(&self, method_prefix: &str, return_type: &MethodReturnType, mutability: bool, field_idents: Vec<&syn::Ident>) -> proc_macro2::TokenStream {         let count = field_idents.len();         let method_name = syn::Ident::new(&format!("{}_{}", method_prefix, return_type.name), Span::call_site());         let (vis, return_type) = (&self.ast.vis, &return_type.ty);         if mutability {             quote! {                 #vis fn #method_name(&mut self) -> [&mut #return_type; #count] {                     [#(&mut self.#field_idents),*]                 }             }         } else {             quote! {                 #vis fn #method_name(&self) -> [&#return_type; #count] {                     [#(&self.#field_idents),*]                 }             }         }     } }  struct MethodReturnType<'a> {     ty: &'a syn::Type,     name: String, }  struct FieldsSharingType<'a> {     immutable_fields: Vec<&'a syn::Ident>,     mutable_fields: Vec<&'a syn::Ident>,     ty: &'a syn::Type, }  impl<'a> FieldsSharingType<'a> {     fn new(ty: &'a syn::Type) -> FieldsSharingType {         FieldsSharingType {             immutable_fields: vec![],             mutable_fields: vec![],             ty,         }     } }  struct TypeInfo<'a> {     is_mutable: bool,     ty: &'a syn::Type, }  #[derive(Hash, PartialEq, Eq)] enum TypePart<'a> {     Ident(&'a syn::Ident),     Integer(u64),     Separator(&'static str), }  impl<'a> TypePart<'a> {     fn to_string(&self) -> String {         match self {             TypePart::Ident(i) => i.to_string(),             TypePart::Separator(s) => s.to_string(),             TypePart::Integer(i) => i.to_string(),         }     } }  fn get_info_from_type(ty: &syn::Type) -> TypeInfo {     let (ty, is_mutable) = match ty {         syn::Type::Reference(ref reference) => (&*reference.elem, reference.mutability.is_some()),         _ => (ty, true),     };     TypeInfo { is_mutable, ty } }  fn make_idents_from_type<'a>(ty: &'a syn::Type) -> Result<Vec<TypePart<'a>>, &'static str> {     let mut type_pieces = Vec::<TypePart<'a>>::with_capacity(8);     fill_type_pieces_from_type(&mut type_pieces, ty)?;     Ok(type_pieces) }  fn fill_type_pieces_from_type<'a>(type_pieces: &mut Vec<TypePart<'a>>, ty: &'a syn::Type) -> Result<(), &'static str> {     match ty {         syn::Type::Path(ref path) => fill_type_pieces_from_type_path(type_pieces, &path.path),         syn::Type::Reference(ref reference) => fill_type_pieces_from_type(type_pieces, &reference.elem),         syn::Type::BareFn(ref function) => {             type_pieces.push(TypePart::Separator("fn("));             fill_type_pieces_from_array_of_inputs(type_pieces, &function.inputs, ",", |type_pieces, arg| fill_type_pieces_from_type(type_pieces, &arg.ty))?;             type_pieces.push(TypePart::Separator(")"));             fill_type_pieces_from_return_type(type_pieces, &function.output)?;             Ok(())         }         syn::Type::Slice(slice) => {             type_pieces.push(TypePart::Separator("["));             fill_type_pieces_from_type(type_pieces, &slice.elem)?;             type_pieces.push(TypePart::Separator("]"));             Ok(())         }         syn::Type::Array(array) => {             type_pieces.push(TypePart::Separator("["));             fill_type_pieces_from_type(type_pieces, &array.elem)?;             type_pieces.push(TypePart::Separator(";"));             match &array.len {                 syn::Expr::Lit(lit) => match &lit.lit {                     syn::Lit::Int(int) => type_pieces.push(TypePart::Integer(int.value())),                     _ => return Err("syn::Lit::* are not implemented yet."),                 },                 _ => return Err("syn::Expr::* are not implemented yet."),             }             type_pieces.push(TypePart::Separator("]"));             Ok(())         }         syn::Type::Tuple(tuple) => {             type_pieces.push(TypePart::Separator("("));             fill_type_pieces_from_array_of_inputs(type_pieces, &tuple.elems, ",", fill_type_pieces_from_type)?;             type_pieces.push(TypePart::Separator(")"));             Ok(())         }         syn::Type::Paren(paren) => {             type_pieces.push(TypePart::Separator("("));             fill_type_pieces_from_type(type_pieces, &paren.elem)?;             type_pieces.push(TypePart::Separator(")"));             Ok(())         }         syn::Type::Ptr(ptr) => {             type_pieces.push(TypePart::Separator("ptr_"));             if ptr.const_token.is_some() {                 type_pieces.push(TypePart::Separator("const_"));             }             if ptr.mutability.is_some() {                 type_pieces.push(TypePart::Separator("mut_"));             }             fill_type_pieces_from_type(type_pieces, &ptr.elem)?;             Ok(())         }         syn::Type::ImplTrait(_) => Err("syn::Type::ImplTrait can not be implemented."), // ImplTrait is not valid outside of functions and inherent return types, so can't be implemented.         syn::Type::TraitObject(trait_object) => {             if trait_object.dyn_token.is_some() {                 type_pieces.push(TypePart::Separator("dyn_"));             }             fill_type_pieces_from_array_of_inputs(type_pieces, &trait_object.bounds, "+", |type_pieces, bound| match bound {                 syn::TypeParamBound::Trait(trait_bound) => fill_type_pieces_from_type_path(type_pieces, &trait_bound.path),                 syn::TypeParamBound::Lifetime(_) => Ok(()),             })         }         syn::Type::Never(_) => Err("syn::Type::Never is not implemented yet."),         syn::Type::Group(_) => Err("syn::Type::Group is not implemented yet."),         syn::Type::Infer(_) => Err("syn::Type::Infer is not implemented yet."),         syn::Type::Macro(_) => Err("syn::Type::Macro is not implemented yet."),         syn::Type::Verbatim(_) => Err("syn::Type::Verbatim is not implemented yet."),     } }  fn fill_type_pieces_from_type_path<'a>(type_pieces: &mut Vec<TypePart<'a>>, path: &'a syn::Path) -> Result<(), &'static str> {     for segment in path.segments.iter() {         type_pieces.push(TypePart::Ident(&segment.ident));         fill_type_pieces_from_path_arguments(type_pieces, &segment.arguments)?;     }     Ok(()) }  fn fill_type_pieces_from_path_arguments<'a>(type_pieces: &mut Vec<TypePart<'a>>, arguments: &'a syn::PathArguments) -> Result<(), &'static str> {     match arguments {         syn::PathArguments::AngleBracketed(ref angle) => {             type_pieces.push(TypePart::Separator("<"));             fill_type_pieces_from_array_of_inputs(type_pieces, &angle.args, ",", |type_pieces, arg| match arg {                 syn::GenericArgument::Type(ref ty) => fill_type_pieces_from_type(type_pieces, ty),                 syn::GenericArgument::Lifetime(_) => Ok(()),                 syn::GenericArgument::Binding(_) => Ok(()),                 syn::GenericArgument::Constraint(_) => Ok(()),                 syn::GenericArgument::Const(_) => Ok(()),             })?;             type_pieces.push(TypePart::Separator(">"));         }         syn::PathArguments::None => {}         syn::PathArguments::Parenthesized(ref paren) => {             type_pieces.push(TypePart::Separator("("));             fill_type_pieces_from_array_of_inputs(type_pieces, &paren.inputs, ",", fill_type_pieces_from_type)?;             type_pieces.push(TypePart::Separator(")"));             fill_type_pieces_from_return_type(type_pieces, &paren.output)?;         }     }     Ok(()) }  fn fill_type_pieces_from_return_type<'a>(type_pieces: &mut Vec<TypePart<'a>>, output: &'a syn::ReturnType) -> Result<(), &'static str> {     match output {         syn::ReturnType::Default => Ok(()),         syn::ReturnType::Type(_, ref arg) => fill_type_pieces_from_type(type_pieces, &**arg),     } }  fn fill_type_pieces_from_array_of_inputs<'a, T, U>(     type_pieces: &mut Vec<TypePart<'a>>,     inputs: &'a syn::punctuated::Punctuated<T, U>,     separator: &'static str,     action: impl Fn(&mut Vec<TypePart<'a>>, &'a T) -> Result<(), &'static str>, ) -> Result<(), &'static str> {     if !inputs.is_empty() {         for arg in inputs {             action(type_pieces, arg)?;             match type_pieces[type_pieces.len() - 1] {                 TypePart::Separator(_s) if _s == separator => {}                 _ => type_pieces.push(TypePart::Separator(separator)),             }         }         match type_pieces[type_pieces.len() - 1] {             TypePart::Separator(_s) if _s == separator => type_pieces.truncate(type_pieces.len() - 1),             _ => {}         }     }     Ok(()) }  fn make_type_name_from_type_pieces(type_pieces: Vec<TypePart>) -> String {     type_pieces         .into_iter()         .map(|piece| piece.to_string())         .collect::<String>()         .to_lowercase()         .chars()         .map(|c| match c {             '<' | '>' | '(' | ')' | '[' | ']' | '-' | ',' | ';' => '_',             _ => c,         })         .collect() } 

Can you see any way to improve it? It’s my first code using the new proc_macro feature, and I don’t find much examples out there.

Thanks!

SharePoint Document Sets with template from content type

Document Sets are created and simple but in the default content – I do not want static documents. I want the users to be able to modify the document as and when. I have attempted to add the template in a content type and used that content type as default content, but it does not stay in likewise the document does not arrive in the document set – any ideas ?

How can I type Lithuanian stress characters (e.g., ą́, ė̃, m̃)?

This is an obscure use case, so I’m not surprised that there’s nothing about this online. I already know how to type accent marks in general, and how to change keyboards. However, I was not able to find any way to type e.g. m̃ using the Lithuanian or ABC Extended keyboards. I thought option-N followed by M would work in ABC Extended, for instance, but it doesn’t. Here is a complete list of the characters I would like to be able to type:

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.693.9500&rep=rep1&type=pdf

Note that only a subset of these pose an issue. For example, I can obviously type é, ȩ, and č in either of the keyboard layouts above.

Any advice is appreciated. I would prefer to not have to pick characters from the symbol selection table.

Custom field type where entity reference is optional?

I am trying to create a field type that is a bundle of two fields. An entity reference user field, and a plain text field.

Image attached for clarity.

enter image description here

The idea is that the user attached to a published piece of content may have a different name at the time of the publication (marriage, divorce, name change, whatever) and has to remain intact for historical reasons. I am still linking to the same user profile, its just the visible name that is different. The most up to date name lives in the user account, but thats irrelevant.

There may be certain cases where a contributing author won’t exist as a user in Drupal at all, for a handful of reasons. In this case, I do not want to fill in the reference field, but still use the plain text field. The field formatter will be updated to detect the presence of a target id or not.

The end result being something like:

Attributions: Author One, Author Two, Author Three, Author Four

I can’t seem to get it to save an input though unless it has a reference value. How can you do that?

Here is my widget code:

/**  * Plugin implementation of the 'authors_widget' widget.  *  * @FieldWidget(  *   id = "authors_widget",  *   label = @Translation("Authors"),  *   field_types = {  *     "authors"  *   }  * )  */ class AuthorsWidget extends EntityReferenceAutocompleteWidget {    /**    * {@inheritdoc}    */   public function formElement(FieldItemListInterface $  items, $  delta, array $  element, array &$  form, FormStateInterface $  form_state) {     $  element = parent::formElement($  items, $  delta, $  element, $  form, $  form_state);      $  element['target_id']['#title_display'] = 'before';     $  element['target_id']['#title'] = 'User ID';     $  element['target_id']['#description'] = $  this->t('The Drupal user id of the user to reference.');     $  element['target_id']['#weight'] = -50;      $  element['name'] = array(       '#type' => 'textfield',       '#title' => $  this->t('Published Name'),       '#description' => $  this->t('Set the published name for this author at the time this content was published.'),       '#default_value' => isset($  items->get($  delta)->getValue()['name']) ? $  items->get($  delta)->getValue()['name'] : NULL,     );      return $  element;   }  }