26
\$\begingroup\$

As the majority of nations using the Euro have the , as the decimal separator, you must use it also.

The task is to output all the values of the Euro coins and notes in ascending order. You must also put the trailing ,00 on the integer values.

0,01 0,02 0,05 0,10 0,20 0,50 1,00 2,00 5,00 10,00 20,00 50,00 100,00 200,00 500,00

I accept both output to stdout or a function returning an array/list. If output is to stdout, the acceptable separators between values are: space, tab, or newline.

There will be no accepted answer, unless I see some one I find very creative.

, so I want to know shortest answer by language.

Update:

Leading 0 zeros are not acceptable. Sorry, I should make it clear before.

Update 2:

It is also acceptable a function returning a string.

\$\endgroup\$
13

34 Answers 34

27
\$\begingroup\$

Pure Bash, 48

s={1,2,5}
eval echo 0,0$s 0,${s}0 ${s}{,0,00},00

Try it online.

\$\endgroup\$
3
  • \$\begingroup\$ Well played! You got the check mark! \$\endgroup\$
    – sergiol
    Sep 3, 2017 at 22:46
  • 4
    \$\begingroup\$ I never noticed the pattern... and I've been using the currency over 15 years.. \$\endgroup\$ Sep 4, 2017 at 8:08
  • \$\begingroup\$ @StephanBijzitter many currencies work like that. \$\endgroup\$
    – Maya
    Sep 4, 2017 at 19:48
7
\$\begingroup\$

Japt, 23 22 bytes

-1 byte thanks to @Shaggy

5Æ#}ì ®eX-2 x2 d".,"
c

Returns an array of strings.

Try it online! with the -R flag to output array items on separate lines.

\$\endgroup\$
1
  • \$\begingroup\$ Go multiline for 22 bytes. \$\endgroup\$
    – Shaggy
    Sep 2, 2017 at 22:20
7
\$\begingroup\$

Python 2, 72 bytes

print[('%.2f'%(10**(x/3-2)*(5>>~x%3))).replace(*'.,')for x in range(15)]

Try it online!

The expression 5>>~x%3 maps the non-negative integers to 1, 2, 5, 1, 2, 5

It works because 5, 2, 1 are the successive right-bitshifts of 5 (0b1010b100b1); we cycle through them backwards.

\$\endgroup\$
6
\$\begingroup\$

Charcoal, 36 bytes

EE×125⁵⁺⁺×0⁻²÷κ³ι×0÷κ³⁺⁺✂ι⁰±²¦¹,✂ι±²

Try it online! Link is to verbose version of code. Explanation:

   125                                  String `125`
  ×   ⁵                                 Repeated 5 times
 E                                      Map over each character
              ÷κ³   ÷κ³                 Integer divide loop index by 3
            ⁻²                          Subtract from 2
          ×0      ×0                    Repeat the string `0` x times
        ⁺⁺       ι                      Concatenate with the character
E                                       Map over each resulting string
                         ✂ι⁰±²¦¹        Slice off the last two digits
                                ✂ι±²    Extract the last two digits
                       ⁺⁺       ,       Concatenate with a comma
                                        Implicitly print one per line
\$\endgroup\$
6
\$\begingroup\$

SOGLOnline offline, 27 26 25 24 23 22 21 bytes

252¹5∙īυ;{⁴Ζ.,ŗP*F⁾?½

Try it Here!

The online link doesn't show trailing zeroes, but the offline version does as Javas BigDecimals are nice.

Explanation:

252¹5∙īυ;{⁴Ζ.,ŗP*F⁾?½
252¹                 push the array [2, 5, 2]
    5∙               multiply vertically by 5
      īυ;            push 0.01 below that - the main number
         {           iterate over that array - [2,5,2,2,5,2,2,5,2,2,5,2,2,5,2]
          ⁴            duplicate the main number
           Ζ.,ŗ        replace "." with ","
               P       output in a new line
                *      multiply the main number with the current item of the array
                 F⁾?   if the current array item-2 isn't 0, then
                    ½    divide by 2

TO run in the offline interpreter, download SOGLOnlines repository, go to compiler/interpreter, open any of the .pde files with Processing, then do file -> export for your OS (otherwise you can't give arguments to a Processing program :/), and then execute the compiled program with an argument to the path of the file with the code. Then, stdout will contain this.

2L¼2¹5∙īυ;{⁴Ζ.,ŗP* for 18 bytes almost works but the zero amount grows, resulting in 0,01 0,02 0,050 0,100 0,200 0,5000 1,0000 2,0000 5,00000 10,00000 20,00000 50,000000 100,000000 200,000000 500,0000000 (newlines replaced with spaces)

\$\endgroup\$
9
  • 2
    \$\begingroup\$ Output format incorrect: "You must also put the trailing ,00 on the integer values." (I imagine this is also intended to include the trailing ,0 where appropriate) \$\endgroup\$ Sep 2, 2017 at 22:39
  • \$\begingroup\$ You should fix your post according to @JonathanAllan 's observation. JonathanAllan, thanks \$\endgroup\$
    – sergiol
    Sep 2, 2017 at 23:30
  • \$\begingroup\$ @JonathanAllan: Hmmmpf, let me take your comment with a grain of salt. Post author says: "The online link doesn't show trailing zeroes, but the offline version does as Javas BigDecimals are nice.". So I have no way to check whether the script behaves well or not on the offline version. \$\endgroup\$
    – sergiol
    Sep 2, 2017 at 23:42
  • \$\begingroup\$ @sergiol Ah, I missed that text. I wonder why the online interpreter is implemented differently in this regard - dzaima...? \$\endgroup\$ Sep 2, 2017 at 23:44
  • \$\begingroup\$ I believe the online interpreter is written in JavaScript while the offline one is written in Processing. Also solutions don't have to be testable online. :P \$\endgroup\$ Sep 3, 2017 at 0:52
6
\$\begingroup\$

Java 8, 109 108 81 80 bytes

Thanks to @OlivierGrégoire for the Locale idea

x->{for(double i=.001;i<11;)System.out.printf("%.2f %.2f %.2f ",i*=10,i*2,5*i);}

Try it online!

\$\endgroup\$
5
  • \$\begingroup\$ You can save a byte by switching to an unused parameter (meta post on this): Try it online \$\endgroup\$ Sep 3, 2017 at 20:14
  • \$\begingroup\$ 100 bytes. \$\endgroup\$ Sep 4, 2017 at 10:48
  • 2
    \$\begingroup\$ 81 bytes. Works on my system because my default locale is be_FR. "Work on my system" is good enough. I can't find the meta-post linked to this, but you can use it. To simulate it, just have Locale.setDefault(Locale.FRENCH); in the non-competite part of the TIO. \$\endgroup\$ Sep 4, 2017 at 10:59
  • 1
    \$\begingroup\$ @OlivierGrégoire Here is the relevant meta-post, and you're indeed right that it is allowed. I even asked OP to verify, and he linked me to Dennis' answer with a link to this meta post. \$\endgroup\$ Sep 4, 2017 at 11:47
  • 1
    \$\begingroup\$ 80 bytes: x->{for(double i=.001;i<11;)System.out.printf("%.2f %.2f %.2f ",i*=10,i*2,5*i);} \$\endgroup\$
    – Nevay
    Sep 4, 2017 at 13:16
5
\$\begingroup\$

Bash, 38 bytes

printf %.2f\\n {1,2,5}e{-2..2}|sort -h

Requires an appropriate locale, which is allowed by default and costs no bytes.

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ The output is not respecting ascending order! \$\endgroup\$
    – sergiol
    Sep 3, 2017 at 23:03
  • \$\begingroup\$ I broke it when I switched from newlines to spaces to save a byte. Fixed now. \$\endgroup\$
    – Dennis
    Sep 3, 2017 at 23:30
5
\$\begingroup\$

APL (Dyalog), 30 28 bytes

Complete program. Outputs to space-separated to STDOUT.

'\.'⎕R','⊢2⍕×\.01,14⍴2 2.5 2

Try it online!

2 2.5 2 the list;
[2,2.5,2]

14⍴ cyclically reshape to length 14;
[2,2.5,2,2,2.5,2,2,2.5,2,2,2.5,2,2,2.5]

.01 prepend 0.01;
[0.01,2,2.5,2,2,2.5,2,2,2.5,2,2,2.5,2,2,2.5]

×\ cumulative multiplication;
[0.01,0.02,0.05,0.1,0.2,0.5,1,2,5,10,20,50,100,200,500]

2⍕ format with two decimals;
" 0.01 0.02 0.05 0.10 0.20 0.50 1.00 2.00 5.00 10.00 20.00 50.00 100.00 200.00 500.00"

 yield that (to separate ',' from 2)

'\.'⎕R',' PCRE Replace periods with commas;
" 0,01 0,02 0,05 0,10 0,20 0,50 1,00 2,00 5,00 10,00 20,00 50,00 100,00 200,00 500,00"

\$\endgroup\$
4
\$\begingroup\$

R 70, 50 bytes

inspired by @Giuseppe:

format(c(1,2,5)*10^rep(-2:2,e=3),ns=2,de=",",sc=F)

Try it here!

Ungolfed

format(c(1,2,5)*10^rep(-2:2, each = 3),
   nsmall = 2, 
   decimal.mark = ",",
   scientific = FALSE)
\$\endgroup\$
1
  • \$\begingroup\$ I could only manage 56 using a similar method, just with an t(outer()) rather than the rep(). Not sure if we're allowed that leading whitespace though, that'd cost 4 bytes to fix. \$\endgroup\$ Sep 4, 2017 at 8:36
3
\$\begingroup\$

Pyth, 37 bytes

smmX%"%.2f"*dk\.\,[1 2 5)[.01.1 1T^T2

Try it online!

Pyth, 37 bytes

Will shorten in a few minutes.

V[.01.1 1T^T2)V[1 2 5)X%"%.2f"*NH\.\,

Try it online!

\$\endgroup\$
3
\$\begingroup\$

JavaScript (ES6), 83 bytes

Returns an array.

_=>[...'125'.repeat(k=5)].map(c=>(c*(c-1?k:k*=10)/5e3).toFixed(2).split`.`.join`,`)

Demo

let f = 

_=>[...'125'.repeat(k=5)].map(c=>(c*(c-1?k:k*=10)/5e3).toFixed(2).split`.`.join`,`)

console.log(f())


Recursive version (ES7), 84 bytes

Returns a string with a trailing space.

f=(i=0)=>i<15?('125'[i%3]/100*10**(i/3|0)).toFixed(2).split`.`.join`,`+' '+f(i+1):''

Demo

f=(i=0)=>i<15?('125'[i%3]/100*10**(i/3|0)).toFixed(2).split`.`.join`,`+' '+f(i+1):''

console.log(f())

\$\endgroup\$
0
3
\$\begingroup\$

Python 2, 80 77 75 73 bytes

-2 bytes thanks to @Mr.Xcoder
-1 byte thanks to @EriktheOutgolfer
-2 bytes thanks to @totallyhuman
-2 bytes thanks to @Lynn

print[('%.2f'%(v*m)).replace(*'.,')for m in.01,.1,1,10,100for v in 1,2,5]

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ @EriktheOutgolfer forgets to remove spaces \$\endgroup\$
    – Mr. Xcoder
    Sep 2, 2017 at 15:34
  • \$\begingroup\$ I forgot to specify what kind of separator between values are acceptable. Don't worry, newline is acceptable. \$\endgroup\$
    – sergiol
    Sep 2, 2017 at 15:36
2
\$\begingroup\$

Retina, 42 bytes


5$*0
0
$'1$`¶$'2$`¶$'5$`¶
..¶
,$&
m`^00?

Try it online! Explanation: There are fifteen values, with 1, 2 and 5 in each of five places. The first stage inserts five 0s. The second stage repeats them into a square, then changes the trailing diagonal into 1s, then duplicates those lines three times with 2 and 5. The third stage inserts the commas and the last stage removes unnecessary leading zeros.

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

Charcoal, 37 bytes

”{➙∧N\`�4✳×″↶tι⦄|Q~(↥↗⁻“Q§U‴w⎇δUη◨÷¤G”

Try it online! Link is to verbose version.

Yay, compression!

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

Bash, 88 bytes

s=125
for i in {0..14};{ printf %1.2f\  `bc<<<"scale=2;${s:i%3:1}*10^$[i/3-2]"`|tr . ,;}

Try it online!

\$\endgroup\$
2
  • 3
    \$\begingroup\$ After all that hard work, echo 0,01 0,02 0,05 0,10 0,20 0,50 1,00 2,00 5,00 10,00 20,00 50,00 100,00 200,00 500,00 is the same length :( \$\endgroup\$ Sep 2, 2017 at 21:36
  • \$\begingroup\$ @DigitalTrauma But that's no fun :P \$\endgroup\$ Sep 2, 2017 at 21:38
1
\$\begingroup\$

JavaScript (ES6), 81 bytes

Returns an array.

_=>[...Array(13),b=.005,i=0].map(p=>(b*=++i%3?2:2.5).toFixed(2).replace(".",","))

Demo

let f = 

_=>[...Array(13),b=.005,i=0].map(p=>(b*=++i%3?2:2.5).toFixed(2).replace(".",","))

console.log(f())


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

Common Lisp, 95 bytes

(dotimes(i 5)(dolist(j'(1 2 5))(princ(substitute #\, #\.(format()"~$ "(*(expt 10(- i 2))j))))))

Try it online!

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

Husk, 28 bytes

ṁm↔ṪöJ',CtN`J§¤eR'0≥≤2ḣ5"125

Try it online!

Just string manipulation, since Husk is terrible at formatting floating point numbers.

Explanation

ṁm↔ṪöJ',CtN`J§¤eR'0≥≤2ḣ5"125
                        "125  The string "125".
                      ḣ5      The range [1,2,3,4,5].
   Ṫö                         Compute their outer product wrt this function:
                               Arguments are number n (say 3) and character c (say '5').
             §     ≥≤2         Compute max(0,n-2+1) and max(0,2-n+1),
                R'0            repeat '0' those numbers of times,
              ¤e               and put them into a list: ["00",""]
           `J                  Join with c: "005"
        CtN                    Split to lengths 2 and at most 3: ["00","5"]
     J',                       Join with ',': "00,5"
                              This gives a 2D array of the outputs reversed.
ṁ                             Map and concatenate
 m↔                           map reversal.
                              Implicitly print separated by newlines.
\$\endgroup\$
1
\$\begingroup\$

C++, 138 120 bytes

-18 bytes thanks to MSalters

#include<iostream>
void p(){for(auto&a:{"0,0%d ","0,%d0 ","%d,00 ","%d0,00 ","%d00,00 "})for(int b:{1,2,5})printf(a,b);}

Hardcoded version, by Lynn, 116 bytes

#include<ios>
void p(){puts("0,01 0,02 0,05 0,10 0,20 0,50 1,00 2,00 5,00 10,00 20,00 50,00 100,00 200,00 500,00");}
\$\endgroup\$
3
  • \$\begingroup\$ You should include some online example for people seeing it running. I already did it for you: tio.run/… \$\endgroup\$
    – sergiol
    Sep 3, 2017 at 22:07
  • \$\begingroup\$ No need for v and f: void p(){for(auto&a:{"0,0%d ","0,%d0 ","%d,00 ","%d0,00 ","%d00,00 "})for(int b:{1,2,5})printf(a,b);} - just 120 bytes \$\endgroup\$
    – MSalters
    Sep 4, 2017 at 13:11
  • \$\begingroup\$ #include<ios>␤void p(){puts("0,01 0,02 0,05 0,10 0,20 0,50 1,00 2,00 5,00 10,00 20,00 50,00 100,00 200,00 500,00");} is 116 bytes. \$\endgroup\$
    – Lynn
    Sep 4, 2017 at 14:00
1
\$\begingroup\$

R, 70 61 bytes

options(scipen=9,OutDec=",")
print(c(1,2,5)*10^rep(-2:2,e=3))

Try it online!

-9 bytes thanks to Rui Barradas

Outgolfed by AndriusZ

\$\endgroup\$
7
  • \$\begingroup\$ I think there are no 1000€, 2000€ and 5000€ \$\endgroup\$
    – AndriusZ
    Sep 3, 2017 at 14:12
  • \$\begingroup\$ You can save 5 bytes by removing print \$\endgroup\$
    – AndriusZ
    Sep 3, 2017 at 14:20
  • \$\begingroup\$ by mixing your and my answers we can achieve 50 bytes - format(c(1,2,5)*10^rep(-2:2,e=3),ns=2,de=",",sc=9) \$\endgroup\$
    – AndriusZ
    Sep 3, 2017 at 14:32
  • \$\begingroup\$ @AndriusZ I think you still need a print around that answer but you should post it yourself; I just used the most barbaric method to change the settings, using format required some actual thought. \$\endgroup\$
    – Giuseppe
    Sep 3, 2017 at 15:38
  • 1
    \$\begingroup\$ You can save 8 bytes by combining the two options into one. options(OutDec=",",scipen=5). \$\endgroup\$ Sep 3, 2017 at 17:43
1
\$\begingroup\$

C (gcc), 82 bytes

p(n){printf("%d,%02d ",n/100,n%100);}f(n){for(n=1;n<5e4;n*=10)p(n),p(n*2),p(n*5);}

Try it online!

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

05AB1E, 25 bytes

125S5иεN3÷°*т/'.',:N2›i0«

Returns a list of strings.

Try it online.

Explanation:

125                          # Push 125
   S                         # Split to a list of digits: [1,2,5]
    5и                       # Repeat it 5 times: [1,2,5,1,2,5,1,2,5,1,2,5,1,2,5]
      ε                      # Map each to:
       N3÷                   #  Integer-divide the map-index by 3
          °                  #  Take it to the power 10
           *                 #  Multiply the current map number with it
            т/               #  Divide it by 100
              '.',:          #  Replace all "." with ","
                   N2›i      #  And if the map-index is larger than 2:
                       0«    #   Append a "0"

125S5и could be •}•15∍ (push compressed 125; enlarge it to size 15: 125125125125125) and '.',: could be „.,`: (push string ".,", pop and push the characters as separated items to the stack) for the same byte-count: Try it online.
Also, N3÷°*т/ can be shortened to N3÷Í°* (where Í subtracts 2), but unfortunately we need the / so all the numbers becomes decimals, whereas with N3÷Í°* most numbers will remain integers.

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

T-SQL, 104 bytes

SELECT FORMAT(p*n,'0\,00')
FROM(VALUES(1),(2),(5))a(n),(VALUES(1),(10),(100),(1E3),(1E4))b(p)
ORDER BY p,n

Line breaks are for readability only.

Annoyingly longer than the trivial PRINT version (90 bytes):

PRINT'0,01 0,02 0,05 0,10 0,20 0,50 1,00 2,00 5,00 10,00 20,00 50,00 100,00 200,00 500,00'
\$\endgroup\$
2
0
\$\begingroup\$

Bubblegum, 41 bytes

00000000: 1dc5 8105 0040 1402 d055 1ae0 50d1 feab  [email protected]...
00000010: dd2f 788f 8fc2 e192 433c 5c42 e891 7049  ./x.....C<\B..pI
00000020: 11ab 67a6 b8bc 90f5 01                   ..g......

Try it online!

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

Retina, 58 bytes


¶0¶00¶000¶0000¶
.*¶
1$&2$&5$&
^
¶
+`¶(.?.?¶)
¶0$1
..¶
,$&

Try it online!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I double-checked with a question to the OP - the leading zeros are not acceptable :( \$\endgroup\$ Sep 2, 2017 at 23:24
  • \$\begingroup\$ You should fix your post according to @JonathanAllan 's observation. JonathanAllan, thanks \$\endgroup\$
    – sergiol
    Sep 2, 2017 at 23:31
  • \$\begingroup\$ @sergiol fixed it \$\endgroup\$
    – ovs
    Sep 3, 2017 at 6:06
0
\$\begingroup\$

Ruby, 66 62 bytes

-2.upto 2{|m|[1,2,5].map{|v|$><<('%.2f '.%v*10**m).tr(?.,?,)}}

4 bytes shorter thanks to Lynn!

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ -2.upto 2{…} saves 3 bytes. '%.2f '.%v*10**m saves one byte (calling the % method!) \$\endgroup\$
    – Lynn
    Sep 3, 2017 at 12:27
0
\$\begingroup\$

C# (.NET Core), 107 bytes

Console.Write("0,01{0}2{0}5 0,10 0,20 0,50 1{1}2{1}5{1}1{2}2{2}5{2}10{2}20{2}50{2}"," 0,0",",00 ","0,00 ");

Run it

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

JavaScript - 96 bytes

x=>{for(o="",b=-2;b<3;b++)for(n of[1,2,5])o+=(n*10**b).toFixed(2).replace(".",",")+" ";return o}

And here's a slightly longer (98 characters) functional approach:

x=>[].concat.apply([],[.01,.1,1,10,100].map(n=>[n,n*2,n*5])).map(n=>n.toFixed(2).replace(".",","))
\$\endgroup\$
0
\$\begingroup\$

J, 36 bytes

echo'.,'charsub 0j2":,1 2 5*/~10^i:2

Try it online!

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

Tcl, 80 bytes

lmap d {-2 -1 0 1 2} {lmap c {1 2 5} {puts [regsub \\. [format %.2f $c\e$d] ,]}}

Try it online!

Tcl, 90 bytes

lmap d {.01 .1 1 10 100} {lmap c {1 2 5} {puts [regsub \\. [format %.2f [expr $c*$d]] ,]}}

Try it online!

Still very long, golfing it more later!

\$\endgroup\$
4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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