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 , 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.

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;}

• 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 Jan 26 '18 at 17:01
• @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 Jan 26 '18 at 17:06
• @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. – Weijun Zhou Jan 26 '18 at 17:10
• @WeijunZhou I'd also suggest making the input formats for start, end and elim more lenient. – Erik the Outgolfer Jan 26 '18 at 17:17
• 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). – Jonathan Allan Jan 26 '18 at 17:27

Emojicode, 141 116 bytes

thanks to @NieDzejkob for 25 bytes!

🍇a🚂b🚂c🚂d🚂🔂i⏩c➕1d🍇🍊🎊❎😛0🚮i b☁️🔍🔡i a🔡b a🍇😀🔡i 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 ಠ_ಠ – Rod Jan 26 '18 at 18:13
• You can just post a closure, which is the emojicode equivalent of a lambda. This should save you some bytes. – NieDzejkob Jan 26 '18 at 18:17

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⁵ċÐḟ⁶...) – Erik the Outgolfer Jan 26 '18 at 17:45
• Ah yeah, never used the sixth arg! – Jonathan Allan Jan 26 '18 at 17:49
• As usual, would you mind expanding it and elaborating how it works? – Weijun Zhou Jan 26 '18 at 17:51
• An alternative for ọÐḟ could be %Ðf – Mr. Xcoder Jan 26 '18 at 17:59

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. – Brad Gilbert b2gills Jan 27 '18 at 17:55

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.

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. – Weijun Zhou Jan 27 '18 at 18:55

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? – Weijun Zhou Jan 27 '18 at 9:27
• @WeijunZhou: Updated. – Shaggy Jan 28 '18 at 11:22
• Thank you very much. You can update the "explanation" part of the other answer whenever you like to. No hurry. – Weijun Zhou Jan 28 '18 at 11:25
• @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. – Shaggy Jan 28 '18 at 11:27
• Yes, my bad. I edited the comment right away but you still saw the original one ... Sorry about it. – Weijun Zhou Jan 28 '18 at 11:28

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 Jan 26 '18 at 22:59
• @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. – Shaggy Jan 26 '18 at 23:07
• Fair enough, I found the spec to be super confusing. – gggg Jan 26 '18 at 23:17
• 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. – Weijun Zhou Jan 27 '18 at 9:21
• @WeijunZhou: Done – Shaggy Feb 9 '18 at 19:30

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