How to resolve the algorithm Largest int from concatenated ints step by step in the Quackery programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Largest int from concatenated ints step by step in the Quackery programming language

Table of Contents

Problem Statement

Given a set of positive integers, write a function to order the integers in such a way that the concatenation of the numbers forms the largest possible integer and return this integer. Use the following two sets of integers as tests   and   show your program output here.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Largest int from concatenated ints step by step in the Quackery programming language

Source code in the quackery programming language

[ sortwith
    [ 2dup swap join
      dip join $< ]
  [] swap witheach join ] is largest-int ( [ --> $ )

$ '1 34 3 98 9 76 45 4' nest$ largest-int echo$ cr
$ '54 546 548 60' nest$ largest-int echo$

  [ number$ dip number$ join $->n drop ] is conc   ( n n --> n )

  [ 2dup conc unrot swap conc < ]        is conc>  ( n n --> b )

  [ sortwith conc>
    $ "" swap 
    witheach [ number$ join ]
    $->n drop ]                          is task (   [ --> n )

  ' [ [ 1 34 3 98 9 76 45 4 ] 
      [ 54 546 548 60 ] ] 

  witheach [ task echo cr ]

  

You may also check:How to resolve the algorithm Search in paragraph's text step by step in the jq programming language
You may also check:How to resolve the algorithm Greatest subsequential sum step by step in the ATS programming language
You may also check:How to resolve the algorithm Loops/While step by step in the Zig programming language
You may also check:How to resolve the algorithm Repeat a string step by step in the VBA programming language
You may also check:How to resolve the algorithm Barnsley fern step by step in the Raku programming language