New answers tagged

3 votes

Terms of expressions with non-commutative multiplication that meet the given criteria

I am assuming that out was missing a closing bracket and should look like the following: ...
user avatar
  • 58.4k
19 votes

How can a verbal reasoning question be solved with Mathematica?

Riffing off of DanielHuber's answer, and with less user intervention: ...
user avatar
11 votes
Accepted

How can a verbal reasoning question be solved with Mathematica?

To look for a pattern,we get the character codes: cc= ToCharacterCode["KDXPNGVNQJTLTM"] (* {75, 68, 88, 80, 78, 71, 86, 78, 81, 74, 84, 76, 84, 77} *) ...
user avatar
  • 24.3k
4 votes

Deleting sublists where an element repeats beyond a repetition threshold

part[m_, n_] := DeleteCases[ IntegerPartitions[m], _?(Max[Tally[#][[All, 2]]] > n &)] part[37, 2] {{37}, {36, 1}, {35, 2}, {35, 1, 1}, {34, 3}, {34, 2, ...
user avatar
  • 29.2k
5 votes
Accepted

Deleting sublists where an element repeats beyond a repetition threshold

ClearAll[f] f[m_, n_] := Select[LessEqualThan[1 + n] @* Max @* Counts] @* Map[Apply[Sequence] @* IntegerPartitions] @* Range @ m; Examples: ...
user avatar
  • 349k
4 votes

Deleting sublists where an element repeats beyond a repetition threshold

SeedRandom[1]; n = 2; plist = RandomSample[IntegerPartitions[37, {6, 7}], 200]; The list is still too large; let's reduce it to 20 entries for better visualization....
user avatar
  • 14.9k
6 votes

StringReplace question from "An Elementary Introduction to the Wolfram Language"

Decompose the problem. For example, "Make any 2-letter word uppercase" is a problem that you can probably solve (hint, there is a built in function for that). Now move on to "Make any 2-...
user avatar
  • 3,797
2 votes
Accepted

StringReplace question from "An Elementary Introduction to the Wolfram Language"

...
user avatar
  • 58.4k
3 votes
Accepted

How to make a pattern that matches only when one of the argument's Head is a Plus?

I think that there is some ambiguity in your description, so this probably needs some tweaking, but here goes... ...
user avatar
  • 3,797
5 votes
Accepted

Replacement, PatternTest, Module related Question

The reason your attempt fails is that at the time the Function is applied to its arguments, m has not yet been replaced by ...
user avatar
  • 23.4k
3 votes
Accepted

Pattern match with "+" sign

ClearAll[Pr2] Give Pr2 the attribute HoldFirst ...
user avatar
  • 120k
1 vote

Finding words that start and end with same letter

A solution using Reap/Sow: ...
user avatar
  • 14.9k
2 votes

Finding words that start and end with same letter

Another way: ...
user avatar
7 votes
Accepted

Finding words that start and end with same letter

Since you said that the start/end character was specified, you could do this: StringBookendedQ[char_] := StringMatchQ[char ~~ ___ ~~ char] and then this: ...
user avatar
  • 3,797
6 votes

Finding words that start and end with same letter

Consider: AbsoluteTiming[ res = Pick[WordList[], StringMatchQ[WordList[], x_ ~~ ___ ~~ x_]]; ] (* {0.040667, Null} *) ...
user avatar
3 votes

Counting negative values in list

Another one: Total@Boole@Negative@data
user avatar
  • 4,888
2 votes

Counting negative values in list

As a short variant Count[data, x_ /; x < 0]
user avatar

Top 50 recent answers are included