Skip to main content
Commonmark migration
Source Link

#MathGolf, 9 bytes

MathGolf, 9 bytes

0ô+_▒╙2<▼ 

Try it online. (Test cases n=9 and n=18 are excluded, since they time out.)

Explanation:

0 # Start with 0 ▼ # Do-while false with pop, ô # using the following 6 commands: + # Add the (implicit) input-integer to the current value _ # Duplicate it ▒ # Convert it to a list of digits ╙ # Pop and push the maximum digit of this list 2< # And check if this max digit is smaller than 2 (thus 0 or 1) # (after the do-while, the entire stack joined together is output implicitly) 

#MathGolf, 9 bytes

0ô+_▒╙2<▼ 

Try it online. (Test cases n=9 and n=18 are excluded, since they time out.)

Explanation:

0 # Start with 0 ▼ # Do-while false with pop, ô # using the following 6 commands: + # Add the (implicit) input-integer to the current value _ # Duplicate it ▒ # Convert it to a list of digits ╙ # Pop and push the maximum digit of this list 2< # And check if this max digit is smaller than 2 (thus 0 or 1) # (after the do-while, the entire stack joined together is output implicitly) 

MathGolf, 9 bytes

0ô+_▒╙2<▼ 

Try it online. (Test cases n=9 and n=18 are excluded, since they time out.)

Explanation:

0 # Start with 0 ▼ # Do-while false with pop, ô # using the following 6 commands: + # Add the (implicit) input-integer to the current value _ # Duplicate it ▒ # Convert it to a list of digits ╙ # Pop and push the maximum digit of this list 2< # And check if this max digit is smaller than 2 (thus 0 or 1) # (after the do-while, the entire stack joined together is output implicitly) 
deleted 10 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

#MathGolf, 10 9 bytes

0ô+_▒╙2<▼ 

Try it online. (Test cases n=9 and n=18 are excluded, since they time out.)

Explanation:

0 # Start with 0 ▼ # Do-while false with pop, ô # using the following 6 commands: + # Add the (implicit) input-integer to the current value _ # Duplicate it ▒ # Convert it to a list of digits ╙ # Pop and push the maximum digit of this list 2< # And check if this max digit is smaller than 2 (thus 0 or 1) # (after the do-while, the entire stack joined together is output implicitly) 

#MathGolf, 10 9 bytes

0ô+_▒╙2<▼ 

Try it online. (Test cases n=9 and n=18 are excluded, since they time out.)

Explanation:

0 # Start with 0 ▼ # Do-while false with pop, ô # using the following 6 commands: + # Add the (implicit) input-integer to the current value _ # Duplicate it ▒ # Convert it to a list of digits ╙ # Pop and push the maximum digit of this list 2< # And check if this max digit is smaller than 2 (thus 0 or 1) # (after the do-while, the entire stack joined together is output implicitly) 

#MathGolf, 9 bytes

0ô+_▒╙2<▼ 

Try it online. (Test cases n=9 and n=18 are excluded, since they time out.)

Explanation:

0 # Start with 0 ▼ # Do-while false with pop, ô # using the following 6 commands: + # Add the (implicit) input-integer to the current value _ # Duplicate it ▒ # Convert it to a list of digits ╙ # Pop and push the maximum digit of this list 2< # And check if this max digit is smaller than 2 (thus 0 or 1) # (after the do-while, the entire stack joined together is output implicitly) 
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

#MathGolf, 10 9 bytes

0ô+_▒╙2<▼ 

Try it online. (Test cases n=9 and n=18 are excluded, since they time out.)

Explanation:

0 # Start with 0 ▼ # Do-while false with pop, ô # using the following 6 commands: + # Add the (implicit) input-integer to the current value _ # Duplicate it ▒ # Convert it to a list of digits ╙ # Pop and push the maximum digit of this list 2< # And check if this max digit is smaller than 2 (thus 0 or 1) # (after the do-while, the entire stack joined together is output implicitly)