44
\$\begingroup\$

An uninteresting number (which I totally didn't make up only for this challenge) is created like this:

  1. Take a positive integer N
  2. Create a new number O by adding the digits of N at the end of N
  3. The final uninteresting number is O*N

For example for N=12:

  1. O = 1212
  2. O*N = 1212 * 12
  3. Final number is 14544

Input

A positive integer N (N > 0) or your language's equivalent. You don't have to catch incorrect input.

Output

The corresponding uninteresting number.

Test cases

  1 -> 11
  2 -> 44
  3 -> 99
 10 -> 10100
174 -> 30306276

Scoring

Shortest Code in Bytes wins.

\$\endgroup\$
19
  • 11
    \$\begingroup\$ There must be a relevant OEIS entry... \$\endgroup\$
    – MKII
    Jul 7, 2016 at 10:52
  • 2
    \$\begingroup\$ @Seims It was a joke, based on the "uninsteresting" name \$\endgroup\$
    – MKII
    Jul 7, 2016 at 11:10
  • 11
    \$\begingroup\$ @MKII my bad, i don't speak joke \$\endgroup\$
    – Seims
    Jul 7, 2016 at 11:13
  • 1
    \$\begingroup\$ Is taking the number as a string argument bending the rules a bit too much? \$\endgroup\$ Jul 7, 2016 at 11:39
  • 1
    \$\begingroup\$ Go ahead, bend the rules! :P \$\endgroup\$
    – Seims
    Jul 7, 2016 at 11:44

77 Answers 77

4
\$\begingroup\$

R, 28 27 bytes

Edit: -1 byte thanks to @Dominic van Essen.

(10^nchar(z<-scan())*z+z)*z

Try it online!

Shorter than bouncyball's solution with different approach.

Explanation

z=scan() gets input
10^nchar(z))*z+z is concatenation of the two copies of the number
*z at the end to get the result.

\$\endgroup\$
3
  • \$\begingroup\$ 27 bytes... but it took 6 years to save the last byte! \$\endgroup\$ Apr 9 at 8:59
  • 1
    \$\begingroup\$ @DominicvanEssen, thanks, that's some archaeological work! (it was my second R answer on this site...) Actually inlining the scan does the job, so I'll stick to the old formula. \$\endgroup\$
    – pajonk
    Apr 9 at 12:45
  • \$\begingroup\$ Sometimes one of these old questions comes to the top of the 'Home' page, and I give it a go, and only afterwards check whether there's already a similar answer... \$\endgroup\$ Apr 9 at 15:20
3
\$\begingroup\$

Perl 6, 11 bytes

{"$_$_"*$_}
#! /usr/bin/env perl6
use v6.c;
use Test;

my @tests = (
  12 => 14544,
   1 => 11,
   2 => 44,
   3 => 99,
  10 => 10100,
 174 => 30306276,
);

plan +@tests;

my &uninteresting = {"$_$_"*$_}

for @tests -> $_ ( :key($input), :value($expected) ) {
  is uninteresting($input), $expected, .gist
}
1..6
ok 1 - 12 => 14544
ok 2 - 1 => 11
ok 3 - 2 => 44
ok 4 - 3 => 99
ok 5 - 10 => 10100
ok 6 - 174 => 30306276
\$\endgroup\$
3
\$\begingroup\$

Haskell, 22

I'm new to Haskell (and functional programming), so expert criticism is welcome.

f n=(read$n++n)*read n

main=do
  putStrLn $ show $ f "1"
  putStrLn $ show $ f "2"
  putStrLn $ show $ f "3"
  putStrLn $ show $ f "10"
  putStrLn $ show $ f "174"
\$\endgroup\$
2
  • \$\begingroup\$ You technically didn't fulfill the requirements. It says to use numbers as input, you used strings. I had the same idea before I realized that. ;) \$\endgroup\$ Jul 10, 2016 at 9:26
  • \$\begingroup\$ @AplusKminus The asker allows string as input \$\endgroup\$
    – Jo King
    Apr 22 at 13:15
3
\$\begingroup\$

Curry (PAKCS), 26 bytes

f n=n*read(show n++show n)

Try it online!

-1 from ovs

\$\endgroup\$
0
2
\$\begingroup\$

Clojure, 22 bytes

#(*(bigint(str % %))%)

Anonymous function which concatenates string representation of its argument covnerts it to BigInteger and multiplies by the argument. The output is in format 11N (N signifies its a bigint), if there should be no N at the end then we can use

#(*(read-string(str % %))%)

for 27 bytes.

See it online: https://ideone.com/QqYfpo

\$\endgroup\$
2
\$\begingroup\$

SpecBAS - 30 bytes

1 INPUT n$: ?VAL(n$+n$)*VAL n$

My shortest SpecBAS answer yet :-)

\$\endgroup\$
2
\$\begingroup\$

Python, 51 Bytes

from math import*
g=lambda x:x*(x+x*10**(1+int(log10(x))))

Here's the mathematical way to do it (friend of mine found the formula). I guess using it wouldn't produce an answer shorter than 3 bytes. :)

\$\endgroup\$
4
  • \$\begingroup\$ I was a bout to post an answer using a similar approach... by the way it is python not phyton. \$\endgroup\$
    – Leaky Nun
    Jul 7, 2016 at 12:52
  • \$\begingroup\$ @LeakyNun Code doesn't work either. Will look into it. \$\endgroup\$
    – Seims
    Jul 7, 2016 at 12:53
  • 1
    \$\begingroup\$ Add from math import* to the beginning of your submission, and you can remove g= from the byte count. \$\endgroup\$
    – Leaky Nun
    Jul 7, 2016 at 12:55
  • 1
    \$\begingroup\$ Changing from 10**(1+int(log10(x))) to 10**-~int(log10(x)) saves you bytes on parentheses. Changing from x*(x+x*10**... to x*x*-~10**... also saves bytes on parentheses. \$\endgroup\$
    – Sherlock9
    Jul 7, 2016 at 18:14
2
\$\begingroup\$

Japt, 4 bytes

U²*U

² translates to p2, which was (seemingly) designed to shorten the syntax for raising the number to the power of two. For strings, p function is repeating, not exponentiating, but the shortcut still works :) As you may've understood, takes the input as string.

Demo

\$\endgroup\$
1
  • \$\begingroup\$ This can now be 2 bytes, for the win! \$\endgroup\$
    – Shaggy
    Feb 2, 2018 at 17:49
2
\$\begingroup\$

Hexagony, 23 bytes

?'=1*'\|@}*\=+=':<\}0.!

Embiggened:

    ? ' = 1
   * ' \ | @
  } * \ = + =
 ' : < \ } 0 .
  ! . . . . .
   . . . . .
    . . . .

Try it online!

As Hexagony doesn't have a concatenation function, it has to be done through multiplying the input by the appropriate factor of 10, then adding the input to it again. For example, CONCAT(12,12) can be implemented as (12 * 100) + 12.

\$\endgroup\$
2
\$\begingroup\$

><>, 22 Bytes

a:{:@)8$.$a*!
::{*+*n;

Input is expected to be on the stack already. If that's not okay, then I'll probably mark this answer non-competing. Reading numeric inputs in ><> is a real pain. Try it online

On a side note, this is my first post after a long period of inactivity; I'm glad to be able to contribute to this wonderful community again.


Explanation

I'm using the term "padding" to refer to a "variable"* that the input will be multiplied so that its digits may be duplicated.

e.g. if 12 is our input N and 1212 is the number O, then the padding used would be 100 since 12*100 + 12 = 1212.

*><> doesn't exactly have those, aside from the register (&), but you can effectively have them by manipulating the stack if that makes sense

Line 1

a:{:@)8$.$a*!
a              push initial padding value (10)
 :{:           duplicate padding, bring input to front of stack and duplicate it
    @          manipulate stack so that it looks like [padding,input,padding,input]
     )         pop input and padding from top and push the result of (padding > input)
      8$.      push 8 and swap with the result, then jump to that location
         $     swap top so it looks like [input,padding]
          a*!  multiply padding by 10, skip pushing 10 at beginning

Line 2

::{*+*n;
::        duplicate input twice -> [padding,input,input,input]
  {       bring padding from bottom -> [input,input,input,padding]
   *      multiply first input copy by padding
    +     add it to the second copy
     *    multiply by the final copy
      n   print result
       ;  terminate

Here's a hopefully more readable explanation.

Line 1

a:{:@)8$.$a*!

The program initializes the stack so that it contains [input,10] (10 is the initial padding value). It then checks to see if the padding is greater than the input. The result of this (1 if true, 0 if false) is pushed onto the top of the stack. The pointer then jumps to the location (8,padding>input), which means that if the padding is greater than the input, the program goes to the second line and if it isn't it continues along on the first line. If it continues on the first line, it'll multiply the padding by 10 and repeat the process.

Line 2

::{*+*n;

On Line 2, the program duplicates the input twice and then evaluates the expression input*((input*padding) + input) and prints it.

\$\endgroup\$
2
\$\begingroup\$

Brachylog (2), 4 bytes

j:?×

Try it online!

Explanation

j:?×
j     Append the input to itself
 : ×  then multiply by
  ?   the original input
\$\endgroup\$
2
\$\begingroup\$

Wren, 41 bytes

Fn.new{|n|Num.fromString(n.toString*2)*n}

Try it online!

Explanation

Fn.new{|n|                              } // New function with the parameter n
                         n.toString       // Convert the number to a string
                                   *2     // Duplicate this value
          Num.fromString(            )    // Convert to a number
                                      *n  // Multiply it with the original number
\$\endgroup\$
2
\$\begingroup\$

Google Sheets, 11 bytes

=(A1&A1)*A1
\$\endgroup\$
1
\$\begingroup\$

Fishing, 26 bytes

v+CCCCCCCCCC
  Icc{n{n}mP

Explained column-by column

  1. Set casting direction downwards
  2. Increase casting length to 1
  3. Read input to first cell on tape
  4. Concatenate first and second (empty) cell on tape and add to end of tape
  5. Concatenate first and second (now containing input) cell and add to end of tape
  6. Move to second cell (containing input)
  7. Cast cell content to number
  8. Move to third cell (containing input twice)
  9. Cast cell content to number
  10. Move to second cell.
  11. Set content of second cell to second cell multiplied by third cell
  12. Print second cell content
\$\endgroup\$
1
\$\begingroup\$

Actually, 7 bytes

;;+k♂≈π

Try it online!

Explanation:

;;+k♂≈π
;;       duplicate input twice (3 total copies)
  +      concatenate two of the copies
   k♂≈   push to a list, convert all elements to ints
      π  product
\$\endgroup\$
1
\$\begingroup\$

R 34 bytes

y=scan();as.numeric(paste0(y,y))*y
\$\endgroup\$
1
  • 1
    \$\begingroup\$ I think the numeric approach is faster ;-) Nice answer however, I didn't know paste converts numbers to strings implicitly. \$\endgroup\$
    – pajonk
    Jul 7, 2016 at 17:28
1
\$\begingroup\$

hashmap, 8 bytes

i&&+d#d*

Explanation:

i&&+d#d*
i&&      Triple the input
   +     Add them together
    d#d  Convert both into a number
       * Multiply them
\$\endgroup\$
1
\$\begingroup\$

Forth, 63 bytes

This feels horribly inefficient...

: f dup 2dup 10e s>f flog 1e f+ floor f** s>f f* s>f f+ f>s * ;

Try it online

Note that this works on Ideone (gforth-0.7.2), but not repl (JS-Forth), since repl doesn't support pushing numbers to the float stack or the flog and floor operations.

Explanation

: f                     ( define a word/function named 'f'              )
dup 2dup                ( duplicate 3 times                             )
10e                     ( push 10 to float stack, not used for log{n}   )
s>f flog                ( move # to f-stack and get its log-10          )
1e f+ floor             ( increment the above result by 1 and floor     )
f**                     ( use the 10 pushed earlier, 10**log{n}         )
s>f f* s>f f+           ( mul by n, then add n                          )
f>s * ;                 ( to regular stack, mul by n, end definition    )
\$\endgroup\$
1
\$\begingroup\$

Mathematica, 24 bytes

a=FromDigits;a[#<>#]a@#&

Anonymous function, takes a string representing a number as input and generates its corresponding uninteresting number.

\$\endgroup\$
1
\$\begingroup\$

Ruby, 22 Bytes

->n{(n*2).to_i*n.to_i}

Takes input as a string. Double the string, and then multiply it by the input, both as integers

\$\endgroup\$
1
\$\begingroup\$

RProgN, 9 Bytes

] ] . * _

Explanation

] ]     # Push two copies of the top of the stack, which implicitly contains the input.
.       # Concatenate the top two values of the stack, and push it to the top of the stack.
*       # Multiply the top two values of the stack
_       # Floor the top of the stack, to make it pretty.
        # Implicitly print

Yay for Stack Based Loosly typed languages. The main downside of RProgN is that (Currently) whitespace is needed for a function to run (Aside from the last command). Which wastefully adds four whole bytes.

\$\endgroup\$
1
\$\begingroup\$

Coffeescript, 36 34 19 bytes

Thanks to @Fawful for shaving off 2 bytes, and to @joeytwiddle for some more

a=(n)->(""+n+n|0)*n

Neater script and explanation:

a=(n)->               # Creates a new function
       (""+n+n|0)     # Concatenate as strings, then convert back to integer 
                 *n   # then multiplies it by n
\$\endgroup\$
3
  • \$\begingroup\$ parseInt((""+n)+n)? \$\endgroup\$
    – Steven H.
    Jul 7, 2016 at 21:35
  • \$\begingroup\$ You can use Number() instead of parseInt(). Or even better you can use |0. Also there is no need for return. We can reach 19 in CS, 17 in ES6. ;) \$\endgroup\$ Oct 3, 2016 at 3:15
  • \$\begingroup\$ @joeytwiddle Ah yeah... I posted this ages ago, so... \$\endgroup\$
    – clismique
    Oct 3, 2016 at 3:22
1
\$\begingroup\$

TI-Basic, 9 bytes

Input should be passed as string

expr(Ans)expr(Ans+Ans
\$\endgroup\$
1
\$\begingroup\$

k, 14 bytes:

{x*"J"$s,s:$x}

Explanation:

x              // implicit input
  $            // string the input
    s:         // set variable s to.. 
      s,s      // append s to s
        "J"$   // cast to 64bit int
           x*  // multiply by original input, return is implicit
\$\endgroup\$
1
\$\begingroup\$

Brain-Flak, 226 bytes

((({}))){(({})(<><>))<>((()())(({}){}){}){(({})){({}[()])<>}{}}{}<>([{}()]{})(<>{}(<>))<>((()())(({}){}){})([()]{()<(({})){({}[()])<>}{}>}{}<><{}{}>)}{}<>([]){{}({}<>(({}){})(({}){}){})<>([])}{}<>({}<>)({<({}[()])><>({})<>}{})

Try it online!

The main idea here is to decompose N into its digits, putting the digits on the off-stack; then we can calculate O by multiplying N by 10, adding a digit from the off-stack, and repeating until the off-stack is empty. Multiplying that result by another copy of N gives the final answer. I borrowed pretty heavily from the arithmetic algorithms here, tweaking them a bit to fit into this particular program in fewer bytes.

Make two more copies of the input
((({})))
The third copy will be decomposed into its digits
Loop while the partially decomposed number is not zero:
{
 Push a zero and a copy of the number
 (({})(<><>))
 Switch to the off-stack and push 10
 <>((()())(({}){}){})
 Modulo algorithm: we end up on the off-stack with number % 10 on top
 {(({})){({}[()])<>}{}}{}<>([{}()]{})
 Push a zero and the top of the main stack to the off-stack, popping the main stack
 (<>{}(<>))
 Switch to the main stack and push 10
 <>((()())(({}){}){})
 Division algorithm: we end up on the main stack with number / 10 on top, and without any
 junk left on the off-stack
 ([()]{()<(({})){({}[()])<>}{}>}{}<><{}{}>)
}
Pop the leftover zero, switch to off-stack, and push stack height
{}<>([])
Loop while stack height is not zero:
{
 Discard stack height
 {}
 Add top of off-stack to 10 times top of main stack and push to main stack
 ({}<>(({}){})(({}){}){})
 Switch back to off-stack and push stack height
 <>([])
}
Discard stack height and switch to main stack
{}<>
Multiplication algorithm: we end up with O*N on the stack, which the program outputs
({}<>)({<({}[()])><>({})<>}{})
\$\endgroup\$
1
\$\begingroup\$

Keg, 7 bytes

::⑫++ℤ*

Try it online!

Simply duplicate the input twice, push an empty string, add the input to that string, convert to integer and multiply by original input

\$\endgroup\$
1
\$\begingroup\$

GolfScript, 7 bytes

.2*~\~*

Try it online!

Explanation:

.2*       duplicate, concatenate duplicate to self
   ~\~    convert both strings to ints
      *   multiply
\$\endgroup\$
1
\$\begingroup\$

Your mom, 6 bytes

ð::+*

The name of this language is a idea from mbomb007...

Explanation:

ð     Read a string from stdin
 ::   : is the duplicate operator, so the input is duplicated 2 times
   +*
      Implicit output
\$\endgroup\$
1
\$\begingroup\$

Vyxal, 2 bytes

J*

Try it Online!

\$\endgroup\$
1
  • \$\begingroup\$ Bruh beat me to it by like one sec \$\endgroup\$
    – Steffan
    Apr 9 at 1:36
1
\$\begingroup\$

Desmos, 28 bytes

f(n)=10^{floor(logn)}10nn+nn

Try It On Desmos!

Try It On Desmos! - Prettified

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.