Skip to main content
Golfed 15 bytes
Source Link
DLosc
  • 40.7k
  • 6
  • 87
  • 142

Acc!!, 6060 45 bytes

Count i while 8-i { _+(N-48)*(33*N+N+3*N+N+3*N+N+3*N+N-i%2*2) }8 Write 1/(1+_%10)+48 

Try it online!Try it online!

Explanation

The Count i loop runs 8 times. At each iteration, weWe read a digit and get its value (N-48) and computeeight digits, multiplying the multiplier asappropriate ones by 3 when i, and add. It's not quite that simple, because what we're actually reading is evenASCII codes, 1 when iand so each digit has 48 added to it. Thus, the resulting sum is odd (3-i%2*2)too big by 3484 + 48*4 = 768. We add their productonly care about the 1's digit, so subtracting 8 is sufficient to get the accumulator (_)correct result.

Once the loop finishes, weWe want to print 1 if the accumulator mod 10 is 0, and 0 otherwise. Acc!! doesn't have comparison operators, so we have to use integer division:

_%10 0 1 9 1+_%10 1 2 10 1/(1+_%10) 1 0 0 

Then we add 48 to get an ASCII value and Write it.


Original 60-byte solution with a loop:

Count i while 8-i { _+(N-48)*(3-i%2*2) } Write 1/(1+_%10)+48 

Acc!!, 60 bytes

Count i while 8-i { _+(N-48)*(3-i%2*2) } Write 1/(1+_%10)+48 

Try it online!

Explanation

The Count i loop runs 8 times. At each iteration, we read a digit and get its value (N-48) and compute the multiplier as 3 when i is even, 1 when i is odd (3-i%2*2). We add their product to the accumulator (_).

Once the loop finishes, we want to print 1 if the accumulator mod 10 is 0, and 0 otherwise. Acc!! doesn't have comparison operators, so we have to use integer division:

_%10 0 1 9 1+_%10 1 2 10 1/(1+_%10) 1 0 0 

Then we add 48 to get an ASCII value and Write it.

Acc!!, 60 45 bytes

3*N+N+3*N+N+3*N+N+3*N+N-8 Write 1/(1+_%10)+48 

Try it online!

Explanation

We read eight digits, multiplying the appropriate ones by 3, and add. It's not quite that simple, because what we're actually reading is ASCII codes, and so each digit has 48 added to it. Thus, the resulting sum is too big by 3484 + 48*4 = 768. We only care about the 1's digit, so subtracting 8 is sufficient to get the correct result.

We want to print 1 if the accumulator mod 10 is 0, and 0 otherwise. Acc!! doesn't have comparison operators, so we have to use integer division:

_%10 0 1 9 1+_%10 1 2 10 1/(1+_%10) 1 0 0 

Then we add 48 to get an ASCII value and Write it.


Original 60-byte solution with a loop:

Count i while 8-i { _+(N-48)*(3-i%2*2) } Write 1/(1+_%10)+48 
Source Link
DLosc
  • 40.7k
  • 6
  • 87
  • 142

Acc!!, 60 bytes

Count i while 8-i { _+(N-48)*(3-i%2*2) } Write 1/(1+_%10)+48 

Try it online!

Explanation

The Count i loop runs 8 times. At each iteration, we read a digit and get its value (N-48) and compute the multiplier as 3 when i is even, 1 when i is odd (3-i%2*2). We add their product to the accumulator (_).

Once the loop finishes, we want to print 1 if the accumulator mod 10 is 0, and 0 otherwise. Acc!! doesn't have comparison operators, so we have to use integer division:

_%10 0 1 9 1+_%10 1 2 10 1/(1+_%10) 1 0 0 

Then we add 48 to get an ASCII value and Write it.