Never tell me the odds

05AB1E, 11 10 bytes

Code:

\>GN¹¢ÈiN,

Explanation:

\           # Pop input, which saves the first input into ¹
 >          # Increment on second input
  G         # For N in range(1, input + 1)
   N        # Push N
    ¹       # Push the first input from the input register
     ¢      # Count the number of occurences of the digit in N
      È     # Is even?
       iN,  # If true, print N with a newline

Try it online

Uses CP-1252 encoding.


Haskell, 69 63 52 50 bytes

d#n=[i|i<-[1..n],even$sum[1|x<-show i,read[x]==d]]

Straightforwared solution for my first ever post here. It uses show to count the number of d's. I explicitly did not use Char as input for d, which would have saved 12 6 (after Damien's edit) bytes.

EDIT: 11 bytes less thanks to Damien! EDIT 2: another 2 bytes less thanks to nimi!


Befunge, 1080 945 bytes

vd>"000">" "v
&0      ^              p21-1+*68<
62            >        v
8           >-|        >12g68*-:|
*             >11g1+11p^        $
+                      v  <
5                         |%2g11<
5                      v.:<          
+         v            <        
0         >268*+12p68*11p"000"40p50p60pv
p
           v                             -1<
             v-g01p06+1g06<
>&         >:>:10g1-`     |            >:0`|
             v            <                @
             v-+55p05+1g05<      
             >:54+`       |
   v               p04+g04<
  ^          <                <      <
   >60g68*-0`|      >50g68*-0`|
             >" "60p^         >" "50p^

The score is given that we count the entire square, including newlines, which makes sense. You can copy paste the code into the interpeter. Provide two inputs, first d and then n. This solution does not work for values larger than n > 999.

This will obviously not be a contender for the grand prize, but I've been wanting to implement a codegolf in Befunge for a while now, so I decided to just do it. I figure this will not be even close to an optimal Befunge solution, as it is the first actual thing I've done in Befunge. So, hints are welcome, if you need clarification or more information, please let me know in the comments.

Attempt at explanation:

In the first column downward we read an integer from the input, add 48 (6*8, you'll see this more often) to it to convert it to the corresponding ASCII value and puts it to (10, 0).

& - read input

68*+ - add 48

55+0p - put the value at (10, 0)

Note that the d at (1, 0) is just an easy way to get the number 100 on the stack.

After that, we go east and read another integer and head in to what I call the ASCIIfier. This turns the current number into a series of ASCII characters. The ASCIIfier is the rectangular piece from (13, 12) to (26, 17). It consists of two loops, first counting the hunderds and than the tens and putting them into the three digits at (6, 0) and (5, 0). After that the last digit is put into (4, 0). So the numbers is actually in reverse.

v-g01p06+1g06< - increment the "hunderds counter" located at (0, 6) and decrease current value by 100
>:10g1-`     | - ASCIIfier entry; check if the current value is > 99, if so, go up, else go down
v            < - go to start of "tens counter"
v-+55p05+1g05< - increment the "tens counter" located at (0, 5) and decrease current value by 10
>:54+`       | - check if current value is > 9, if so, go up, else go down
      p04+g04< - put the final value into the "singles counter" located at (0, 4)

After putting the current integer into a series of ASCII characters, we go a bit more south to remove prepended zeroes. Thus, afterwards, what are initially the three zeroes at the top, will be the current number, without prepended zeroes.

Then we go back up, all the way to the North, where we put the three digits on the stack. We iterate over the three digits in the top loop, each time incrementing the counter located at (1, 1) if the current digit corresponds with the input d

When that is done we go and check to see if the counter that located at (1, 1) is odd or even. If it is even, we output the current number and move on to the big outer loop to decrement the current value and start over again.