9
\$\begingroup\$

This week's odyssey in Bloons Tower Defense 6 has a neat gimmick, but it's slightly confusing at first. Each custom round is actually two consecutive regular rounds at once, but this means the round number no longer helps you know what is coming! The rounds are as follows:

1  1,2
2  3,4
3  5,6
4  7,8
5  9,10
6  11,12
7  13,14
8  15,16
9  17,18
10 19,20
11 21,22
12 23,24
13 25,26
14 27,28
15 29,30
16 31,32
17 33,34
18 35,36
19 37,38
20 39,40
21 41,42
22 43,44
23 45,46
24 47,48
25 49,50
26 51,52
27 53,54
28 55,56
29 57,58
30 59,60
31 61,62
32 63,64
33 65,66
34 67,68
35 69,70
36 71,72
37 73,74
38 75,76
39 77,78
40 79,80
41 81,82
42 83,84
43 85,86
44 87,88
45 89,90
46 91,92
47 93,94
48 95,96
49 97,98
50 99,100
51 101,102
52 103,104
53 105,106
54 107,108
55 109,110
56 111,112
57 113,114
58 115,116
59 117,118
60 119,120
61 121,122
62 123,124
63 125,126
64 127,128
65 129,130
66 131,132
67 133,134
68 135,136
69 137,138
70 139,140

Where each round is (2n-1, 2n). Since rounds only go up to 140, the table only needs 70 lines.

A lookup table would be nice... Since I play on speedup, code should be as short as possible so I can type it before the next custom round starts. You can use any delimiters provided each round is on its own line, and the round number delimiter is different from the paired round delimiter. trailing whitespace on each line is fine, as is a trailing newline at the end. You can use a leading zero instead of padding with spaces for rounds 1-9, padding can be done on either side.

\$\endgroup\$
9
  • \$\begingroup\$ Is padding limited to only be whitespace? Does padding have to be consistent across all of the lines? May the two delimiters used contain any of the same characters as each other? \$\endgroup\$ Commented Sep 28 at 17:49
  • \$\begingroup\$ padding for the round numbers can either be whitespace or a leading zero, but has to be consistent. Delimiters must be distinct, but can contain similar characters if the actual delimiter is different \$\endgroup\$
    – pacman256
    Commented Sep 28 at 17:51
  • \$\begingroup\$ So multiple answers are invalid? (e.g. having trailing characters after the last number on each line.) \$\endgroup\$ Commented Sep 28 at 17:53
  • \$\begingroup\$ only vyxal appears to be invalid? \$\endgroup\$
    – pacman256
    Commented Sep 28 at 17:57
  • 1
    \$\begingroup\$ yeah thats what i meant by padding. delimiters can be multiple characters long as long as theyre consistent, but be reasonable \$\endgroup\$
    – pacman256
    Commented Sep 28 at 18:34

13 Answers 13

7
\$\begingroup\$

Bash + coreutils, 24

seq 140|paste -d, - -|nl

Try it online!


MacOS Shell and utilities, 20

seq 140|rs 70|nl -s,

Here, the paired-round delimiter is whitespace and the round number delimiter is ,.

rs is a default tool in the MacOS shell. It can also be installed on Linux, after which this answer will work there just as well.

Try it online!

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

Bash, 44 bytes

for i in {1..70};{
echo $i $[i*2-1],$[i*2]
}

Attempt This Online!

doesn't really get simpler than this.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Trying to simplify it turned into bash + sed + coreutils, not really worth its own answer. Attempt This Online! \$\endgroup\$
    – manatwork
    Commented Sep 27 at 15:06
  • \$\begingroup\$ @manatwork seems fine to me for its own answer, also how does it even work? \$\endgroup\$ Commented Sep 27 at 15:14
  • \$\begingroup\$ Dumbly generates all possible combinations of the comma separated number pairs then keeps only the needed ones and prepends the line numbers. \$\endgroup\$
    – manatwork
    Commented Sep 27 at 15:20
3
\$\begingroup\$

05AB1E, 14 bytes

Left space padding for 1-9:

ƵdL2ôā2jøí',ý»

Attempt it online.

Prepended 0s for 1-9 (15 bytes):

ƵdL2ôāT‰Jøí',ý»

Try it online.

Without additional formatting (9 bytes):

ƵdL2ôāøí»

Try it online.

Explanation:

Ƶd              # Push compressed integer 140
  L             # Pop and push a list in the range [1,140]
   2ô           # Split it into pairs
     ā          # Push a list in the range [1,length] (without popping)
      2j        # Pad leading spaces to make all values of length 2
        ø       # Pair the items in the two lists together
         í      # Reverse each pair, so the [1,70] are leading
          ',ý  '# Join each inner-most pair by ","-delimiter
             »  # Then join each pair by spaces, and then all strings by newlines
                # (after which the result is output implicitly)

      T‰        # Divmod each integer by 10
        J       # Join each pair together

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ƶd is 140.

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

><> (Fish), 43 bytes

1:::::"G"=?;n" "{a(?:{a(?oo2*:1-n","onao1+!

Might be able to be improved, but I couldn't find anything right now.

Starts with the counter as 1 and loops until exiting on 71. Adds a space if the counter is less than 10, then makes two copies of the counter times two, then prints that minus one, a comma, the remaining copy, then a newline.

Try it

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

Google Sheets, 32 bytes

=sort(row(1:70)*{1,2,2}-{0,1,0})

enter image description here

The result is unformatted. To get a formatted result (58 bytes):

=sort(text(row(1:70)*{1,2,2}-{0,1,0},{"00","0"",""","0"}))

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ what does "unformatted" give you I might allow it \$\endgroup\$
    – pacman256
    Commented Sep 27 at 20:29
  • \$\begingroup\$ "You can use any delimiters" — the unformatted result has each number is its own cell. There is no need for delimiters in a spreadsheet. "A lookup table would be nice" — the unformatted version would be most conducive for lookups. \$\endgroup\$ Commented Sep 27 at 20:57
  • \$\begingroup\$ oh yeah everything in its own cell is fine \$\endgroup\$
    – pacman256
    Commented Sep 28 at 0:30
2
\$\begingroup\$

J, 27 bytes

1(":,TAB,<:@+:":@,+:)@+i.70

Formats n with 2*n-1 and 2*n using left justify for the round numbers and tab and space for the delimiters.

Attempt This Online!

1(":,TAB,<:@+:":@,+:)@+i.70
                       i.70   NB. 0..69
1                     +       NB. add 1
                     @        NB. apply using rank of +, so for each item
                  +:          NB. double
         <:@":                NB. double then decrement
              ":@,            NB. concat then stringify
     TAB,                     NB. prepend a tab
  ":                          NB. stringify
    ,                         NB. concat
\$\endgroup\$
2
\$\begingroup\$

Arturo, 45 bytes

loop 70'n->print[pad~"|n|"2~"|dec*2n|,|n*2|"]

Try it!

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

Retina, 27 bytes


70*$(ab
L$`b
$>:& $.`,$.>`

Try it online! Explanation:


70*$(ab

Insert 70 copies of the string ab.

L$`b

For each b...

$>:& $.`,$.>`

... output its 1-based index, the number of characters to its left, and the number of characters up to and including it.

32 bytes in Retina 0.8.2:


70$*
1
$`1 $`$`1,$`1$`1¶
1+
$.&

Try it online! Explanation:


70$*

Insert 70 1s.

1
$`1 $`$`1,$`1$`1¶

Replace each 1 with the characters up to and including it, then a separator, then the characters to its left, then the characters up to and including it, then another separator, then the characters up to and including it twice, all on its own line.

1+
$.&

Convert to decimal.

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

Jelly, 10 bytes

140s2ĖṾ€€G

A full program that takes no arguments and prints the table where 1-9 are padded with a space on their right and the delimiters are five spaces and ,.

Try it online!

How?

140s2ĖṾ€€G - Main Link: no arguments
140        - 140
   s2      - split into twos
               -> [[1,2],[3,4],[5,6],...,[139,140]]
     Ė     - enumerate
               -> [[1,[1,2]],[2,[3,4]],[3,[5,6]],...,[70,[139,140]]
      Ṿ€€  - un-evaluate each of each
               -> [["1","1,2"],["2","3,4"],["3","5,6"],...,["70","139,140"]
         G - format as a grid
               (pads with spaces to left-align each of the two columns, giving both
                columns equal width)
               -> "1      1,2\n2      3,4\n3      5,6\n...\n70     138,140"
                    (6)         (6)         (6)               (5)
           - implicit print
\$\endgroup\$
2
\$\begingroup\$

Perl 5, 37 bytes

say"$_ ",$_*2-1,",",$_*2for'01'..'70'

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ needs padding for the round numbers 1-9 \$\endgroup\$
    – pacman256
    Commented Sep 29 at 22:43
  • 1
    \$\begingroup\$ @pacman256 – corrected now \$\endgroup\$
    – Kjetil S
    Commented Oct 1 at 7:57
1
\$\begingroup\$

Charcoal, 17 bytes

E⁷⁰⁺⁺⁺⁺⊕ι ⊕⊗ι,⊗⊕ι

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

 ⁷⁰                 Literal integer `70`
E                   Map over implicit range
        ι           Current value
       ⊕            Incremented
                    Literal space
            ι       Current value
           ⊗        Doubled
          ⊕         Incremented
             ,      Literal string `,`
                ι   Current value
               ⊕    Incremented
              ⊗     Doubled
   ⁺⁺⁺⁺             All concatenated together
                    Implicitly print

18 bytes on TIO to align the second column:

E⁷⁰⁺⁺⁺◨I⊕ι³⊕⊗ι,⊗⊕ι

Try it online! Link is to verbose version of code. Explanation: Instead of appending a space to the first number, it is converted to string and then padded to length 3.

17 bytes on ATO to align the second column:

E⁷⁰⁺⁺⁺◨⊕ι³⊕⊗ι,⊗⊕ι

Attempt This Online! Link is to verbose version of code. Explanation: As above except that Pad implicitly casts to string.

\$\endgroup\$
6
  • \$\begingroup\$ first link just doesnt seem to work \$\endgroup\$
    – pacman256
    Commented Sep 28 at 17:57
  • \$\begingroup\$ Looks like the formatting on the 14 is invalid, also the TIO link just prints a bunch of zeros. \$\endgroup\$ Commented Sep 28 at 17:57
  • 1
    \$\begingroup\$ @pacman256 Sorry about that; I've no idea how that happened, but it should be fixed now. Let me know whether that format is valid because I wasn't sure so I added the other answer just in case. \$\endgroup\$
    – Neil
    Commented Sep 28 at 18:16
  • \$\begingroup\$ that is not valid due to the trailing brackets \$\endgroup\$
    – pacman256
    Commented Sep 28 at 18:35
  • \$\begingroup\$ @pacman256 What about the padding (Although it turns out that doesn't matter if I use ATO instead of TIO)? \$\endgroup\$
    – Neil
    Commented Sep 28 at 18:59
1
\$\begingroup\$

Python 3, 57 Bytes 61 Bytes 81 Bytes

print("\n".join([f"{n}{' 'if n<10 else ''} {2*n-1},{2*n}" for n in range(1,71)]))
\$\endgroup\$
3
  • \$\begingroup\$ this doesn't print the modified round numbers, only the rounds they contain \$\endgroup\$
    – pacman256
    Commented Sep 30 at 19:00
  • \$\begingroup\$ single digit round numbers are not padded correctly, the second column should line up. \$\endgroup\$
    – pacman256
    Commented Sep 30 at 19:06
  • \$\begingroup\$ Welcome to Code Golf, and nice first answer! You might want to add a TIO link, so others can test your answer, and you can save quite a few bytes by a) using f-string padding n:<3 b) rearranging things into a regular for loop: Try it online! \$\endgroup\$
    – emanresu A
    Commented Sep 30 at 19:59
1
\$\begingroup\$

C# (.NET 6+), 68 bytes

for(int i=1;i<71;)System.Console.Write($"{i:00} {i*2-1},{i++*2}\n");

DotNetFiddle

Maybe one day System.Range will implement IEnumerable

\$\endgroup\$

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.