Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Pyth , 16 bytes

Pyth , 16 bytes

#Pyth , 18 bytes

Pyth , 18 bytes

###How it works

How it works

#Pyth , 16 bytes

#Pyth , 18 bytes

###How it works

Pyth , 16 bytes

Pyth , 18 bytes

How it works

added 16 characters in body
Source Link
Mr. Xcoder
  • 42.9k
  • 9
  • 87
  • 221

Takes input as a String. Try it here! (Alternative: .WtH`*s.-ZeSZseS)

###How it works (18-byter)

16-byter


.WtH`*s.-ZKeSZsK ~ Full program.
.W ~ Functional while. While A(value) is truthy, value = B(value).
 ~ The final value is returned.
 tH ~ A, condition: Is value[1:] truthy? Is the length ≥ 2?
 `*s.-ZKeSZsK ~ B, setter.
 .- ~ Bagwise subtraction, used for removing the highest digit, with...
 Z ~ The current value Z, and...
 KeSZ ~ The highest digit of Z (as a String). Also assigns to a variable K.
 s ~ Casted to an integer.
 * ~ Multiplied by...
 sK ~ The highest digit.
 ` ~ Convert to a String.

18-byter


.WgHT*s.-`ZKeS`ZsK ~ Full program.
.W ~ Functional while. While A(value) is truthy, value = B(value).
 ~ The final value is returned.
 gHT ~ A, condition: is value (H) ≥ 10?
 *s.-`ZKeS`ZsK ~ B, setter.
 .- ~ Bagwise substraction (used for removing first occurrence).
 `Z ~ The string representation of Z.
 KeS`Z ~ And the highest (lexicographically) character of Z (highest digit).
 It also assigns it to a variable called K.
 s ~ Cast to integer.
 * ~ Multiply by...
 sK ~ K casted to int.

Being that close to Jelly at such type of challenge is very good for Pyth IMO :-)

Takes input as a String. Try it here!

###How it works (18-byter)

.WgHT*s.-`ZKeS`ZsK ~ Full program.
.W ~ Functional while. While A(value) is truthy, value = B(value).
 gHT ~ A, condition: is value (H) ≥ 10?
 *s.-`ZKeS`ZsK ~ B, setter.
 .- ~ Bagwise substraction (used for removing first occurrence).
 `Z ~ The string representation of Z.
 KeS`Z ~ And the highest (lexicographically) character of Z (highest digit).
 It also assigns it to a variable called K.
 s ~ Cast to integer.
 * ~ Multiply by...
 sK ~ K casted to int.

Takes input as a String. Try it here! (Alternative: .WtH`*s.-ZeSZseS)

###How it works

16-byter


.WtH`*s.-ZKeSZsK ~ Full program.
.W ~ Functional while. While A(value) is truthy, value = B(value).
 ~ The final value is returned.
 tH ~ A, condition: Is value[1:] truthy? Is the length ≥ 2?
 `*s.-ZKeSZsK ~ B, setter.
 .- ~ Bagwise subtraction, used for removing the highest digit, with...
 Z ~ The current value Z, and...
 KeSZ ~ The highest digit of Z (as a String). Also assigns to a variable K.
 s ~ Casted to an integer.
 * ~ Multiplied by...
 sK ~ The highest digit.
 ` ~ Convert to a String.

18-byter


.WgHT*s.-`ZKeS`ZsK ~ Full program.
.W ~ Functional while. While A(value) is truthy, value = B(value).
 ~ The final value is returned.
 gHT ~ A, condition: is value (H) ≥ 10?
 *s.-`ZKeS`ZsK ~ B, setter.
 .- ~ Bagwise substraction (used for removing first occurrence).
 `Z ~ The string representation of Z.
 KeS`Z ~ And the highest (lexicographically) character of Z (highest digit).
 It also assigns it to a variable called K.
 s ~ Cast to integer.
 * ~ Multiply by...
 sK ~ K casted to int.

Being that close to Jelly at such type of challenge is very good for Pyth IMO :-)

added 16 characters in body
Source Link
Mr. Xcoder
  • 42.9k
  • 9
  • 87
  • 221

#Pyth, 1716 bytes

.WtlH`*sWtH`*s.-ZKeSZsK

Takes input as a String. Try it here! Try it here!

#Pyth, 18 bytes

.WgHT*s.-`ZKeS`ZsK

Takes input as an integer. Try it here!

##How###How it works (will be updated18-byter)

.WgHT*s.DJ`ZxJKeSJsK-`ZKeS`ZsK ~ Full program.
.W ~ Functional Whilewhile. While A(value) is truthy, value = B(value).
 gHT ~ A, the condition. The: currentis value (H) ≥ 10.?
 *s.DJ`ZxJKeSJsK-`ZKeS`ZsK ~ B, the setter.
 .- J`Z ~ The stringBagwise representationsubstraction of(used thefor currentremoving value,first Zoccurrence).
 xJ`Z ~ The index in the string representation of Z of...
 KeSJKeS`Z ~ TheAnd the highest digit(lexicographically) character of Z as a(highest Stringdigit).
 .D ~ Delete fromIt Zalso assigns it to a variable called K.
 s ~ Cast to intinteger.
 * ~ Multiply by...
 sK ~ By the highest digit of ZK ascasted anto integerint.

#Pyth, 17 bytes

.WtlH`*s.-ZKeSZsK

Takes input as a String. Try it here!

#Pyth, 18 bytes

.WgHT*s.-`ZKeS`ZsK

Takes input as an integer. Try it here!

##How it works (will be updated)

.WgHT*s.DJ`ZxJKeSJsK ~ Full program.
.W ~ Functional While. While A(value) is truthy, value = B(value).
 gHT ~ A, the condition. The current value ≥ 10.
 *s.DJ`ZxJKeSJsK ~ B, the setter.
 J`Z ~ The string representation of the current value, Z.
 xJ ~ The index in the string representation of Z of...
 KeSJ ~ The highest digit of Z as a String.
 .D ~ Delete from Z.
 s ~ Cast to int.
 * ~ Multiply.
 sK ~ By the highest digit of Z as an integer.

#Pyth, 16 bytes

.WtH`*s.-ZKeSZsK

Takes input as a String. Try it here!

#Pyth, 18 bytes

.WgHT*s.-`ZKeS`ZsK

Takes input as an integer. Try it here!

###How it works (18-byter)

.WgHT*s.-`ZKeS`ZsK ~ Full program.
.W ~ Functional while. While A(value) is truthy, value = B(value).
 gHT ~ A, condition: is value (H) ≥ 10?
 *s.-`ZKeS`ZsK ~ B, setter.
 .- ~ Bagwise substraction (used for removing first occurrence).
 `Z ~ The string representation of Z.
 KeS`Z ~ And the highest (lexicographically) character of Z (highest digit).
 It also assigns it to a variable called K.
 s ~ Cast to integer.
 * ~ Multiply by...
 sK ~ K casted to int.
added 16 characters in body
Source Link
Mr. Xcoder
  • 42.9k
  • 9
  • 87
  • 221
Loading
deleted 17 characters in body
Source Link
Mr. Xcoder
  • 42.9k
  • 9
  • 87
  • 221
Loading
Source Link
Mr. Xcoder
  • 42.9k
  • 9
  • 87
  • 221
Loading

AltStyle によって変換されたページ (->オリジナル) /