text:
Introduction
Try to convert words to two different unicode fonts.
Challenge
Your task is to transform your input string into the   and    unicode characters.
All uppercase words should become lowercase    words.

For Example: WORD ->

All lowercase words should become   words

For example: other words ->

All mixed case words should remain unchanged

For example: Mixed Case Words -> Mixed Case Words

Periods and spaces should remain unchanged.
Words are separated by spaces or periods

For example (highlighted things are words):

Hello. This is a word. S.O. are these

Inputs: A string containing letters, spaces, and periods ([A-Za-z .]+)
Output: The formatted string

As this is a golfing challenge, the lowest number of bytes wins
Example Input and Output
Input:

This is an example STRING that c.o.U.L.d. be INPUTTED. It can CONTAIN multiple sentences.

Output:

This      .....  . It    .

Reference
Math Sans Bold:  (characters 120302 through 120327)
Math Sans:  (characters 120250 through 120275)

Welcome to PPCG!

♫ Philosophy's just   rigor, sense, and practicality... ♫

Whoa! You got a title in bold in the sidebar? What? I... don't understand.... is the internet breaking? Have you broken the internet?

https://i.stack.imgur.com/R4V3C.png I came here thinking this challenge was about stacking boxes, bar charts or something...

This shouldn't have been close hammered. This problem is significantly more difficult than a simple character transliteration. The leading answer in the cited challenge can not easily nor competitively be transferred using that same method (afaict, my retina isn't great)

QuadR, 45 43 bytes
-2 thanks to ngn.
\w+
⎕UCS a+(2>≢b)×120153+84×⊃b←∪96>a←⎕UCS⍵M

Since TIO scrambles Unicode output from QuadR, here is a screenshot of using QuadR as an APL library in an interactive session:

\w+ replace words with the result of applying the following code to them:
⍵M the found word

⎕UCS the Universal Character Set code points of that

a← store that in a

96> 0 or 1 for whether 96 is greater than each of those

∪ take just the unique; [0] or [1] or [0,1] or [1,0]

b← store that in b

⊃ pick the first from that

84× multiply 84 with that

120153+ add 120153 to that

(…)× multiply the following with that:

 ≢b the tally (length) of b (1 if single-case, 2 if mixed-case)

 2> 0 or 1 for whether two is greater than that (1 if single-case, 0 if mixed-case)

a+ the original code points added to that

⎕UCS convert the resulting code points back to characters

APL (Dyalog Unicode), 63 57 53 bytes
-6 thanks to Erik the Outgolfer. -4 thanks to ngn.
Anonymous tacit prefix function.
'\w+'⎕R{⎕UCS a+(2>≢b)×120153+84×⊃b←∪96>a←⎕UCS⍵.Match}

Since TIO scrambles Unicode output from Dyalog APL, here is a screenshot of the code in action:

'\w+'⎕R PCRE Replace words with the result of applying the following…
{...} anonymous lambda:
 ⍵.Match the found word
 ⎕UCS the Universal Character Set code points of that
 a← store that in a
 96> 0 or 1 for whether 96 is greater than each of those
 ∪ take just the unique; [0] or [1] or [0,1] or [1,0]
 b← store that in b
 ⊃ pick the first from that
 84× multiply 84 with that
 120153+ add 120153 to that
 (…)× multiply the following with that:
  ≢b the tally (length) of b (1 if single-case, 2 if mixed-case)
  2> 0 or 1 for whether two is greater than that (1 if single-case, 0 if mixed-case)
 a+ the original code points added to that
 ⎕UCS convert the resulting code points back to characters

57 bytes: '\b([A-Z]+|[a-z]+)\b'⎕R{⎕UCS(⎕UCS+120153+84×∊∘⎕A)⍵.Match}

@EriktheOutgolfer Thanks. Why didn't I think of going tacit‽

I don't know, but it happens to me when I'm tired. :)

@EriktheOutgolfer Actually, I think I wrote this one from home using my wife's computer without APL keyboard layout…

@Adám that regex is too long; you're better off using \w+ and computing the amount to add to the codepoints in the dfn: '\w+'⎕R{⎕UCS a+(2>≢b)×120153+84×⊃b←∪96>a←⎕UCS⍵.Match}

@ngn Separate answer-worthy?

@Adám I can't decide which is worth less: wasting some minutes of my life on explanations, or the potential for 9 upvotes :)

@ngn I'll explain if you want.

@ngn Btw, it is -2 for QuadR too.

@Adám go ahead then :) no need to credit - people can see my comments anyway

@ngn Comments are temporary, credit is forever!

Clean, 268 265 232 224 bytes
As a neat bonus, this works with strings containing any character. Including nulls.
import StdLib,StdInt,StdBool,Text.Unicode,Text.Unicode.UChar
u=isUpper
l=isAlpha
$c|l c=fromInt(toInt c+120153+if(u c)84 0)=c
?[h,s:t]=[if(u h<>isLower s)($c)c\\c<-[h,s:t]]
?[h]=[$h]
@s=[y\\x<-groupBy(\a b=l a&&l b)s,y<- ?x]

Try it online!
Defines the function @, taking a UString and returning a UString

Is it also a clean bonus? :D

C, 292 characters, 448 bytes (in UTF-8)
char*t;s,i,k;p(l){for(l=s=*t/96,i=k=strlen(t);i--;)t[i]/96-s&&++l;for(l=l-s&&write(1,t,k);!l&++i<k;)write(1,s?""+t[i]*4-388:""+t[i]*4-260,4);}f(char*s){char b[strlen(s)];for(t=b;*s;++s)*s<47?(*t=0),p(t=b),putchar(*s):(*t++=*s);*t=0;p(t=b);}

Try it online!
Unrolled:
char*t;
s,i,k;

p(l)
{
    for (l=s=*t/96, i=k=strlen(t); i--;)
        t[i]/96-s && ++l;

    for (l=l-s&&write(1, t, k); !l&++i<k;)
        write(1, s ? ""+t[i]*4-388
                   : ""+t[i]*4-260, 4);
}

f(char*s)
{
    char b[strlen(s)];

    for (t=b; *s; ++s)
        *s<47 ? (*t=0), p(t=b), putchar(*s) : (*t++=*s);

    *t = 0;
    p(t=b);
}

Java 8, 221 219 203 201 bytes
s->{StringBuffer r=new StringBuffer();for(String x:s.split("(?<=[\\. ])|(?=[\\. ])"))x.codePoints().forEach(c->r.appendCodePoint(c+(x.matches("[A-Z]+")?120237:x.matches("[a-z]+")?120153:0)));return r;}

I have to use a StringBuffer instead of a regular String to use .appendCodePoint, unfortunately..
Explanation:
Try it online.
s->{                           // Method with String parameter and StringBuffer return-type
  StringBuffer r=new StringBuffer();
                               //  Resulting StringBuffer
  for(String x:s.split("(?<=[\\. ])|(?=[\\. ])"))
                               //  Split by space or dot, and keep them as separate items,
                               //  and loop over all those substrings
   x.codePoints().forEach(c->  //   Inner loop over the codepoints of that substring
      r.appendCodePoint(       //    Convert int to char, and append it to the result:
        c                      //     The next codepoint of the substring
        +(x.matches("[A-Z]+")? //     If the word is fully uppercase:
           120237              //      Add 120237 to convert it to Math Sans Bold
          :x.matches("[a-z]+")?//     Else-if the word is fully lowercase:
           120153              //      Add 120153 to convert it to Math Sans
          :                    //     Else (mixed case, or a dot/space)
           0)));               //      Leave the codepoint (and thus the character) as is
  return r;}                   //  Return the resulting StringBuffer

Haskell, 172 170 bytes
(s#w)r=[x|all(`elem`s)w,c<-w,(x,k)<-zip r s,c==k]
t[]=[]
t w=filter(>[])[['A'..'Z']#w$[''..],['a'..'z']#w$[''..],w]!!0
f s|(a,b:c)<-span(>'.')s=t a++b:f c|1>0=t s

Try it online!
Fairly straightforward. The # operator takes the set s of charcters (upper or lower case) the word w, and the math sans set r. It returns the word in the math sans font if all the characters in the word are in s or the empty list otherwise. The t function takes a word and tries all three possiblities (all upper, all lower, or mixed), returning the first one that isn't empty. The f function finds the first word by using span, transforming it with t and concatenating it with the separator (either . or space) and recurring on the rest of the string. The alternate case is for if span can't find a separator; we just transform the string.
Edit: Thanks to @Laikoni for taking off 2 bytes! I'm not used to the whole "operator that takes three arguments" thing

(['A'..'Z']#w)[''..] can be ['A'..'Z']#w$[''..].

Jelly, 34 bytes
e€ØBŒg
ṁÇµŒl,Œuiị“¡ẓƬ“¡ẓġ“’×Ç+OỌµ€

Try it online!
Full program.

It's probably obvious to professional Jellyists, but could you add a brief explanation to show ẇƬƒ is going on here?

@MickMnemonic sorry, right now I don't have time to

Japt, 34 33 32 31 bytes
Includes an unprintable (charcode 153) after the last #.
rV="%b%A+%b"Èc+#x#í
rVv Èc+#x#

Try it

Explanation
                        :Implicit input of string U
r                       :Replace
   "%b%A+%b"            :/\b[A-Z]+\b/g
 V=                     :Assign ^that to variable V
            È           :Run each match through a function
             c          :Map over the codepoints of the current match
              +#x#í     :  Add 120237
\n                      :Assign the result of that replacement to variable U
rVv                     :Another replacement, this time with V lowercased to give us the RegEx /\b[a-z]+\b/g
    Èc+#x#              :And, again, map over the codepoints of each match, this time adding 120153 to each

Original 32 Byte Japt v2 Solution
r/\b(\A+|\a+)\b/Èc_+#x#+#T*(X¶u

Try it
r                                     :Replace
 /\b(\A+|\a+)\b/                      :...all matches of this RegEx (\A=[A-Z], \a=[a-z])
                È                     :Pass each match through a function, with X being the current match
                 c_                   :Pass the codepoints of X through a function
                   +                  :Add to the current codepoint
                    #x#               :120153 (there's an unprintable after the second #)
                        +#T           :Plus 84
                           *          :  Multiplied by
                            (X¶u      :  Is X equal to its uppercase self

Mind adding an XXD dump?

A reversible hexdump? For the unprintables.

Python 3, 173 122 120 bytes
lambda s:''.join(chr(ord(c)+120153*t.islower()+120237*t.isupper())for t in re.split(r'\b(\w+)\b',s)for c in t)
import re

-51 bytes from ShreevatsaR
-2 bytes from abccd
Try it online!
Splits on word boundaries (re.split(r'\b(\w+)\b',s)), then maps lowercase words to    (+120153*t.islower()), and uppercase words to    (+120237*t.isupper()), and leaves mixed-case words alone, then joins the words back up.
Ungolfed and un-lambda-ed:
def f(s):
    words = re.split(r'\b(\w+)\b', s)
    ret = ''
    for word in words:
        for char in word:
            if word.isupper():
                ret += chr(ord(c) + 120237)
            elif word.islower():
                ret += chr(ord(c) + 120153)
            else:
                ret += c
    return ret

could it be less bytes if you set a variable to either 120237 or 120153 depending on if it was upper or lower? It looks like it might

@pfg Indeed, can easily shave off 13 bytes (down to 160).

@pfg Actually, replacing the map-lambda with (easier to read) comprehensions brings it down to 149 bytes.

140

122 :-) I'll stop here; quite proud of how golfing it further has made it easier to read. Only in Python!

-2 by getting rid of spaces before for

Retina, 84 bytes
/\b[A-Z]+\b/_(`.
ĵ$&
)T`L`ۮ-܇
/\b[a-z]+\b/_(`.
ĵ$&
)T`l`ں-ۓ
T`ÿ-߿`퟿-

Try it online! Explanation: Retina is a .NET application and therefore works in UTF-16 internally. Unfortunately as the Math Sans characters aren't in the BMP I can't directly transliterate them because the number of code points differs. Worse, I can't use unpaired surrogates at all. Instead, I shift the appropriate words into characters in the range 0xFF-0x7FF which conveniently only take two bytes to encode, plus I also prefix them with the 0x135 character. Finally I map that range onto the a range that overlaps the unpaired surrogates, creating valid BMP pairs.

JavaScript (ES6), 99 114 113 bytes
s=>s.replace(/\b([A-Z]+|[a-z]+)\b/g,e=>e.replace(/./g,f=>String.fromCodePoint(f.charCodeAt()+120153+(f<'a')*84)))

(Thanks to @pfg for pointing out an important flaw in my first solution.)
-1 bytes thanks to @Neil.
Snippet:

let f =

s=>s.replace(/\b([A-Z]+|[a-z]+)\b/g,e=>e.replace(/./g,f=>String.fromCodePoint(f.charCodeAt()+120153+(f<'a')*84)))

d.innerHTML=f('This is an example STRING that c.o.U.L.d. be INPUTTED. It can CONTAIN multiple sentences.');
<p id="d">

This only works with the HTML because of the &#, to do it with pure JS you would need to use String.fromCodePoint(120237) which would increase the size

Don't yet grok that, but I'll come back to it later, thanks.

let a = s=>s.replace(/\b([A-Z]+|[a-z]+)\b/g,e=>e.replace(/./g,f=>String.fromCodePoint(f.charCodeAt(0)+120153+(f<'a')*84))) works pure JS but adds many extra bytes

Ah, I understand!  Daggum.

Save 1 byte by using charCodeAt() without the 0.

05AB1E, 33 bytes
€aγ€g£εÐ.u•1Ù„•*s.l•1Ùm•*+sÇ+çJ}J

Try it online!


text:
Extension of the Game of Sevens
Introduction
Output all the numbers in specific base that would appear in an adapted version of the game of seven.
Challenge
Your task is to output all the numbers in a given base in a given range, skipping the ones matching certain conditions.
You will be  given four inputs: base elim start and end. The roles of the four variables are as follows:

base specifies what base we are using for the other three variables, and also for output. One way to express it is using a single character that is '8', '9' or a capital letter from 'A' to 'Z', using 'A' for decimal system, and 'G' for hexadecimal system. The bases expected to be supported are 8 to 35 (inclusive). This is just my suggested way to express the base and I will use it in the Example Input and Output section, but it is also fine to use your own way to express it. For example, you may choose to format base as its usual decimal representation.

start and end are two strings that specify the range of numbers to be output, expressed in the given base. If base is G and start is 10 and end is 1F, you need to output 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F, but you also need to eliminate some out them based on what elim is, to be explained soon.

elim is a single character and must be a valid digit in the given base. All numbers containing the digit elim or are multiples of elim should be eliminated from the list to generate the final output.

In the case above, if elim is 7, then 17 need to be eliminated because it contains the digit 7. 15 and 1C also need to be eliminated because they are multiples of 7. So the final output would be 10 11 12 13 14 16 18 19 1A 1B 1D 1E 1F
Test Cases
Input -> Output

G,7,10,1F -> 10 11 12 13 14 16 18 19 1A 1B 1D 1E 1F
A,3,1,100 -> 1 2 4 5 7 8 10 11 14 16 17 19 20 22 25 26 28 29 40 41 44 46 47 49 50 52 55 56 58 59 61 62 64 65 67 68 70 71 74 76 77 79 80 82 85 86 88 89 91 92 94 95 97 98 100
G,A,96,C0 -> 97 98 99 9B 9C 9D 9E 9F B0 B1 B2 B3 B5 B6 B7 B8 B9 BB BC BD BF C0

The third test case is added after the original post. All the answers posted before the edit has been tested and passed the third test.
Specs

The input will always be valid so don't worry about exception handling.

This is code-golf, the lowest number of bytes wins.

You can take input and provide output through any standard form, and you are free to choose the format.

As usual, default loopholes apply here.

This is based on the (real-life version of) the game of sevens.

I require base to be at least 8 purely due to personal taste. I just don't want to see the number of digits in the sequence grow too fast.

Scoreboard
Snippet taken from this question. Run the snippet to get the scoreboard.

var QUESTION_ID=154147,OVERRIDE_USER=77134;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} /* font fix */ body {font-family: Arial,"Helvetica Neue",Helvetica,sans-serif;} /* #language-list x-pos fix */ #answer-list {margin-right: 200px;}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

You state a preference that we only support bases >=8 but you should really explicitly specify the upper and lower bounds of the range of bases we need to support.

@Shaggy I thought one can figure it out from the requirement that base is a single character but anyway I have updated the question. Thank you for your feedback.

Welcome to PPCG! This is a nice first post, but I have few recommendations: Avoid very strict Input / Output formats (base,elim,start,end, 'A' for decimal system, 'G' for hexadecimal system), try to format your test cases in a way that is easy to use and consider using the Sandbox in order to receive feedback prior to posting to the main site. Overall, this is a good first challenge!

@Mr.Xcoder Thank you for your advice. I will edit it and maybe you can take a look a while later?

@WeijunZhou Sure, I’ll try to take a look at it later. Also feel free to reach us in chat if you encounter difficulties while editing and / or want tips.

@Mr.Xcoder I have finished the edit. You can also directly edit the question to make it better and I will try to learn from your edit.

@WeijunZhou I'd also suggest making the input formats for start, end and elim more lenient.

@EriktheOutgolfer Not sure about this ... especially for elim. I expect it to be a valid digit ... using something like the decimal representation for it is somewhat confusing ...

For the "G,7,10,1F" input a fully flexible approach would allow, for example, [16,7,16,31] as input and [[1,0],[1,1],[1,2],[1,3],[1,4],[1,6],[1,8],[1,9],[1,10],[1,11],[1,13],[1,14],[1,15]] as output. (Note that the first answer assumed some of this had been allowed already, since it's pretty standard - but it is totally up to you).

In Jelly, I estimate I can get it to ~14 bytes using decimal inputs and representing the digits in the output in decimal, and I estimate that I'll need at least ~30 bytes to be able to get input in the current format in the post, and I feel that's an unnecessary complication to the challenge.

@EriktheOutgolfer Accepted. You can use that format of input and output.

Would a trailing or leadin delimiter in the output be permitted?

@Shaggy As I have relaxed a lot on the input and output format since the original post, the answer is now yes.

Emojicode, 141 116 bytes
thanks to @NieDzejkob for 25 bytes!
abcdi⏩c➕1d❎0i b☁i ab ai a

Try it online!

  a b c d		 4 arguments of type  (integer)
   i  ⏩ c  ➕ 1 d 		 for i in range(c, d+1)
      			   if cond_a and cond_b
      ❎  0   i b		     cond_a: i%b != 0
      ☁   i a   b a	     cond_b: i in base-a doesnt have b in base-a
    				   then
        i a			     print i in base-a

-1 for language choice ಠ_ಠ

You can just post a closure, which is the emojicode equivalent of a lambda. This should save you some bytes.

Jelly,  12  11 bytes
-1 thanks to Erik the Outgolfer (use of "order" ọ in place of divisible with swapped arguments, ḍ@)
r/ọÐḟ⁵bċÐḟ⁵

A full program taking three inputs as command line arguments, all of which employ decimal notation - a list [start, end], and two numbers, base and elim - which prints the Jelly representation of a list of lists, where each represents the digits of a number in base and each digit is a decimal number (e.g. 1043 in base 20 would be [2,12,3], i.e. 2×202+12×201+3×200).
Try it online!
A small note: this won't work for ranges that include negative values, but the linked challenge starts from 1 and counts up.
How?
r/ọÐḟ⁵bċÐḟ⁵ - Main link: list, [start, end]; number, base
 /          - reduce [start, end] with:
r           - inclusive range => [start, start+1, ..., end]
   Ðḟ       - filter discard if:
     ⁵      -   program's 5th argument (the 3rd input), elim
  ọ         -   order (how many times the element is divisible by elim, or 0 if not)
      b     - convert to base "base"
        Ðḟ  - filter discard if:
          ⁵ -   program's 5th argument (the 3rd input), elim
       ċ    -   count (0 if elim is not a digit)

ḍ@ can be ọ ;) (btw I'd have posted rọÐḟ⁶b⁵ċÐḟ⁶...)

Ah yeah, never used the sixth arg!

As usual, would you mind expanding it and elaborating how it works?

An alternative for ọÐḟ could be %Ðf

Julia 0.6, 69 bytes
f(b,e,r,g=filter)=g(z->!contains(z,base(b,e)),base.(b,g(x->x%e>0,r)))

Inputs are base, elim, start:end where start:end is a UnitRange. as base 10 integers. Outputs a list of strings of the numbers in the given base. Filters for divisibility in integer form, uses base. to elementwise convert to strings, then filters on digit containment. Called example: f(10,3,1:100)
Try it online!

I hadn't thought of using defaults in a signature to alias subroutines, I'll have to remember that for future Perl 6 posts.

Japt, 16 bytes
Hastily rewritten after the spec was changed to allow decimal input so can probably be improved upon.
Takes input in the order start, end, base, elim and outputs an array of numbers in the given base.
òV kvX msW køXsW

Try it

Explanation
                   :Implicit input of integers U=start, V=end, W=base & X=elim
òV                 :[U,V]
   k               :Remove
    vX             :  elements divisible by X
       m           :Map
        sW         :  Convert to base-W string
           kø      :Remove elements containing
             XsW   :  X converted to a base-W string
                   :Implicit output of resulting array

For values of elim that are larger than 10, yet smaller than the base, this will fail to remove elements that contain the digit. For example for 0,35,12,11 the output erroneously contains 23=(1,11)base12

@gggg, it looks like the spec was changed since I posted this; originally, elim was specified to be a single digit (i.e., 0-9) rather than a single character in the input base.

Fair enough, I found the spec to be super confusing.

By "single digit" I mean a digit in the corresponding base. Hence "A" (or if you prefer to express it as a 10) is a digit in a hexadecimal base. Sorry about the confusion.

Would you be kind enough to modify the code upon the above clarification? Thank you and sorry again for the confusion.

@gggg Thank you for offering a test case. I will retest all existing answers. And sorry for the confusion.

@WeijunZhou: Updated. Will update my JS one later.

Please accept my heartfelt gratitude.

@Shaggy Would you mind updating the explanation?

@WeijunZhou: Done

Python 2, 102 94 bytes
lambda b,e,l,u:[i for i in range(l,u+1)if i%e*x(i,b,e)]
x=lambda n,b,e:n<1or(e-n%b)*x(n/b,b,e)

Try it online!
Input and output is in base 10.

JavaScript, 82 bytes
A quickie before I hit the boozer! Takes input in base-10 in the order base, elim, start & end and outputs a space delimited string of base-10 numbers with a single trailing space.
(b,l,s,e)=>(g=o=>++s>e?o:g(s%l&&!~s[t=`toString`](b).search(l[t](b))?o+s+` `:o))``

Try it online

This one has the problem as the Japt one. Would you mind modifying it a bit?

@WeijunZhou: Updated.

Thank you very much. You can update the "explanation" part of the other answer whenever you like to. No hurry.

@WeijunZhou: I assume you mean on my Japt solution, rather than this one? I'll be updating when I get back to my computer tomorrow.

Yes, my bad. I edited the comment right away but you still saw the original one ... Sorry about it.

Perl 6,  94  57 bytes
->\a,$b,\c,\d {grep {!/$b/},grep({$_%$b.parse-base(a)},[...] (c,d)».parse-base(a))».base(a)}

Test it (94)
Since the rules have changed:
->\b,$e,\r{grep {!/"$e.base(b)"/},grep(*%$e,r)».base(b)}

Test it ( Int, Int, Range )
Output is a list of strings in the base
Expanded
->
  \b,  # base  (Int)
  $e,  # elim  (Int)
  \r   # range (Int Range)
{
  grep
    {!/"$e.base(b)"/},  # remove the values that contain the character

    grep(
      * % $e,           # remove values that are divisible by elim
      r                 # the input Range

    )».base(b)          # convert each into base ｢b｣
}

Thank you for your interest and effort, also for writing a test. Learned a lot.

Java 8, 92 bytes
(b,k,s,e)->{String r="",t;for(;s<=e;r+=t.contains(k)?"":t+" ")t=b.toString(s++,b);return r;}

Input as Integer (base), String (elem), int (start), int (end).
Explanation:
Try it online.
(b,k,s,e)->{              // Method with the four parameters, and String return-type
  String r="",            //  Result-String, starting empty
         t;               //  Temp-String
  for(;s<=e;              //  Loop from start to end (inclusive)
      r+=                 //    After every iteration: append the result-String with:
         t.contains(k)?   //     If the temp-String contains the elem we exclude
          ""              //      Don't append anything to the result-String
         :                //     Else:
          t+" ")          //      Append the temp-String + a space
    t=b.toString(s++,b);  //   Convert the number to the given base and set the temp-String
  return r;}              //  Return the result-String

The three test cases are inputted like this:
16,"7",16,31
10,"3",1,100
16,"A",151,192

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Partition it into as few disjoint contiguous increasing subsequences as possible
Specification
This challenge is simple to state: your input is a non-empty array of nonnegative integers, and your task is to partition it into as few substrings as possible, such that each substring is a permutation of a consecutive integer range.
More formally, if the input array is A, then the output is minimum number of partition of A into B(s):

Each arrays B form a partition of A into substrings. Inductively, this means that either B is the singleton array containing 1 element from A, or the elements of B is a subsequence of A, which when sorted are contiguous like x,x+1,x+2,...
The number of arrays B is minimal.

Example
Consider the input array A = [1,2,3,4,3,5].
Output is 2
One possible minimal partitions are B = [1,2,3],[4,3,5]. That's the only partition to 2 substrings.
{4,3,5} in sorted order is {3,4,5} which is contiguous.
Input
An array of integers A.
Output
A number, indicate the smallest number of parts A can be splitted to.
Winning criteria
Your submissions will be scored in bytes, with less bytes being better.

This site is for programming contests (i.e., you post programming challenges in questions), general programming questions are off-topic here.

(in other words, because the question is a question, it's off-topic. Counter-intuitive)

Is this a code-golf? Maybe you should clarify and add a [tag:code-golf] tag.

I have edited your question to suit our standards. I have also added an objective winning criterion, namely [tag:code-golf]. Feel free to edit / rollback if you disagree with the changes I’ve made. Oh, and welcome to PPCG!

(well, this way you get completely-useless and very-short programs)

@JonathanAllan "contiguous subsequence" is the same as "substring".

Is the example answer 2 because the minimal length of any possible B is 2 or because there are 2 such minima? Seems to be some conflict between "your task is to partition it into as few contiguous increasing subsequences as possible" vs "we have Q queries updating single value on A asking minimum number of type B(s) possible"

This challenge needs more test cases. I'd suggest [], [3], [1,2], [2,5], [2,6,3], [1,2,11,12,3,4,9,20,22,10,5,6,14,13].

Another test case: [3,3,3,2,2,2]

I VTC as unclear since there seems to still be confusion regarding the specification. The examples do not match up with the literal meaning of the description.

OP's question on SO might help for clarification.

@ovs the question here has probably mutated from its intent. A new, clear question (or even questions) would be better in my opinion.

@ovs Actually that is also unclear to me.

@ovs The pdf posted in discussion might though.

link to my question : https://expirebox.com/download/d250698abbe222861fe450d7f0ee6297.html

@JonathanAllan Oh.... The challenge doesn't match with the PDF. In that case just keep the current challenge, because... we don't care about the OP's original problem.

@user202729 Maybe my previous edit was right :p

@JonathanAllan Anything remaining that's still unclear?

@user202729 yeah 1,2,3,4,5 is not a substring of 1,2,3,4,3,5 - if we go by the examples it should be "subsequence" and the word "contiguous" is just misleading; if we go for substrings then the example is wrong. Which one will lead to less answers being incorrect?!

@JonathanAllan Edited.

why have you removed the Link to the PDF?

@OptimusPrime "Challenges should be self-contained, because links may expire, especially expirebox links."

@user202729 Kotlin answer returns 3 for 1,2,8,3,4,3,5,7, a substring version would return 1 whereas a subsequence version would return 3 so probably the latter (unless also buggy).

Kotlin, 91 bytes
fold(mutableListOf<Int>()){r,i->r.indexOfFirst{it<i}.let{if(it<0)r+=i else r[it]=i
r}}.size

Beautified
fold(mutableListOf<Int>()) {r,i->
    r.indexOfFirst { it<i }.let {
        if (it<0) r+=i else r[it]=i
        r
    }
}.size

Test
fun MutableList<Int>.f() =
fold(mutableListOf<Int>()){r,i->r.indexOfFirst{it<i}.let{if(it<0)r+=i else r[it]=i
r}}.size

fun main(args: Array<String>) {
    val i = mutableListOf(1,2,3,4,3,5)
    println(i.f())
}

TIO
TryItOnline

JavaScript (ES6), 82 bytes
f=(a,n=Math.min(...a),i=a.indexOf(n))=>1/a[0]?i<0?1+f(a):f(a,a.splice(i,1)[0]+1):1

Haskell, 139 bytes
import Data.List
l=length
q(x:r)=map([x]:)(q r)++[(x:y):v|(y:v)<-q r]
q[]=[[]]
s(x:y)=x+l y==last(x:y)
f x=minimum[l y|y<-q x,all(s.sort)y]

Jelly, 9 bytes
Œ!Iċ€1ṀạL

Try it online!
How it works
Œ!Iċ€1ṀạL  Main link. Argument: A (array)

Œ!         Take all permutations of A.
  I        Increments; compute the forward differences of each permutation.
   ċ€1     Count the number of 1's i each array of deltas.
      Ṁ    Take the maximum.
        L  Compute the length of A.
       ạ   Take the absolute value of the difference of the maximum and the length.

I believe [1,2,8,3,4,3,5,7] should actually not return either 3 or 2 but 1 since there is only a single minimal length partition, [[1,2],[8],[3],[4,3,5],[7]], satisfying the criteria. (Either that or 5 since that's the minimal length)

That may have been what the OP was going for, but the latest revision clearly asks to indicate the smallest number of parts A can be splitted to.

Also, since [1,2,3,4,5],[3] appear as part of the worked example, reordering is clearly allowed.

Ah, hadn't updated since going out....

It is not; it has been there since revision 1. By contiguous, the OP appears to mean that the partitions consist of consecutive integers,

Yeah, it was totally unclear then!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Matrices Generated Using Rectangles
Input is an r by c matrix of non-negative integers (you may input r and c as other parameters if this helps with golf). This may be inputted as a 2D array or, if you prefer, a 1D array (though taking in r this time is necessary). Strings separated by spaces to distinguish rows and newlines to distinguish columns are also fine (below, the test cases have multiple spaces to distinguish rows for clarity -- you do not have to do this).
Consider a matrix of zeros. A move consists of replacing a rectangle of numbers with a rectangle of some positive integer (not zero). For example, these are all valid first moves:
0 0 0 0
0 2 0 0
0 0 0 0
0 0 0 0

0 3 0 0
0 3 0 0
0 3 0 0
0 3 0 0

1 1 1 0
1 1 1 0
0 0 0 0
0 0 0 0

These are not valid first moves:
0 0 0 0
0 2 0 0
0 0 0 0
0 2 0 0

0 1 0 0
0 2 0 0
0 0 0 0
0 0 0 0

0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0

Make golfed code to answer the following the question:
Given an r by c matrix, what is the smallest possible number of turns taken to construct this?
Test Cases:
1 1 1 1
1 2 2 2
1 2 3 3
1 2 3 4
1 2 3 4
> 4

1  2  3  4  5
6  7  8  9  10
11 12 13 14 15
> 15

3 3 3 3 3 3
3 2 2 2 2 3
3 2 1 1 2 3
3 2 1 1 2 3
3 2 2 2 2 3
3 3 3 3 3 3
> 3

1 1 1 1 1 1
1 2 2 2 2 1
1 2 0 0 2 1
1 2 0 0 2 1
1 2 2 2 2 1
1 1 1 1 1 1
> 8

0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
> 0

1 1 1 1
1 3 3 1
2 3 3 2
2 2 2 4
> 4

This seems like a very, very hard problem to compute efficiently to me.

This is a harder variation of this challenge.

Based on your examples of first moves I guess the numbers aren't inputted in order? None of your test cases reflect that, though. The test cases all go from 1 upwards (first test case four movies: 1,2,3,4; second test case 15 moves: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15; third test case 3 moves: 1,2,3; fourth test case 8 moves: 1,1,1,1,2,2,2,2). (It does make the challenge easier if only the same or next numbers can be inputted in that order. But if that's not your intention, you could for example swap the 1s and 3s in the third test case to reflect this.)

@KevinCruijssen That's not my intention. Fixed.

What is the answer for [[1,1,1,1], [1,3,3,1], [2,3,3,2], [2,2,2,3]]? (In other words, can a rectangle be placed over different numbers?)

Can you add a test case where the optimal solution requires multiple rectangles with the same number for a reason other than interfering zeros? For example, [[1,1,2,2],[1,1,2,2],[2,2,1,1],[2,2,1,1]] should take 3 rectangles.

The fourth test case can be done in three moves, unless I am (a) not allowed to replace existing numbers with 0, and/or (b) not allowed to apply numbers out of order.  If I can use 0 and replace out of order, the three moves are: (1) replace entire matrix with 1s; (2) replace the central 4x4 matrix with 2s (replacing the 1s that replaced the initial 0s); (3) replace the central 2x2 matrix with 0s (replacing the 2s that replaced the 1s that replaced the 0s).

Python 2, 333 bytes
lambda g,l=len:min(i for i in r(l(g)*l(g[0])+1)if g in o(l(g[0]),l(g),[[0]*l(g[0])for _ in" "*l(g)],set(sum(g,[])),i))
o=lambda w,h,g,s,I:I and sum([o(w,h,n,s,I-1)for n in[[[x<=j<=X<[]>Y>=i>=y and S or E for j,E in e(R)]for i,R in e(g)]for x in r(w)for X in r(x,w)for y in r(h)for Y in r(y,h)for S in s]],[])or[g]
r=range
e=enumerate

Try it online!
This only works in theory, because in practice, it takes way too long if you have more than about 5 elements in the grid.
Since this is code-golf, I apologize for the inefficiency, but efficiency would require more thought and FAR more bytes.
This code does the same thing at the cost of 5 bytes, but short-circuits, meaning that a larger grid with a small answer may finish somewhat earlier... the difference in viable search space is negligible, but just in case you wanted to test it a bit more.
The reason this is so slow is because it looks from \$0\$ up to \$W\times H\$, generating every possible \$W\times H\$ grid that can be achieved with the elements of the grid with that many steps being used.

Python3, 1288 bytes
Long, but crunches the test cases in under a second.
R=range
E=enumerate
M=[(1,0),(-1,0),(0,-1),(0,1)]
def D(b):
 for x,j in E(b):
  for y,_ in E(j):
   for X in R(x,len(b)):
    for Y in R(y,len(b[0])):yield[(u,i)for u in R(x,X+1)for i in R(y,Y+1)]
def r(b):
 S={(x,y)for x,j in E(b)for y,_ in E(j)if _ not in['0']}
 W={*S}
 while S:
  x,y=[(x,y)for x,y in S if b[x][y]!='-'][0];S=S-{(x,y)};d,s={x:[y]},[(x,y)]
  V=b[x][y]
  q=[(x,y)]
  while q:
   x,y=q.pop(0)
   F=1
   for X,Y in M:
    J,K=x+X,y+Y
    if(J,K)in S and(b[J][K]==V or'-'==b[J][K]):F=0;q+=[(J,K)];S=S-{(J,K)};d={**d,J:sorted(d.get(J,[])+[K])};s=s+[(J,K)]
   if all(b==d[min(d)]for b in d.values()):yield s
def Z(B,s,i):
 B=eval(str(B))
 for x,y in s:B[x][y]=i
 return B
V=lambda W,c,S,U:(W==-1 or c+1<W)and all(C>c for C,u in S if u==U)
def f(b):
 q,S=[(b,0)],[(0,b)]
 L=[i for i in D(b) if i]
 W=-1
 while q:
  B,c=q.pop()
  if all(not({*i}-{'-','0'})for i in B):W=c if W==-1 else min(W,c);continue
  H=[*r(B)]
  for i in H:
   U=Z(B,i,'-')
   if V(W,c,S,U):
    q+=[(U,c+1)];S+=[(c,U)]
    if len({sum(B[x][y]!='-'for x,y in j)for j in H})==1:break
  U=Z(B,max([i for i in L if len(T:={B[x][y]for x,y in i})<3 and{'-'}!=T and'0'not in T and(len(T)==1 or'-'in T)],key=lambda X:sum(B[x][y]not in{'-','0'}for x,y in X)),'-')
  if V(W,c,S,U):q+=[(U,c+1)];S+=[(c,U)]
 return W

Try it online!

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
I want my book to be away from this table
Story
So I have a book that I want to separate from my table with nothing but other books. I want to know how many books do I need to achieve this with \$n\$ book lengths.
Here's a visualization that my friend at Wolfram drew for me:

More information about the topic in Wolfram and Wikipedia.
Challenge
Given an integer input \$n\$, output how many books needed for the top book to be \$n\$ book length away from the table horizontally.
or
Find the smallest integer value of \$m\$ for input \$n\$ in the following inequality.
$$\sum_{i=1}^{m}\frac{1}{2i} \geq n$$
Edit: for fractions use at least a IEEE single-precision floating point. sorry for editing challenge after posting
(OEIS A014537)
Test cases
 1          4
 2         31
 3        227
 5      12367
10  272400600

https://www.youtube.com/watch?v=pBYPXsGka74 <-- related

Does it have to be using this particular arrangement of books, which IIRC is not optimal?

Octave, 41 40 33 bytes
1 byte saved thanks to @Dennis
@(n)find(cumsum(.5./(1:9^n))>n,1)

Try it online!
Explanation
This uses the fact that harmonic numbers can be lower-bounded by a logarithmic function.
Also, the >= comparison can be replaced by > because harmonic numbers cannot be even integers (thanks, @Dennis!).
@(n)                                   % Anonymous function of n
                     1:9^n             % Range [1 2 ... 9^n]
                .5./(     )            % Divide .5 by each entry
         cumsum(           )           % Cumulative sum
                            >n         % Is each entry greater than n?
    find(                     ,1)      % Index of first true entry

Python 3, 35 bytes
f=lambda n,k=2:n>0and-~f(n-1/k,k+2)

Try it online!

Husk, 8 bytes
V≥⁰∫m\İ0

Try it online!
Since Husk uses rational numbers when it can, this has no floating point issues
Explanation
      İ0    The infinite list of positive even numbers
    m\      Reciprocate each
   ∫        Get the cumulative sum
V           Find the index of the first element
 ≥⁰         that is greater than or equal to the input

8 bytes, but in which charset?

@john16384 Husk has it's own codepage where each symbol corresponds to a single byte. Here is the corresponding hexdump

JavaScript, 30 bytes
A recursive function so it'll crap out pretty early.
f=(n,x=0)=>n>0?f(n-.5/++x,x):x

Try it online

Haskell, 38 bytes
k!n|n<=0=0|x<-n-1/(2*k)=1+(k+1)!x
(1!)

Javascript (ES6), 34 bytes
n=>eval("for(i=0;n>0;n-=.5/i)++i")

Ungolfed
n => {
    for(i = 0; n > 0; ++i)
        n -= .5 / i
    return i;
}

Test Cases

f=n=>eval("for(i=0;n>0;n-=.5/i)++i")
<button onclick="console.log(f(1))">Run for n = 1</button>
<button onclick="console.log(f(2))">Run for n = 2</button>
<button onclick="console.log(f(3))">Run for n = 3</button>
<button onclick="console.log(f(5))">Run for n = 5</button>
<button onclick="console.log(f(10))">Run for n = 10</button>

Came up with a similar solution using recursion for 30 bytes. Dunno whether to post it or not, after seeing yours.

I may be missing something, but why do you need to wrap it in an eval statement?

@cairdcoinherigaahing, without the eval the i variable would need to be returned at the end, at the cost of a few more bytes.

Swift, 65 bytes
func f(n:Double){var i=0.0,s=i;while s<n{i+=1;s+=0.5/i};print(i)}

Try it online!
Ungolfed
func f(n:Double) {
  var i = 0.0, s = 0.0
  while s < n {
    i += 1;
    s += 0.5 / i
  }
  print(i)
}

R, 39 bytes
function(n){while((F=F+.5/T)<n)T=T+1;T}

Try it online!
Brute Force!

Jelly, 8 bytes
RİSH:ð1#

This is very slow.
Try it online!

Haskell, 71 49 48 bytes
f x=length.fst.span(<x).scanl(+)0$(0.5/)<$>[1..]

@BMO saved me a whopping 22 bytes!

Julia 0.6, 30 27 bytes
<(n,i=1)=n>0?n-.5/i<i+1:i-1

Try it online!
Only works up to n = 6, because Julia has no tail call optimization.
-3 bytes thanks to Dennis.

TI-BASIC, 27 bytes
Prompts user for input and displays output on termination.  Note:  ⁻¹ is the -1 (inverse) token.
Input N
1
Repeat 2N≤Σ(I⁻¹,I,1,Ans
Ans+1
End
Ans

If you're going to save Ans in N immediately, then Input N or Prompt N is an input method that saves you one byte over Ans→N. And M can be replaced by Ans, so that 1→M becomes 1 and M+1→M becomes Ans+1. (But I am skeptical about an output in Ans that does not get displayed - see this - so maybe ending with :Ans is appropriate: then the value will be shown in place of "Done".)

Thank you!  I knew Ans→N felt funny.  Nice optimizations.  Also took your advice on output just to be safe.  Still comes out with a net -3 bytes :D

Japt, 12 bytes
The same length as, but slightly more efficient than, the recursive option.
@T¨(Uµ½÷X}a1

Try it

Explanation
@T¨(Uµ½÷X}a1
                 :Implicit input of integer U
@        }a1     :Return the first number X >=1 that returns truthy when passed through the following function
 T               :Zero
  ¨              :Greater than or equal to
    Uµ           :Decrement U by...
      ½÷X        :0.5 divided by X

05AB1E, 11 bytes
XµN·zODI›}N

Try it online!
Explanation
Xµ       }    # loop until counter is 1
  N·z         # push 1/(2*N)
     O        # sum the stack
      DI›     # break if the sum is greater than the input
          N   # push N

Pyth, 10 bytes
f!>Qsmc1yh

Try it online!
Extremely slow.
Pyth, 10 bytes
fgscL1STyQ

Try it online!

J, 22 bytes
-6 bytes thanks to frownyfrog
I.~0+/\@,1%2*1+[:i.9&^

Try it online!
original answer
Luis's answer in J:
1+]i.~[:<.[:+/\1%2*1+[:i.9&^

Ungolfed
1 + ] i.~ [: <. [: +/\ 1 % 2 * 1 + [: i. 9&^

Mostly curious to see if it can be drastically improved (cough paging miles)
Explanation
1 +      NB. 1 plus...
] i.~    NB. find the index of the arg in...
[: <.    NB. the floor of...
[: +/\   NB. the sumscan of...
1 %      NB. the reciprical of...
2 *      NB. two times...
1 +      NB. 1 plus...
[: i.    NB.  the integers up to
9&^      NB. 9 raised to the power of the arg

Try it online!

1+]i.~[:<. -> 1+]I.~ -> I.~0,

ofc!  thank you frownyfrog

And then I.~0+/\@,

If you edit, you’ll beat Julia :)

@FrownyFrog, done.  if you have some time, i would love to see you solve this one: https://codegolf.stackexchange.com/questions/154345/bracket-expansion.  all the solutions i can think of are too verbose to post in good conscience...

PHP, 35 bytes
while($argv[1]>$s+=.5/++$i);echo$i;

Run it using the CLI:
$ php -d error_reporting=0 -r 'while($argv[1]>$s+=.5/++$i);echo$i;' 5

Wolfram Language (Mathematica), 40 bytes
⌈x/.NSolve[HarmonicNumber@x==2#,x]⌉&

Try it online!

Java 8, 49 bytes
n->{float r=0,s=0;for(;s<n;)s+=.5f/++r;return r;}

Explanation:
Try it online. (Times out for test cases above n=7.)
n->{             // Method with integer parameter and float return-type
  float r=0,     //  Result-float, starting at 0
        s=0;     //  Sum-float, starting at 0
  for(;s<n;)     //  Loop as long as the sum is smaller than the input
    s+=.5f/++r;  //   Increase the sum by `0.5/(r+1)`,
                 //   by first increasing `r` by 1 with `r++`
  return r;}     //  Return the result-float

tinylisp, 98 bytes
(load library
(d _(q((k # N D)(i(l N(* D # 2))(_(inc k)#(+(* N k)D)(* D k))(dec k
(q((#)(_ 1 # 0 1

The last line is an unnamed lambda function that takes the number of book-lengths and returns the number of books needed. Try it online!
Explanation
The only numeric data type tinylisp has is integers, so we calculate the harmonic series as a fraction by keeping track of the numerator and denominator. At each step, N is the numerator, D is the denominator, and k is the sum index. We want the new partial sum to be N/D + 1/k, or (N*k + D)/(D*k). Thus, we recurse with a new numerator of N*K + D, a new denominator of D*k, and a new index of k+1.
The recursion should halt once the partial sum is greater than or equal to #, the desired number of book-lengths. At this point, we've gone one book too far, so we return k-1. The condition is 1/2 * N/D < #; multiplying out the denominator, we get N < D*#*2, which is the golfiest way to write it.
The recursive helper function _ does all these calculations; the main function is merely a one-argument wrapper that calls _ with the correct starting values for k, N, and D.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Reverse columns while preserving shape
Introduction
Suppose you have a list of lists of integers (or any objects really, but let's stick to integers for simplicity).
The lists may be of different lengths, and some of them may be empty.
Let's write the lists in a tabular format:
[[ 1,   2,   3,   4,   5],
 [ 6,   7],
 [ 8,   9,  10,  11],
 [],
 [12,  13,  14],
 [15,  16,  17,  18]]

This table has 5 vertical columns, containing the numbers 1, 6, 8, 12, 15, 2, 7, 9, 13, 16, 3, 10, 14, 17, 4, 11, 18, and 5.
If we reverse each column, we obtain the lists 15, 12, 8, 6, 1, 16, 13, 9, 7, 2, 17, 14, 10, 3, 18, 11, 4, and 5.
Let's plug those numbers back into the columns of the table while keeping the lengths of the rows the same as before:
[[15,  16,  17,  18,   5],
 [12,  13],
 [ 8,   9,  14,  11],
 [],
 [ 6,   7,  10],
 [ 1,   2,   3,   4]]

Your task is to implement this operation.
Input and output
Your input is a list of lists of nonnegative integers, representing the rows.
The rows may have different lengths, and some of them may be empty.
There will always be at least one row.
Your output is the result of reversing each column, as detailed above.
Input and output may be in any reasonable format.
The lowest byte count in each language wins.
Standard code-golf rules apply.
Test cases
[[]] -> [[]]
[[],[]] -> [[],[]]
[[8,5,1]] -> [[8,5,1]]
[[1,200],[0,3]] -> [[0,3],[1,200]]
[[],[3,9],[1],[]] -> [[],[1,9],[3],[]]
[[],[5,8,7],[0,6,5,7,1]] -> [[],[0,6,5],[5,8,7,7,1]]
[[1,8,5],[7,5,4],[],[1]] -> [[1,5,4],[7,8,5],[],[1]]
[[],[],[2],[],[31],[],[5],[],[],[],[7]] -> [[],[],[7],[],[5],[],[31],[],[],[],[2]]
[[1,10,100,1000],[2,20,200],[3,30],[4],[5,50,500],[6,60],[7]] -> [[7,60,500,1000],[6,50,200],[5,30],[4],[3,20,100],[2,10],[1]]
[[8,4],[3,0,4,8,1],[8],[0,8],[9,7,1,6],[3,8,1,9,5]] -> [[3,8],[9,7,1,9,5],[0],[8,8],[3,0,1,6],[8,4,4,8,1]]
[[3,9,3],[5],[1],[3,5],[9,0,6,2],[1,3],[4,9,2],[6,6,7,8,7]] -> [[6,6,7],[4],[1],[9,9],[3,3,2,8],[1,0],[5,5,6],[3,9,3,2,7]]
[[8,5,6],[3,5,2,4,9],[4,3,8,3,7],[6,1,1],[1,8,9,9],[9,1,2],[8,7]] -> [[8,7,2],[9,1,9,9,7],[1,8,1,3,9],[6,1,8],[4,3,2,4],[3,5,6],[8,5]]
[[2,4],[1,4],[0,8,7,3],[4,9,2,5],[2,8,0],[0,8,3],[7,3,1],[],[3,3,7,8]] -> [[3,3],[7,3],[0,8,7,8],[2,8,1,5],[4,9,3],[0,8,0],[1,4,2],[],[2,4,7,3]]

May we pad the rows of the output with nulls? (e.g. [[1,9],[3],[2,4,5]] -> [[2,4],[3,null],[1,9,5]])

@ETHproductions No, the output should contain only numbers.

-1 because it is not general (not allow negative numbers , letters, string and all possible type as row element) + I don't like it (it seems unnecessary difficult)

Jelly, 16 bytes
ḟṚṁṣj
z-ç€-ZFḟ-ṁ

Try it online! or verify all test cases.
How it works
z-ç€-ZFḟ-ṁ  Main link. Argument: M (matrix / 2D array)

z-          Zip the rows of M, using -1 as filler.
  ç€-       Map the helper link over the result, with right argument -1.
     Z      Zip the rows of the result.
      F     Flatten the resulting matrix.
       ḟ-   Filterfalse -1; remove all occurrences of -1.
         ṁ  Mold; shape the result like M.

ḟṚṁṣj       Helper link.
            Left argument: A (row / 1D array). Right argument: -1

ḟ           Filterfalse; remove all occurrences of -1.
 Ṛ          Reverse the resulting vector.
   ṣ        Split A at occurrences of -1.
  ṁ         Mold; shape the vector to the left like the 2D array to the right.
    j       Join the resulting 2D array, separating by -1.

Nice, the ṣ on the top line is very clever! (ḟṚṁṣj does ⁸ḟ⁹Ṛṁ⁸ṣ⁹¤j⁹ right?)  otherwise I had this for one more byte

Yes, that's exactly what it does.

APL (Dyalog Unicode), 20 19 16 bytesSBCS
-4 thanks to ngn.
Full program. Prompts for input from STDIN.
⍟0~¨⍨↓⍉⌽@×⍤1⍉↑*⎕

Try it online!
Explanation with example walk-through
⎕ prompt for evaluated input
 [[1,8,5],[7,5,4],[],[1]]
* raise e to the power of that (en which ensures that there will be no zeros)
 [[2.7,2981,148.4],[1096.6,148.4,54.6],[],[2.7]]
↑ mix the lists into a single matrix, padding with zeros:
 ┌                 ┐
 │2.7E0 3.0E3 1.5E2│
 │1.1E3 1.5E2 5.5E1│
 │0.0E0 0.0E0 0.0E0│
 │2.7E0 0.0E0 0.0E0│
 └                 ┘
⍉ transpose
 ┌                       ┐
 │2.7E0 1.1E3 0.0E0 2.7E0│
 │3.0E3 1.5E2 0.0E0 0.0E0│
 │1.5E2 5.5E1 0.0E0 0.0E0│
 └                       ┘
⌽@×⍤1 reverse the positive elements of each row
 ┌                       ┐
 │2.7E0 1.1E3 0.0E0 2.7E0│
 │1.5E2 3.0E3 0.0E0 0.0E0│
 │5.5E1 1.5E2 0.0E0 0.0E0│
 └                       ┘
⍉ transpose
 ┌                 ┐
 │2.7E0 1.5E2 5.5E1│
 │1.1E3 3.0E3 1.5E2│
 │0.0E0 0.0E0 0.0E0│
 │2.7E0 0.0E0 0.0E0│
 └                 ┘
↓ split the matrix into a list of lists
 [[2.7,148.4,54.6],[1096.6,2981,148.4],[0,0,0],[2.7,0,0]]
0~¨⍨ remove zeros from each list
 [[2.7,148.4,54.6],[1096.6,2981,148.4],[],[2.7]]
⍟ natural logarithm
 [[1,5,4],[7,8,5],[],[1]]

What if the input contains -1?

@ngn Input will never contain negative numbers; see section "Input and output".

@Zgarb That's perfect, thanks.

@Adám I edited to use rank 1 instead of mix-each-split.

@Adám also: exp/log instead of +1/-1 covers the tests with ⎕fr←1287

@ngn Sorry, but I'm afraid editing others' code isn't allowed in this site, Adám is the only one who decides if his code gets edited. I've rolled back for now.

@EriktheOutgolfer I was authorised, but if there's a rule against this, so be it.

remove zeros from each list... The list seems to me not negative so remove the 0 could be wrong...

@RosLuP True, there are no negative values, but due to the mixing (↑) zeros were introduced, and need to be removed.

Isn't there a way to use ⊖ here?

@Razetime Other than replacing ⌽ with ⊖, I don't see how.

Japt, 15 13 bytes
saved 2 bytes thanks to @Shaggy
y@=XfÊX£o
®fÄ

Test it online!
The second line can be removed if we are allowed to pad the rows with null values, saving 4 bytes.
Explanation
 y@  =XfÊ X£  o      Implicit: U = input array
UyX{U=Xfl Xm{Uo}}    (Ungolfed)
UyX{            }    Map each column X in the input by this function:
    U=Xfl              Set U to X filtered to only items whose factorial is truthy;
                       this just gets rid of the empty slots in the column.
          Xm{  }       Map each item in X to
             Uo          the last item in U, popping this item from the list.
                       Due to the way .map works in JS, this is only called on real items
                       and not empty slots, so this preserves empty slots.
                     Newline: set U to the resulting column-reversed array
 ®   fÄ              Due to the way y works, there will now be `undefined` in some rows.
UmZ{Zf+1}            (Ungolfed)
 mZ{    }            Map each row Z in U to
    Zf+1               Z filtered to only items where the item + 1 is truthy.
                     undefined + 1 is NaN, which is falsy, and thus eliminated.
                     Implicit: output result of last expression

Nice one! You can get it down to 13 bytes by replacing l; with Ê and mf_Ä with ®fÄ.

Actually, just mf seems to work for the second line.

@Shaggy Thanks, hadn't thought of those! mf would get rid of any zeroes in the result though, unfortunately...

Ah, yes, wasn't thinking of that.

K4, 36 bytes
Solution:
+{x[w]:|x w:&~^x;x}'x'[::;]@!|/#:'x:

Examples:
q)k)+{x[w]:|x w:&~^x;x}'x'[::;]@!|/#:'x:(1 2 3 4 5;6 7;8 9 10 11;0#0N;12 13 14;15 16 17 18)
15 16 17 18 5
12 13
8  9  14 11

6  7  10
1  2  3  4

q)k)+{x[w]:|x w:&~^x;x}'x'[::;]@!|/#:'x:(0#0N;5 8 7; 0 6 5 7 1)

0 6 5
5 8 7 7 1

Explanation:
This one has been a pain, and I'm still working to simplify the elided indexing.
Instead of indexing in at, for example, x[0] which would return the first row, we want to take the first column, which can be done using x[;0].
However passing variable y into x[;] treats it as doing x[y] not x[;y] hence shoving the :: in there: x[::;].
This is equivalent to flipping the list of lists, but flip requires all lists to be equal length!
+{x[w]:|x w:&~^x;x}'x'[::;]@!|/#:'x: / the solution
                                  x: / save input as variable x
                               #:'   / count (#:) each (')
                             |/      / take the max of these lengths
                            !        / til, range 0..max-1
                           @         / apply (index into)
                      [::;]          / :: is a kind of null,
                    x'               / index into x at each of these
 {              ; }'                 / two statement lambda on each (')
              ^x                     / null x (returns true if entry is null)
             ~                       / not, so flip true/false
            &                        / where, indexes where true
          w:                         / save as variable w
        x                            / index into w at these indexes
       |                             / reverse
  x[w]:                              / store this back in variable x at indexes w
                 x                   / return x from function
+                                    / flip the result

Haskell, 174 bytes
f x=map g.h.map(g.reverse>>=(!)).h$take(maximum$length<$>x).(++z).map pure<$>x
g=concat
h x|g x==[]=x|4>2=foldr(zipWith(:))z x
x!(c:d)|c==[]=c:x!d|a:b<-x=[a]:b!d
_!y=y
z=[]:z

Try it online!
Ungolfed/Explanation
The idea is to wrap all elements in [] and pad the rows with [] (turned out to be shorter than padding with a negative integer, this allows negative inputs as well which is nice), then transpose, reverse all rows and transpose again and flatten each row:
map concat                                   -- flatten each row
  . transpose'                               -- transpose (*)
  . map (\row-> reverse (concat row) ! row)  -- reverse each row (see below)
  . transpose'                               -- tranpose (*)
  $ take (maximum $ length <$> x)            -- only keep up as many as longest row
      . (++ z)                               -- pad row with [],[],..
      . map (\e-> [e])                       -- wrap elements in []
 <$> x

* This transpose function (h) simply returns the list if there are no elements at all.
The reverse function has to ignore [] elements (eg. [[],[1],[],[3],[4]] -> [[],[4],[],[3],[1]]), it does so by receiving two arguments: The first one are the elements in reverse order (eg. [4,3,1]) and the second one the original row.
x@(a:b) ! (c:d)
 | c == []   = c:x ! d    -- if current element is []: skip it
 | otherwise = [a]:b ! d  -- else: replace with new one (a) and continue
_ ! y = y                 -- base case (if no new elements are left): done

Python 2, 111 105 92 bytes
def f(l):x=map(lambda*n:[v for v in n if-1<v],*l);return[map(list.pop,x[:len(k)])for k in l]

Try it online!

You could use print instead of return to save a byte.

JavaScript (ES6), 79 76 bytes
(a,d=[],g=s=>a.map(b=>b.map((c,i)=>(d[i]=d[i]||[])[s](c))))=>g`push`&&g`pop`

Edit: Saved 3 bytes thanks to @ETHproductions.

@ETHproductions Right; I've no idea why I thought it wouldn't, otherwise I would have done that already.

APL (Dyalog Unicode), 27 bytesSBCS
≢¨⍴¨∘↓∘⍉⍉∘↑{⍵\⌽⍵/⍺}⍤1∘⍉∘↑=⍨

Try it online!

I think you overthought this one.

I knew I could use @ but I don't have it.

Clojure, 123 bytes
#(map(fn[i R](map(fn[j _](let[V(for[Q %](get Q j))F filter](nth(reverse(F + V))(count(F +(take i V))))))(range)R))(range)%)

I was expecting (+ nil) to throw an exception, but it evaluates to nil :o
This operates without padding, instead it counts how many of the previous rows are at least as long as the current row R.


text:
Find number of ones to get a number using + and *
Introduction
Your goal is to find the least number of ones you need to add or multiply together to get the input value, this is A005245.
Input
One positive integer N.
Output
The smallest number of ones that must be added/multiplied to get N.
Sample Input

7

Sample Output

6

Explanation

(1 + 1 + 1) * (1 + 1) + 1 = 7
Because this requires 6 ones, the output is 6

Test cases
 1  1
 2  2
 3  3
 5  5
10  7
20  9
50 12

As this is a code-golf challenge, lowest number of bytes wins.

OEIS A005245

Welcome to Programming Puzzles and Code Golf! As a first challenge this is OK, but next time please use the Sandbox before posting challenges so you can get feedback!

I'd suggest modifying this to explicitly state that you're looking for the minimum number of ones required. Otherwise, simply outputting the original number and claiming that it's the number of ones you need to add together would be a valid solution.

To clarify, you meant "using + and * ". Exponentiation would allow fewer, e.g. 9 = (1 + 1 + 1) ^ (1 + 1) ; uses 5 ones, not 6.

Are there examples where f(x) != x.primeFactorisation().sum() except 1?

@jrtapsell:  yes.  The given example of $f(7)=6$ is one.  For any (large enough) prime $p$ you can factor $p-1$ and add one.  You may be able to do better yet.

@Ross Fun fact (taken from the oeis page): the smallest prime number p such that f(p) doesn't equal f(p-1)+1 is p=353942783

@jrtapsell: Yes, many primes or pseudoprimes, esp. near multiples of a large power of 2 or 3 might be more compactly written as that power + a small offset. Examples: a) 13 = 223+1 (requires 8) and b) 129 = 2222222 + 1 (requires 15, not 129). Intuitively, the "optimal" factorization will generally involve powers of 2 and 3 such that we are approximating e^x.

Bonus points if solutions work up to known counterexamples n = 353942783 and n = 516743639 ?

Python 2, 74 70 bytes
f=lambda n:min([n]+[f(j)+min(n%j*n+f(n/j),f(n-j))for j in range(2,n)])

Try it online!
Alternate version, 59 bytes (unverified)
f=lambda n:min([n]+[f(j)+f(n/j)+f(n%j)for j in range(2,n)])

This works at least up to n = 1,000,000, but I have yet to prove that it works for all positive n.
Try it online!

Sorry if I'm missing something simple, but it's not obvious to be that this tries every viable expression tree. In particular, we have outer layer n=a*j+b with b<j, but might we need b>=j?

Hm, it would only fail if both b>=j and b>=a. But you're right, it's not obvious that this won't happen.

Interesting that there's no counterexamples up to 1,000,000, I wonder if it actually just always works. My best thought for a counterexample would be something of form a*b+c*d with a,b,c,d all summation expressions and are very efficient.

Jelly, 16 14 bytes
Thanks Dennis for saving 2 bytes!
ÆḌḊ,Ṗß€€+U$FṂo

Try it online!

Logic explanation
Given a number n:

If it's 1, the answer is 1. Otherwise:

The representation is either a + b or a × b, where a and b are expressions.
Consider all possible values of a and b:

If the representation is a + b, then a and b are in range [1 .. n-1].
If the representation is a × b, a and b are proper divisors of n larger than 1.

In both cases, the list [[<proper divisors of n larger than 1>], [1, 2, ..., n-1]] is computed (ÆḌḊ,Ṗ), map the current link over each number ß€€, add the correct pairs together (+U$) and get the minimum value (FṂo).
Code explanation
ÆḌḊ,Ṗß€€+U$FṂo   Main link. Assume n = 10.
ÆḌ       Proper divisors. [1,2,5]
  Ḋ      Ḋequeue, remove the first element. [2,5]
   ,Ṗ    Pair with Ṗop. Auto convert n = 10 to range
         [1,2,3,4,5,6,7,8,9,10] and remove the last element
         10, get [1,2,3,4,5,6,7,8,9].

ß€€      Apply this link over each element.
   +U$   Add with the Upend of itself.

FṂ       Flatten and get the Ṃinimum element.
  o      Logical or with n.
         If the list is empty, minimum returns 0 (falsy), so logical or
         convert it to n.

Pari/GP, 66 bytes
A port of Dennis's Python answer:
f(n)=vecmin(concat(n,[f(j)+min(n%j*j+f(n\j),f(n-j))|j<-[2..n-1]]))

Try it online!

Pari/GP, 72 bytes
Longer, but more efficient:
f(n)=if(n<6,n,vecmin([if(d>1,f(d)+f(n/d),1+f(n-1))|d<-divisors(n),d<n]))

Try it online!

Dennis improved his method and using that can save you 11 bytes: f(n)=vecmin(concat(n,[f(j)+f(n\j)+f(n%j)|j<-[2..n-1]])).

JavaScript (ES6), 108 96 bytes
f=n=>n<6?n:Math.min(...[...Array(n-2)].map((_,i)=>Math.min(f(++i)+f(n-i),n%++i/0||f(i)+f(n/i))))

Very inefficient; Array(n>>1) speeds it up slightly at a cost of a byte. Explanation: n%++i is non-zero if i is not a factor, so n%++i/0 is Infinity (and therefore truthy, and also definitely not minimal) if i is not a factor, but NaN (and therefore falsy) if i is a factor. Edit: Saved 12 bytes with inspiration from @edc65.

I tried running this in the background to see whether it was in fact capable of calculating f(50) but unfortunately Windows Update rebooted my PC before it could finish.

Did you try a single walk on the a array?

@edc65 Sorry, but I'm unclear as to what you're suggesting and why.

I see 2 maps, each one scanning the a array. Can't you merge the evaluations in the 2 lambdas and take the min?

@edc65 Ah yes, for some reason I thought nesting the min wouldn't be cheaper but I get to replace (i+=2) with another ++i so I'm saving 12 bytes in total, thanks!

Pari/GP, 213 bytes
Edit: I've been severely beaten.
f(n)={d;n<6&return(n);if(n<=#a,a[n]&return(a[n]),a=vector(n));for(i=1,n-1,a[i]||a[i]=f(i));a[n]=min(vecmin(vector(n\2,k,a[k]+a[n-k])),if(isprime(n),n,vecmin(vector((-1+#d=divisors(n))\2,i,a[d[i+1]]+a[d[#d-i]]))))}

Try it online!

Python 2, 181 bytes
def F(N,n,s="",r=""):
 try:
	if n<1:return(eval(s)==N)*0**(`11`in s or"**"in s)*s
	for c in"()+*1":r=F(N,~-n,s+c)or r
 except:r
 return r
f=lambda N,n=1:F(N,n).count(`1`)or f(N,-~n)

Try it online!

@pizzapants184 The main function f must not be anonymous, as it calls itself recursively.

Ah, sorry, I didn't see that.

Wolfram Language (Mathematica), 59 bytes
Saved 3 bytes thanks to Martin Ender. Using CP-1252 encoding, where ± is one byte.
±1=1;±n_:=Min[1+±(n-1),±#+±(n/#)&/@Divisors[n][[2;;-2]]]

Try it online!

Using ± instead of f saves 3 bytes assuming the source is encoded in CP 1252: https://tio.run/##y00syUjNTSzJTE78///QRkNbQ@tDG/PirWx9M/OiDbUPbdTI0zXU1Dm0URnM1lfWVNN3cMksyyzOLyqOzouNjjayttY1io2N/e@SHx1QlJlXEp2no6CkoGunoKSjADQrVkehGihiCEQGtbHWXBA1pgbIikwN4BKGBigyQG6s9X8A

Does not work correctly for input 353942783.

Perl 5, -p 78 bytes
79 bytes in old style counting (+1 for -p)
The fact that perl must use an extra $ for all scalar access really hurts the length of golfs that do a lot of arithmetic...
This method is mostly like the others already posted (try multiplication and addition to build a target number, take the cheapest). It however doesn't repeatedly recurse down so it can be used for relatively large inputs.
It also doesn't try to minimize the cost of building a number by addition or multip[lication because perl 5 has no builtin min and numeric sort is looooooong (as seen from the sort still in the code). Instead I just assume if a number is a factor of the target that I will use multiplication. That is safe since if e.g. 3 is a factor of 12 (so it sums the cost of 3 and 12/3) later in the loop it will consider 9=12-3 which will not be a factor, so 9+3 with the same cost as 3+9 will get tried anyways. However that may fail for targets <= 4 (it only does for 1 and 2). Adding $_ to the list to minimize fixes that. Which is unfortunate since I don't actually need that for the base cases because I already initialize @; with the proper starting values so it costs 3 bytes.
#!/usr/bin/perl -p
($_)=sort{$a-$b}$_,map{$;[$_]+$;[$'%$_?$'-$_:$'/$_]}//..$_ for@;=0..$_;$_=pop@

Try it online!


text:
Hexcellent Minesweeping
Hexcells is a game based off of Minesweeper played on hexagons. (Full disclosure: I have nothing to do with Hexcells. In fact I don't really like the game.)  Most of Hexcells rules can be pretty easily expressed in Generalized Minesweeper (Minesweeper played on an arbitrary graph).  The one that is most difficult is the {X} and -X- rules.
The {X} rule tells us that a cell borders X mines and that all of these mines border each other in a continuous path.  For example if we had the board:
  ?   ?

?  {3}  ?

  ?   ?

The 6 possibilities for mine placement would be
  *   .       .   .       .   .       .   *       *   *       *   *

*  {3}  .   *  {3}  .   .  {3}  *   .  {3}  *   .  {3}  *   *  {3}  .

  *   .       *   *       *   *       .   *       .   .       .   .

Your goal is to implement the rule {3} in generalized Minesweeper.
Specifics
Generalized Minesweeper is Minesweeper played on an arbitrary graph.  The graph has two types of vertex, an "indicator" or a "value".  A value can be either on or off (a mine or a dud) however its state is unknown to the player. An indicator tells the player how many adjacent vertices are on (mines) and does not count as a mine itself.
For example the following board for Generalized Minesweeper tells us that cells A and B are either both mines or neither of them are mines.

(In the diagram indicators are marked in gray while values are white)
Unlike in normal minesweeper where you click values that are off to reveal indicators, there is no such mechanic in Generalized Minesweeper.  A player simply determines for what states of the graph can satisfy its indicator.
Your goal is to build a structure in Generalized Minesweeper such that there are 6 specific cells that can only have states that fulfill as if they were connected with the Hexcells rule {3}.  When you write your solution you should not have specific values in mind for value cells. (In answer to H.PWiz's question it is allowed that some value cells might be deducible from the state, but you can always improve your score by removing such cells)
Scoring
You answers will be scored by the number of vertices in the final graph minus 6 (for the 6 inputs) with a lower score being better.  If two answers tie in this metric the tie breaker will be the number of edges.
Solvability
This problem is solvable, I have a solution to this problem and I will post it once this challenge is a week old.

So there always need to be 6 edges between the 6 input vertices?

@Bergi edges between value cells are redundant, as they have no meaning

@H.PWiz But the "{3} rule" says "all of these mines border each other in a continuous path" - without edges there is no path.

@Bergi but the task is create a graph such that are 6 cells that act "as if they were connected with the Hexcells rule {3}". They need not be connected

@H.PWiz Ah, right, I understood that as "if there were 6 connections made to a Hexcells {3} node".

Since 3 other people have solved it and probably beaten your solution, can you post yours?

This isn't really code or programming related is it? It looks more like something Puzzling.SE would have.

@Pavel Generalized minesweeper is a programming language as far as I am concerned.  It may be very esoteric, but I don't think it is too far off from [tag:proof-golf].

7 5 vertices, 14 10 edges

(Graph made with this online tool and paint.)
A-F are our six nodes, and J is a helper node. The three 1-nodes enforce that opposite nodes are different, while the 2-node makes sure that A, C and E can neither be all mines, nor all empty.
Edit: -2 vertices thanks to  CalculatorFeline and H.PWiz!

You can remove 2 vertices.

Note that the 2-J structure also ensures that ACE are not all empty.

44 vertices, 66 edges
First, we start with a ring of 6 value cells all connected to a 3. These cells will be the cells with the {3} rule.
  A   B
   \ /
F---3---C
   / \
  E   D

Then, we attach 012 sensors to the value cell pairs (AB,BC,CD,DE,EF,FA). The structure of the 012 sensor is below.
O   ?---1---?
 \ /       /
  2---?---1
 / \
A   B

A and B are the inputs to the sensor and O is the output. The ? cells are generic value cells. O will be a mine if exactly one of A and B is a mine and empty otherwise. Then, we connect a 2 node to all the sensor outputs. This ensures that there are exactly 2 pairs with exactly 1 mine, and it can be proven that the only configurations that satisfy this are the ones that satisfy {3}. Each sensor takes 7 nodes, so 6 sensors requires 42. Add the 3 node connected to ABCDEF and the 2 node connected to the outputs and you get 44.
This solution can also be adapted for {1}-{5} by changing the 3 node to some other value.

What are the outputs for each 012 sensor? Also, I only count 6 nodes in your 012

There's the 2 node, the 2 1 nodes, the 3 ? nodes, and C (which is not one of the ABCDEF nodes, just the output of the sensor).

@CalculatorFeline Got it, maybe rename C to O, since C is in ABCDEF

Fun fact: This solution is planar.

9 Vertices, 17 Edges
Where ? is a value cell, that is not one of the 6 we care about, we need the following subgraph.
    ___________
?  /    ?      \?
 \|    /|\     /
  3¯¯¯¯ 1 ¯¯¯¯2
  |\    |    /|
  | \ /¯|¯¯¯¯ |
  |  X  |     |
 /  / \_|___  \
A__/    B   \__C

My ASCII-art skill are dreadful.
With those 6 vertices set up: ABC can have the following states:
111, 110, 011, 000, 100, 001
With the cells corresponding to the following hexagon, all we then need are 3 more indicator cells A-1-D, B-1-E, C-1-F
  B  C
A      D
  F  E

It would be a lot smaller if you checked A,C,E instead of A,B,C.

@CalculatorFeline I can't see why...

If you remove the ABC check device from your solution, it almost works, except that it also allows ACE and BDF. In those, the # of mines in ACE is either 0 or 3, but in a valid solution it's 1 or 2. This allows you to have a score of 5.

@CalculatorFeline Right, and that would be Laikoni's answer minus 2. I see now. This is definitely hard to convey with text

@CalculatorFeline Since it doesn't contain the main idea of my submission, I won't post it. I think Laikoni will


text:
Implement the Boids algorithm
Introduction
The Boids Algorithm is a relatively simple demonstration of emergent behavior in a group. It has three main rules, as described by its creator, Craig Reynolds:

The basic flocking model consists of three simple steering behaviors which describe how an individual boid maneuvers based on the positions and velocities its nearby flockmates:

Separation: steer to avoid crowding local flockmates.
Alignment: steer towards the average heading of local flockmates.
Cohesion: steer to move toward the average position of local flockmates.

Each boid has direct access to the whole scene's geometric description, but flocking requires that it reacts only to flockmates within a certain small neighborhood around itself. The neighborhood is characterized by a distance (measured from the center of the boid) and an angle, measured from the boid's direction of flight. Flockmates outside this local neighborhood are ignored. The neighborhood could be considered a model of limited perception (as by fish in murky water) but it is probably more correct to think of it as defining the region in which flockmates influence a boids steering.

I am not perfect when explaining things, so I highly recommend checking out the source. He also has some super informative pictures on his site.
Challenge
Given the number of boids (simulated entities) and the number of frames, output an animation of the simulation.

The boids should be rendered as a red circle, with a line inside of the circle showing its heading, which is the direction the boid is pointing in:

The angle of each boid (as described by Reynolds) should be a full 300 degrees. (not 360)
The starting heading and position of each boid should be uniformly random (but seeded, so that the output is still determinate), as well as the position.
If the radius of the boid is 1, than the radius of the neighborhood should be 3.
The number of boids will be anywhere from 2-20.
The number of frames will be anywhere from 1-5000
The animation should be played with a minimum of 10 milliseconds per frame and a maximum of 1 second times the number of boids. (2 boids = 2 seconds per frame max, 3 boids = 3 seconds per frame max, et cetera)
The output animation should be at least 5 boid-radii by 5 boid-radii, times half the number of boids. So, the minimum size for 2 boids would be 10 boid-radii by 10 boid-radii, the minimum for 3 boids would be 15 boid-radii by 15 boid-radii, et cetera.
The radius of each boid must be a minimum of 5 pixels and a maximum of 50 pixels.
The speed of each boid needs to be limited so that it doesn't move more than 1/5th of its radius in one frame.
The output needs to be determinate, so that the same input will produce the same output if run multiple times.
If a boid reaches a border, it should wrap back to the other side. Likewise, the neighborhood around each boid should also wrap around the borders.

Rules for the algorithm
In this case, each boid has a sector around it spanning 300 degrees, centered on the boid's heading. Any other boids in this "neighborhood" are considered "neighbors", or (to use Reynolds' term) "flockmates".

Each boid should adjust its heading to avoid collisions and maintain a comfortable distance of one boid-radius with its neighbors. (This is the "Separation" aspect of the algorithm. The one boid-radius may be bypassed, but it should be like a rubber band, snapping back into place.)

Each boid should additionally adjust its heading to be closer to the average heading of the other boids in its neighborhood, as long as it doesn't interfere with the first rule. (This is the "Alignment" aspect of the algorithm)

Each boid should turn itself towards the average position of its flockmates, as long as this doesn't cause collision or significantly interfere with the second rule.

In his paper on the subject, he explains this as follows:

To build a simulated flock, we start with a boid model that supports geometric flight. We add behaviors that correspond to the opposing forces of collision avoidance and the urge to join the flock. Stated briefly as rules, and in order of decreasing precedence, the behaviors that lead to simulated flocking are:

Collision Avoidance: avoid collisions with nearby flockmates
Velocity Matching: attempt to match velocity with nearby flockmates
Flock Centering: attempt to stay close to nearby flockmates

More detailed description of movement:

The standard implementation of the Boids Algorithm usually does a calculation for each of the rules, and merges it together.
For the first rule, the boid goes through the list of neighboring boids within its neighborhood, and if the distance between itself and the neighbor is less than a certain value, a vector pushing the boid away from is neighbor is applied to the boid's heading.
For the second rule, the boid calculates the average heading of its neighbors, and adds a small portion (we'll use 1/10 in this challenge) of the difference between its current heading and the average heading to its current heading.
For the third and final rule, the boid averages the positions of its neighbors, calculates a vector that points towards this location. This vector is multiplied by an even smaller number than what was used for rule 2 (for this challenge, 1/50 will be used) and applied to the heading.
The boid is then moved in the direction of its heading

Here is a helpful pseudocode implementation of the Boids Algorithm.
Example Input and Output
Input:

5, 190 (5 boids, 190 frames)

Output:

Winning criterion
This is code-golf, so the smallest solution in bytes wins.

"There is, of course, more to the algorithm, so I highly recommend checking out the source." - is everything necessary here or not? If not I'd recommend fixing that.

Please use the sandbox before posting challenges, as advised on the ask page.

@JonathanAllan Yeah, everything necessary is here, but more in-depth explanations that may make more sense to other users are available at the source.

This is an interesting challenge (I find flocking behaviours fascinating) but it will need to be well specified, especially for a code-golf, otherwise the pressure to reduce the length of the code will cause every possible deviation from the spirit of the challenge to be incentivised.

Processing 3.3.6 (Java), 932 931 940 928 957 917 904 bytes

-1 byte from Jonathan Frech
+11 bytes to better match the spec
-2 bytes from Kevin Cruijssen
-12 bytes for changing args to t()
+29 bytes because I was doing ghosting wrong, see commented version below
-40 bytes for using for loops instead of separate calls for each ghost
-13 bytes for using default frameRate, 30

Well, it's a start, for someone who doesn't Java-golf. :)
int n=15,f=400,i,j,z=255,w=500;float d=200./n;PVector m;B[]a=new B[n];void setup(){size(500,500);fill(z,0,0);randomSeed(n);for(i=0;i<n;a[i++]=new B(new PVector(random(w),random(w)),m.fromAngle(random(TAU))));}void draw(){background(z);for(B b:a)b.u();if(frameCount%f<1)setup();}class B{PVector p,v,e,q,r;ArrayList<B>n;B(PVector m,PVector o){p=m;v=o;}void u(){e=v.copy();n=new ArrayList();for(B b:a){if(b!=this)for(i=-w;i<=w;i+=w)for(j=-w;j<=w;j+=w)t(i,j,b);}if(n.size()>0){q=new PVector();r=q.copy();for(B b:n){q.add(b.v);r.add(b.p);if(p.dist(b.p)<=d)e.add(p).sub(b.p);}e.add(q.div(n.size()).sub(v).div(10));e.add(r.div(n.size()).sub(p).div(50));}p.add(e.limit(d/10));v=e.mult(10);p.set((p.x+w)%w,(p.y+w)%w);noStroke();ellipse(p.x,p.y,d,d);stroke(0,0,z);line(p.x,p.y,p.x+v.x,p.y+v.y);}void t(int x,int y,B o){m=o.p.copy().add(x,y);if(2*d>=p.dist(m)&q.angleBetween(v,q.sub(m,p))<=5*PI/6)n.add(new B(m,o.v));}}

I don't know any reasonable way to do input in Processing, so the first two variables are the inputs (and I didn't count their values (5 bytes) toward the byte count). If this is a problem, I can try other things.
I also don't know of a good way to allow trying it online (the Processing.js project can't deal with this code style) without hosting things myself; and that is something I'm not eager to attempt. Let me know if there is anything clever I can do.
Formatted code, with comments
int n=15, // Number of boids
    f=400, // Number of frames
    i,j,z=255,w=500; // temp*2, and two constants
float d=200./n; // Boid diameter
PVector m; // temp
B[]a=new B[n];
void setup(){ // This is automatically called at startup
  size(500,500); // Can't use variables for this without extra bytes for settings()
  fill(z,0,0);
  randomSeed(n); // seeded from number of Boids, so that n=19 is very different from n=20
  for(i=0;i<n;a[i++]=new B(new PVector(random(w),random(w)),m.fromAngle(random(TAU))));
}
void draw(){ // This is automatically called each frame
  background(z);
  for(B b:a)
    b.u();
  if(frameCount%f<1) // When desired frames length is hit, reset everything.
    setup();         // Could also use noLoop() instead of setup() to just stop instead.
                     // Or, remove this if statement altogether to go on to infinity.
}
class B{ // Boid
  PVector p,v,e,q,r; // Position, Velocity, Next velocity, and two temp vectors
  ArrayList<B>n; // List of neighbors
  B(PVector m,PVector o){
    p=m;
    v=o;
  }
  void u(){ // Update function, does rules and redraw for this Boid
    e=v.copy();
    n=new ArrayList();
    for(B b:a){ // Test a Boid and its eight ghosts for neighborship
      if(b!=this) // Note: Assumes neighborhood diameter < min(width,height)
        // The ghosts are to check if it'd be closer to measure by wrapping
        // We need eight for wrapping north, east, south, west, northeast,
        // northwest, southeast, and southwest. And also the non-wrapped one.
        // The above assumption ensures that each ghost is further apart than
        // the neighborhood diameter, meaning that only one neighbor might be
        // found for each boid. To test this, place a boid in each corner, right
        // to the edge, facing away from center. Each boid should find three
        // neighbors, that are the three other boids.
        for(i=-w;i<=w;i+=w)for(j=-w;j<=w;j+=w)t(i,j,b);
    }
    if(n.size()>0){
      q=new PVector();
      r=q.copy();
      for(B b:n){
        q.add(b.v); // Velocity matching, pt 1
        r.add(b.p); // Flock centering, pt 1
        if(p.dist(b.p)<=d)
          e.add(p).sub(b.p); // Collision avoidance
      }
      e.add(q.div(n.size()).sub(v).div(10)); // Velocity matching, pt 2
      e.add(r.div(n.size()).sub(p).div(50)); // Flock centering, pt 2
    }
    p.add(e.limit(d/10)); // Update vectors
    v=e.mult(10);
    p.set((p.x+w)%w,(p.y+w)%w); // Wrapping
    noStroke();
    ellipse(p.x,p.y,d,d); // Draw Boid, finally
    stroke(0,0,z);
    line(p.x,p.y,p.x+v.x,p.y+v.y);
  }
  void t(int x,int y,B o){ // Test if a Boid (or a ghost) is a neighbor
    m=o.p.copy().add(x,y);
    if(2*d>=p.dist(m)&q.angleBetween(v,q.sub(m,p))<=5*PI/6)
      n.add(new B(m,o.v));
  }
}

Sample output
n = 15, frames = 400:

Or, the same animation, but showing the neighborhood of each boid.

Can 2*PI not become TAU to save a byte?

@JonathanFrech Yes it can; I originally had -PI,PI and I was going that way, but got sidetracked.

My program (which was written in js and html) didn't export a gif, but it drew an image and I used a screen capturing program and converted the video it exported to a gif. There is one thing I did notice, though. The boids have a blue outline, which doesn't follow the spec :)

Just another friendly reminder, this answer does not follow the spec, so it won't get the bounty.

I don't know Processing, but I think you can golf the following things: ,i, to ,i=0, and then remove the i=0 inside the for-loop. (-1 byte); frameCount%f==0 to frameCount%f<1 (1 byte); && to & in the final if 2*d>=p.dist(m)&q.angleBetween(v,q.sub(m,p))<=5*PI/6 (-1 byte). Again, not sure if these are possible, but since Processing seems fairly similar to Java, I think it is. Also, you could try creating a gif with http://www.screentogif.com/.

@iPhoenix I'd like to point out that neither the color of the line, nor the lack of a border on the circle are actually in the (text of the) spec, however I did expect this and can make the changes easily.

@KevinCruijssen The second two savings work, thanks! However, the setup method is called multiple times and something needs to reset i to zero when that happens. As to the gif, it was the online converter that caused the artifacts. (I used exported Processing frames as the input. I'll try screencapping to see if that does anything different).

@Phlarx I provided a picture for this reason. Nice entry, though.

@iPhoenix just providing a picture doesn't make every part of the picture part of the spec. Your picture doesn't have antialiasing on the circles, does that mean an answer that uses AA would be wrong?

JavaScript (ES6) + HTML5, 1200 bytes
Here's my current solution using the Canvas API. The eval() returns a curried function whose first input is the Boid population, and second is the number of animation frames. You can use Infinity for continuous animation.
The eval(...) is 1187 bytes and <canvas id=c> is 13 bytes, making a total of 1200. The CSS is unnecessary, but for convenience, it allows you to see the edges of the canvas.

eval("L7F7{function B8{t=this,t.a=o8*T,t.x=o8*S,t.y=o8*S}C=this.c,D=C.getContext`2d`,({abs:z,random:o,atan2:k,cos:u,sin:g,PI:P,T=2*P,G={c:_7A[r='filter'](b7b!=t)[i](9)79)),n:_7A[r](b7b!=t)[i](9)7({a,x,y:y-S})),s:_7A[r](b7b!=t)[i](9)7({a,x,y:y+S})),e:_7A[r](b7b!=t)[i](9)7({a,x:x-S,y})),w:_7A[r](b7b!=t)[i](9)7({a,x:x+S,y}))},M=I7[I,I+T,I-T][p]((a,x)7z(x)<z(a)?x:a)}=Math),B.prototype={d8{with(D)save8,translate(x,y),rotate(a),beginPath8,arc(0,0,5,0,T),fillStyle='red',fill8,beginPath8,moveTo(0,0),lineTo(10,0),strokeStyle='blue',stroke8,restore8},n:_7(({c,n,s,e,w}=G),c8.concat(n8,s8,e8,w8)[r](b7(d=b.x-x,f=b.y-y,400>d*d+f*f&&z(z(k(f,d)-a)/P-1)>1/6))),s8{q=(j=t.n8).length,v=t.v8||0,l=t.l8||0,f=t.f8||0,a=t.a=(t.a+v+l/10+f/50)%T,t.x=(x+u(a)+S)%S,t.y=(y+g(a)+S)%S},v:_7([d,f]=j[r](b7225>(b.x-x)**2+(b.y-y)**2)[p='reduce'](([d,f],b)7[x+d-b.x,y+f-b.y],[0,0]),d||f?M(k(f,d)-a):0),l:_7j[i](b7M(b.a-a))[p]((a,x)7a+x,0)/q,f:_7([d,f]=j[p](([d,f],b)7[d+b.x,f+b.y],[-x*q,-y*q]),d||f?M(k(f,d)-a):0)},S=C.width=C.height=50*L,A=Array(L).fill().map(_7new B),R=_7{D.clearRect(0,0,S,S),A[i='map'](b79=b).d8),A[i](b79=t=b).s8),F--&&setTimeout(R,10)},R8}".replace(/[789]/g,m=>['=>','()','({a,x,y}'][m-7]))
(10)(Infinity)
canvas{border:1px solid}
<canvas id=c>

Edit
As requested, another snippet with an input for Boid population:

b.onchange=()=>{eval("L7F7{function B8{t=this,t.a=o8*T,t.x=o8*S,t.y=o8*S}C=this.c,D=C.getContext`2d`,({abs:z,random:o,atan2:k,cos:u,sin:g,PI:P,T=2*P,G={c:_7A[r='filter'](b7b!=t)[i](9)79)),n:_7A[r](b7b!=t)[i](9)7({a,x,y:y-S})),s:_7A[r](b7b!=t)[i](9)7({a,x,y:y+S})),e:_7A[r](b7b!=t)[i](9)7({a,x:x-S,y})),w:_7A[r](b7b!=t)[i](9)7({a,x:x+S,y}))},M=I7[I,I+T,I-T][p]((a,x)7z(x)<z(a)?x:a)}=Math),B.prototype={d8{with(D)save8,translate(x,y),rotate(a),beginPath8,arc(0,0,5,0,T),fillStyle='red',fill8,beginPath8,moveTo(0,0),lineTo(10,0),strokeStyle='blue',stroke8,restore8},n:_7(({c,n,s,e,w}=G),c8.concat(n8,s8,e8,w8)[r](b7(d=b.x-x,f=b.y-y,400>d*d+f*f&&z(z(k(f,d)-a)/P-1)>1/6))),s8{q=(j=t.n8).length,v=t.v8||0,l=t.l8||0,f=t.f8||0,a=t.a=(t.a+v/3+l/10+f/50)%T,t.x=(x+u(a)+S)%S,t.y=(y+g(a)+S)%S},v:_7([d,f]=j[r](b7225>(b.x-x)**2+(b.y-y)**2)[p='reduce'](([d,f],b)7[x+d-b.x,y+f-b.y],[0,0]),d||f?M(k(f,d)-a):0),l:_7j[i](b7M(b.a-a))[p]((a,x)7a+x,0)/q,f:_7([d,f]=j[p](([d,f],b)7[d+b.x,f+b.y],[-x*q,-y*q]),d||f?M(k(f,d)-a):0)},S=C.width=C.height=50*L,A=Array(L).fill().map(_7new B),R=_7{D.clearRect(0,0,S,S),A[i='map'](b79=b).d8),A[i](b79=t=b).s8),F--&&setTimeout(R,10)},R8}".replace(/[789]/g,m=>['=>','()','({a,x,y}'][m-7]))(+b.value)(Infinity);b.remove()}
input{display:block}canvas{border:1px solid}
<input id=b><canvas id=c>

The boids don't seem to interact when I run the snippet

@JoKing it should be fixed now

The problem was because the babel minifier shadowed a global variable in one function with a parameter name, and the implicit typecast to a number didn't throw an error, so the function just failed silently and never detected any neighbors.

I'll try to make an interactive demo tomorrow night but I've run out of steam for tonight.

Just a note: where it reads t.a+v+l/10+f/50, if you change that to t.a+v/3+l/10+f/50, it produces somewhat more interesting behavior, but the current program is smaller and still to spec.

Hmm. Would you mind adding another snippet that contains an input field taking the number of boids? (I can do it if you don't mind)

@ASCII-only done

@PatrickRoberts hmm. i think it would be better with a constant size? i kinda just wanted to see it running with, say, 100 boids :P

@ASCII-only The output animation should be at least 5 boid-radii by 5 boid-radii, times half the number of boids. So, the minimum size for 2 boids would be 10 boid-radii by 10 boid-radii, the minimum for 3 boids would be 15 boid-radii by 15 boid-radii, et cetera.

@PatrickRoberts :/ (i kinda wanted to be able to see all of it (maybe canvas{height:100vh}), especially since 1. it's not like it's the submission code/a serious contender and 2. this is currently the only submission that can be run directly here)