28
\$\begingroup\$

Write the shortest program that prints, in order, a complete list of iPhone iterations, according to this site:

iPhone
iPhone 3G
iPhone 3GS
iPhone 4
iPhone 4S
iPhone 5
iPhone 5c
iPhone 5s
iPhone 6
iPhone 6 Plus
iPhone 6s
iPhone 6s Plus
iPhone SE
iPhone 7
iPhone 7 Plus
iPhone 8
iPhone 8 Plus
iPhone X
iPhone XR
iPhone XS
iPhone XS Max
iPhone 11
iPhone 11 Pro
iPhone 11 Pro Max

Output should be printed exactly as specified, though trailing newlines are allowed (as well as additional whitespace at the end of each line).

This is code golf, so the shortest answer in bytes, per language, wins.

\$\endgroup\$
10
  • \$\begingroup\$ Note that this is about 87 bytes using naive compression. \$\endgroup\$ Commented Mar 8, 2020 at 3:17
  • \$\begingroup\$ Possible duplicate of We're no strangers to code golf, you know the rules, and so do I \$\endgroup\$ Commented Mar 8, 2020 at 15:58
  • 2
    \$\begingroup\$ I disagree; the fact that only one answer beats Bubblegum is evidence that the text doesn't have enough structure for specialized compression algorithms to beat generic ones. \$\endgroup\$ Commented Mar 8, 2020 at 16:04
  • 2
    \$\begingroup\$ @pppery I admit the answers can't be as interesting as I though, but that's not necessarily grounds for closing/duping, right? \$\endgroup\$
    – rydwolf
    Commented Mar 8, 2020 at 16:07
  • 2
    \$\begingroup\$ @JairoA.delRio The quality's comparable, Apple's just overprices stuff :p \$\endgroup\$
    – rydwolf
    Commented Feb 27, 2021 at 17:32

30 Answers 30

13
\$\begingroup\$

Canvas, 77 76 73 bytes

¶+∔iF╴qV1┼#│»lN↶:╋KARV/+├6<∔ZK@≠≡Ze3h}s×⁴*⁵GZX─?ep┼Q‟-s{iPhone ×|∙ Plus╋]

Try it here!

-3G-3GS-4-4S-5-5c-5s-6-6|-6s-6s|-SE-7-7|-8-8|-X-XR-XS-XS Max-11-11 Pro-11 Pro Max compressed, split on -, | replaced with ' Plus', and 'iPhone ' prepended.

\$\endgroup\$
1
  • \$\begingroup\$ Wow, this beats the Bubblegum solution! \$\endgroup\$
    – PkmnQ
    Commented Mar 11, 2020 at 4:20
9
\$\begingroup\$

Zsh, 107 105 bytes

-2 bytes due to leniency on trailing spaces

print -l iPhone\ {,{3G,4}{,S},5{,c,s},6{,s}{,\ Plus},SE,{7,8}{,\ Plus},X{,R,S,S\ Max},11{,\ Pro{,\ Max}}}

Try it online! Try it online!

A long brace expansion. Bash/sh need printf %s\\n instead for 4 extra bytes.

\$\endgroup\$
2
  • \$\begingroup\$ Not necessarily. I just came up with a Bash answer that's the same size (but it uses less strict output rules). \$\endgroup\$
    – S.S. Anne
    Commented Mar 8, 2020 at 22:17
  • 1
    \$\begingroup\$ Ah, the "as well as additional whitespace at the end of each line" wasn't allowed when I posted. \$\endgroup\$ Commented Mar 8, 2020 at 23:51
9
\$\begingroup\$

JavaScript (ES6),  137 136  135 bytes

_=>"iPhone3G9GS39S33c9s3303s9s01SE3903301X1XR1XS1XS Max22 Pro2 Pro Max".replace(/\d/g,n=>[" Plus",k=`
iPhone `,k+11,k+i][n]||k+i++,i=3)

Try it online!

How?

The numeric version is stored in a counter \$i\$ initialized to \$3\$.

Below are the digits used for the compression:

  • \$0\$: " Plus"
  • \$1\$: "\n" + "iPhone "
  • \$2\$: "\n" + "iPhone 11"
  • \$3\$: "\n" + "iPhone " + \$i\$
  • \$9\$: same as \$3\$, but \$i\$ is incremented afterwards

Resulting in:

"iPhone"    --> "iPhone"
"3G"        --> "iPhone 3G"
"9GS"       --> "iPhone 3GS" (i++)
"3"         --> "iPhone 4"
"9S"        --> "iPhone 4S" (i++)
"3"         --> "iPhone 5"
"3c"        --> "iPhone 5c"
"9s"        --> "iPhone 5s" (i++)
"3"         --> "iPhone 6"
"30"        --> "iPhone 6 Plus"
"3s"        --> "iPhone 6s"
"9s0"       --> "iPhone 6s Plus" (i++)
"1SE"       --> "iPhone SE"
"3"         --> "iPhone 7"
"90"        --> "iPhone 7 Plus" (i++)
"3"         --> "iPhone 8"
"30"        --> "iPhone 8 Plus"
"1X"        --> "iPhone X"
"1XR"       --> "iPhone XR"
"1XS"       --> "iPhone XS"
"1XS Max"   --> "iPhone XS Max"
"2"         --> "iPhone 11"
"2 Pro"     --> "iPhone 11 Pro"
"2 Pro Max" --> "iPhone 11 Pro Max"
\$\endgroup\$
4
\$\begingroup\$

///, 108 bytes

Naive compression, simply replacing # with \niPhone. (Further compression does not work by the way.)

/#/
iPhone //@/ Plus/iPhone#3G#3GS#4#4S#5#5c#5s#6#6@#6s#6s@#SE#7#7@#8#8@#X#XR#XS#XS Max#11#11 Pro#11 Pro Max

Try it online!

///, 103 bytes

This works only if preceding newlines are allowed.

/#/
iPhone //@/ Plus/##3G#3GS#4#4S#5#5c#5s#6#6@#6s#6s@#SE#7#7@#8#8@#X#XR#XS#XS Max#11#11 Pro#11 Pro Max

Try it online!

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

Jelly, 83 bytes

“Ø^ÞṠṠẠ'Ḣߥ»=⁶œṗ;11;“RcGEs436X578 ”µ“ƈ`¿øÐ⁽ḞÆCḊḋɲÑF×GÇz ⁸¦MƊ‘ד£¿Þ瑦5ŻṃµṚ“®Ɲ,»,K)Y

Try it online!

How?

Uses eighteen non-"iPhone " parts and constructs each line from a big-endian number in base eighteen, then prefixes each with "iPhone " and joins with newline characters.

The parts used are (comma separated):
Max, Plus, Pro, ,S,R,c,G,E,X,s,3,4,5,6,7,8,11

The mapping to the eighteen digits was chosen so that:

  1. the space character is a zero - allowing a single byte prepend-zero to make the first line
  2. no two digit "numbers" are greater than 255 - allowing encoding with code-page indices
  3. the three digit "numbers" (S,G,3; Plus,s,6; Max,S,X; and Max, Pro,11) are all exact multiples of five (and less than 1275) - allowing encoding with code-page indices, with post multiplication to acquire their full value
  4. the three words are adjacent and do not occupy digit one - allowing compression with a split-before spaces application

One such (1-indexed) ordering is:
S, Max, Plus, Pro,11,R,c,G,E,s,4,3,6,X,5,7,8,

As such the code works like so:

“...»=⁶œṗ;11;“...”µ“...‘ד£¿Þ瑦5ŻṃµṚ“®Ɲ,»,K)Y - Main Link: no arguments
“...»                                          - string = "S"+" Max"+" Plus"+" Pro"
      ⁶                                        - space character
     =                                         - equals? (vectorises)
       œṗ                                      - partition before truthy indices
         ;11                                   - concatenate 11
             “...”                             - list of characters "RcGEs436X578 "
            ;                                  - concatenate
                                               - giving our "digits" [1,2,...,17,0]
                  µ                            - start a new monadic chain
                   “...‘                       - list of code-page indices = [156, 96, 11, 29, 15, 141, 195, 13, 67, 193, 233, 163, 16, 70, 17, 71, 14, 122, 32, 136, 5, 77, 145]
                               ¦               - sparse application...
                                               - ...to indices:
                         “£¿Þç‘                -   code-page indices = [2, 11, 20, 23]
                        ×       5              - ...do: multiply by five -> [156, 480, 11, 29, 15, 141, 195, 13, 67, 193, 1165, 163, 16, 70, 17, 71, 14, 122, 32, 680, 5, 77, 725]
                                 Ż             - prepend a zero
                                  ṃ            - base-decompress (convert to base-18 using the "digits")
                                               -   e.g. 680 -> [2, 1, 14] -> [" Max",'S','X']
                                   µ        )  - for each:
                                    Ṛ          -   reverse it (e.g. [" Max",'S','X'] -> ['X','S'," Max"])
                                     “®Ɲ,»     -   string = "iPhone"
                                          ,    -   pair
                                           K   -   join with a space character
                                             Y - join with newline characters
                                               - implicit, smashing print
\$\endgroup\$
4
\$\begingroup\$

05AB1E, 81 bytes

11”3G3GS44S55c5s66‰´6s6s‰´SE77‰´88‰´XXRXSXSî£ÿÿˆ×ÿˆ×•ΛΩ&°ŽäÞнã•0šTª£'i”ƒ¿ ”«ì»

Try it online!

I dom't have time to re-analyze.

Original Solution, 178 bytes

'i”ƒ¿”«D… 3G«D'S«.ÀD.Á„ 4«D'S«.ÀD.Á„ 5«Ð'c«s's«.ÀD.Á„ 6«D" Plus"D.Á«sDŠ's«D.À«.ÀD.Á… SE«.ÀD.Á„ 7«D" Plus"D.Á«.À.ÀD.Á„ 8«DŠs«.ÀD.Á„ X«Ð'R«s'S«D" Max"D.Á«.À.ÀD.Á… 11«DŠ" Pro"«DŠs«»

Try it online!

Explanation

First, I push the string "iPhone" by using 'i”ƒ¿”«.

I duplicate that, and push " 3G", and concatenate them to get "iPhone 3G".

After that, I use .ÀD.Á to get "iPhone" at the top of the stack, etc.

When I get to iPhone 6, I put " Plus" at the bottom of the stack and save it for iPhone 6S Plus.

I don't save it for iPhone 7 and 8 Plus, because I'm not sure if it will golf off some bytes, and I'd already spent enough time figuring it out.

I did save " Max" though, and I'm pretty sure now that saving " Plus" would've shaved off more bytes. However, now that the program is already completed, it's unclear how I do that.

At the end, I concatenate the whole stack together with newline delimiters, and implicit output happens.

\$\endgroup\$
8
  • \$\begingroup\$ 84B. \$\endgroup\$
    – user92069
    Commented Mar 8, 2020 at 7:59
  • 4
    \$\begingroup\$ 80 \$\endgroup\$ Commented Mar 8, 2020 at 15:11
  • \$\begingroup\$ This is missing iPhone 6s and iPhone 6s Plus, as are all the suggested edits (the 178 is fine) :( \$\endgroup\$ Commented Mar 9, 2020 at 0:11
  • \$\begingroup\$ @ExpiredData This is missing iPhone 6s & Plus (as well as mine). Quick fix of 89 bytes \$\endgroup\$
    – user92069
    Commented Mar 9, 2020 at 0:35
  • 1
    \$\begingroup\$ @ExpiredData Your 85-byter is missing the leading iPhone (and I'm not sure leading newlines are allowed either). Here an easy fix that's still 85 bytes, though. PS: If your 85-byter would have worked, you could have dropped the ) to join the stack directly. \$\endgroup\$ Commented Mar 9, 2020 at 14:51
3
\$\begingroup\$

Bubblegum, 82 bytes

00000000: cb0c c8c8 cf4b e582 500a c6ee 0856 308c  .....K..P....V0.
00000010: 6902 67c0 854c e18c 6438 ab18 c632 8333  i.g..L..d8...2.3
00000020: 1402 724a 11c2 482c 1489 6057 18cb 1cce  ..rJ..H,..`W....
00000030: 4051 6001 67a0 0847 c019 4170 5630 82a5  @Q`.g..G..ApV0..
00000040: e09b 5801 e319 1a22 580a 0145 f9a8 3c90  ..X...."X..E..<.
00000050: 4a00                                     J.

Try it online!

Bubblegum, 87 bytes

Written by @FryAmTheEggman, so I don't take credit for this.

00000000: e001 0700 4f5d 0034 9409 072b 9ed9 334a  ....O].4...+..3J
00000010: 2d4f 957c 30d4 5ae8 8bc7 1c12 f267 7c2c  -O.|0.Z......g|,
00000020: 47df 6d0b 6d45 b174 dcab 2da7 e97a ed9f  G.m.mE.t..-..z..
00000030: e772 808d f6c6 d93e c423 2b3c 378e 0a13  .r.....>.#+<7...
00000040: c57b 7a72 436d a362 6818 88d0 a495 4466  .{zrCm.bh.....Df
00000050: e336 dcfb ac00 00                        .6.....

Try it online!

\$\endgroup\$
1
  • 3
    \$\begingroup\$ 82 bytes, generated with zopfli. \$\endgroup\$
    – ovs
    Commented Mar 8, 2020 at 16:51
3
\$\begingroup\$

Perl 5, 118 114 bytes

$_="3G3GS44S55c5s66-6s6s-SE77-88-XXRXSXS Max99Pro9Pro Max";s/-/ Plus/g;s/^|(\d|X|SE)/\niPhone $1/g;s/9/11 /g;print

Try it online!

This code is rather simple: in the string $_, it replaces "-" with " Plus". Then it cuts the string at every digit, "X" or "SE" and prefixes the matching part with a line break and "iPhone ". Finally, it replaces "9" by "11 ".

Attempting to replace " Max" or " Pro" with shorter symbols would not bring any benefits because the substitution would cost more characters.

Thanks to Weizel who allowed me to save 4 bytes by replacing the first "iPhone" in the string.

I assumed that the final newline was not necessary.

\$\endgroup\$
2
  • \$\begingroup\$ Last line is not required to end with a newline (-: \$\endgroup\$
    – rydwolf
    Commented Mar 8, 2020 at 16:29
  • 1
    \$\begingroup\$ Add line beggining sarch in this substitution s/^|(\d|X|SE)/\niPhone $1/g. It allows to cut 'iPhone' in the main string and saves 4 bytes. \$\endgroup\$
    – Weizel
    Commented Mar 14, 2020 at 17:14
2
\$\begingroup\$

Keg, 129 127 bytes

‘1⊙‘®p`iPhone `:&
⑻3G
⑻3GS
⑻4
⑻4S
⑻5
⑻5c
⑻5s
⑻6
⑻6 ©p
⑻6s
⑻6s ©p
⑻SE
⑻7
⑻7 ©p
⑻8
⑻8 ©p
⑻X
⑻XR
⑻XS
⑻XS Max
⑻11
⑻11 Pro
⑻11 “∂⬭q≥

Try it online!

How's that for a submission! Simply using the register and a little bit of string compression + variables gives a kind of competitive answer.

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

Retina 0.8.2, 91 bytes


¶3G¶3GS¶4¶4S¶5¶5c¶5s¶6=¶6s=¶SE¶7=¶8=¶X¶XR¶XS!¶11¶11 Pro!
%(`^
iPhone 
!
¶$` Max
=
¶$` Plus

Try it online! Includes additional whitespace on the first line Explanation:


¶3G¶3GS¶4¶4S¶5¶5c¶5s¶6=¶6s=¶SE¶7=¶8=¶X¶XR¶XS!¶11¶11 Pro!

Insert the names of the models, but without iPhone, Max or Plus, which get added later.

%(`

Operate on each line individually.

^
iPhone 

Prefix iPhone to the line.

!
¶$` Max

If the line has a !, then duplicate it and append Max to the duplicate.

=
¶$` Plus

If the line has a =, then duplicate it and append Plus to the duplicate.

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

Bash, 109 bytes

printf %s\\n iPhone\ {,{3G,4}{,S},5{,c,s},6{,s}{,\ Plus},SE,{7,8}{,\ Plus},X{,R,S,S\ Max},11{,\ Pro{,\ Max}}}

Similar to the Zsh solution but some slight changes and some output leniency.

Try it online!

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

Swift, 152 bytes

",3G,3GS,4,4S,5,5c,5s,6,6 Plus,6s,6s Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max".split(separator: ",").forEach{print("iPhone \($0)")}

Being related to iPhones, this needs an answer in Swift. Unfortunately Swift is woooordy. The most boring route is the shortest :/

Try it online

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

Brain-Flak, 5007 bytes

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

Try it online!

Created using this program

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

Deadfish, 2374 bytes

{{i}}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}i}dc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}dc{i}{i}c{{d}iiii}dc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}dc{i}{i}c{i}iic{{d}iii}dddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}c{{d}iiiiii}ddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}c{i}{i}{i}ic{{d}iii}dddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}ic{{d}iiiiii}dddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}ic{{i}dddddd}iiiiiic{{d}i}ic{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}ic{{i}dddd}iic{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iic{{d}iiiiii}ddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iic{d}{d}ddc{{i}ddddd}ddc{i}{i}{i}ddc{i}dcddc{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iic{{i}dddd}ic{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iic{{i}dddd}ic{{d}ii}dddc{{i}ddddd}ddc{i}{i}{i}ddc{i}dcddc{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{{i}ddddd}ic{d}ddddc{{d}iiii}ic{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iiic{{d}iiiiii}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iiic{d}{d}dddc{{i}ddddd}ddc{i}{i}{i}ddc{i}dcddc{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iiiic{{d}iiiiii}ddddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}iiiic{d}{d}ddddc{{i}ddddd}ddc{i}{i}{i}ddc{i}dcddc{{d}}dddddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{{i}ddddd}iiiiiic{{d}ii}iic{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{{i}ddddd}iiiiiicddddddc{{d}iii}ddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{{i}ddddd}iiiiiicdddddc{{d}iii}dddc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{{i}ddddd}iiiiiicdddddc{{d}iiiii}dc{{i}dddddd}iiiiic{i}{i}c{i}{i}iiic{{d}}{d}c{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}dddcc{{d}iiiiii}ic{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}dddcc{d}{d}iiic{{i}ddddd}ddc{i}{i}{i}iiiicdddc{{d}}dc{{i}d}iiiiic{d}{d}dddddc{i}{i}iiiic{i}dddcdc{d}ic{{d}iii}ic{i}{i}dddcc{d}{d}iiic{{i}ddddd}ddc{i}{i}{i}iiiicdddc{{d}ii}ic{{i}dddddd}iiiiic{i}{i}c{i}{i}iiic

Umm...

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

Vyxal jr, 96 93 bytes

` «₍
`\Y`
3G
3GS
4
4S
5
5c
5s
6
6Y6s
6sYSE
7
7Y8
8YX
XR
XS
XS ½…
11
11 ×Ǐ
11 ×Ǐ ½…`V↵ƛ`i¬Ẋ `+

Try it Online!

Compressed Plus with a newline a bit.

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

Python 3, 136 bytes

for i in",3G,3GS,4,4S,5,5c,5s,6,6 Plus,6s,6s Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max".split(","):print("iPhone",i)

Try it online!

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

APL (dzaima/APL), 139 bytes

⎕←↑('iPhone ',)¨" ""3G""3GS""4""4S""5""5c""5s""6""6 Plus""6s""6s Plus""SE""7""7 Plus""8""8 Plus""X""XR""XS""XS Max""11""11 Pro""11 Pro Max"

I do not think there is a way to "bond" similar to J's n&u. That would be an obvious way to save some bytes.

This is my first APL answer. I probably should've gone with something a little less trivial.

Attempt This Online!

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

Vyxal jr, 88 bytes

`3G3GS44S55c5s66 «₍6s6s «₍SE77 «₍88 «₍XXRXSXS ½…1111 ×Ǐ11 ×Ǐ ½…`»∵Te§ḋƒꜝL⁼»f₀pẇ¤J`i¬Ẋ `+

Try it Online!

\$\endgroup\$
1
  • \$\begingroup\$ As opposed to Vyxal senior. \$\endgroup\$
    – emanresu A
    Commented Oct 25, 2022 at 23:01
1
\$\begingroup\$

Stax, 100 bytes

Yay, I (finally) beat Zsh!

┌W○εRKW>◙≡D↨u^╬=Θs╜i^░δ#(\D╘i╗◄⌠╜`┌!║Æ♂∞╦J╘^╙üÜ°¢╠╣⌂ƒ♣↨←Bµ☻òK$▲,0fε▄PÉ↔ΓÅ▲s2îùvπ↑╛!╢╠♣=·F┴²C6µób└╢íf

Run and debug it

Explanation

  1. Repace all A's in the compressed string with "".
  2. Surround it with ".
  3. Evaluate the string.
  4. Wrap the output in a list.
  5. Map every item with a preceding iPhone. Print with a newline.
\$\endgroup\$
1
\$\begingroup\$

R, 175 178 bytes

cat(paste('iPhone',c('','3G','3GS','4','4S','5','5c','5s','6','6 Plus','6s','6s Plus','SE','7','7 Plus','8','8 Plus','X','XR','XS','XS Max','11','11 Pro','11 Pro Max')),sep='\n')

Try it online!

Manual is shorter than this programmatic take:

R, 231 bytes

r=rep;b='';m='Plus';cat(paste("iPhone",paste0(r(c(b,3:6,'SE',7:8,'X',11),c(1,2,2,3,3,1,2,2,4,3)),c(b,'G','GS',b,'S',b,'c','s',b,'s','s',r(b,6),'R','S','S',r(b,3))),c(r(b,9),m,b,m,b,b,m,b,m,r(b,3),'Max',b,'Pro','Pro Max')),sep='\n')

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ First answer doesn't seem to include the original iPhone? \$\endgroup\$
    – Neil
    Commented Mar 8, 2020 at 19:47
  • \$\begingroup\$ @Neil whoops, fixed thanks \$\endgroup\$
    – John
    Commented Mar 8, 2020 at 19:49
  • \$\begingroup\$ write and rbind save 3 bytes: Try it online! I may come back and tinker with the numerals a little more; I do think it can be shortened somehow. \$\endgroup\$
    – Giuseppe
    Commented Mar 9, 2020 at 21:41
  • \$\begingroup\$ note that write is just a wrapper to cat so it can sometimes be shorter if you know the options :-) \$\endgroup\$
    – Giuseppe
    Commented Mar 9, 2020 at 21:42
1
\$\begingroup\$

T-SQL, 145 bytes:

SELECT'iPhone '+value
FROM string_split(' -3G-3GS-4-4S-5-5c-5s-6-6 Plus-6s-6s Plus-SE-7-7 Plus-8-8 Plus-X-XR-XS-XS Max-11-11 Pro-11 Pro Max','-')

I did find a shorter version using a simple string replacement (128 bytes), but it's not quite as interesting, and it's not clear whether the preceding line break is allowed:

PRINT REPLACE('223G23GS2424S2525c25s2626 Plus26s26s Plus2SE2727 Plus2828 Plus2X2XR2XS2XS Max211211 Pro211 Pro Max',2,'
iPhone ')

I used the numeral (2) as the replacement character so I don't have to include another set of quotes.

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

Ruby, 129 bytes

$><<"iPhone:3G:3GS:4:4S:5:5c:5s:6:6 Plus:6s:6s Plus:SE:7:7 Plus:8:8 Plus:X:XR:XS:XS Max:11:11 Pro:11 Pro Max".gsub(?:,"
iPhone ")

Try it online!

Uses the fact that strings can have newlines in (one byte), rather than \n (two bytes). Otherwise this is a simple replacement of a single-character string into iPhone

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

PowerShell, 108 bytes

'3G,3GS,4,4S,5,5c,6,6 Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max'-split','|%{"iPhone $_"}

Try it online!

-30 bytes for mazzy

\$\endgroup\$
2
  • 1
    \$\begingroup\$ 108 bytes \$\endgroup\$
    – mazzy
    Commented Feb 28, 2021 at 6:22
  • 1
    \$\begingroup\$ @mazzy thx learnt new trick ;-) \$\endgroup\$
    – Wasif
    Commented Feb 28, 2021 at 9:39
1
\$\begingroup\$

Stax, 92 bytes

Ωî♂∞¥■J⌡┤≥♦C♀ç¿kë▀/∞♥╧0î·Φ│∟/╢ì☼αuèôΩY?╘÷▄òà╣○╢{⌂P○å§o\τ+ mδ↓ê☻.═+Ä{╜A2jJü7πP|è╡╖Rä►┴Luƒ☺/¬&

Run and debug it

simplifying the existing answer was enough for 92. there's probably a way to compress the intial over-big string.

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

JavaScript (Node.js), 132 bytes

_=>'iPhone,3G,3GS,4,4S,5,5c,5s,6,6 Plus,6s,6s Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max'.split`,`.join`
iPhone `

Try it online!

-5 bytes thanks to @cairdcoinheringaahing and @RedwolfPrograms

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

Batch, 156 Bytes

@ECHO(iPhone&For %%A In (3G 3GS 4 4S 5 5c 5s 6 6s "6 Plus" "6s Plus" SE 7 "7 Plus" 8 "8 Plus" X XR XS "XS Max" 11 "11 Pro" "11 Pro Max")do @Echo(iPhone %%~A
\$\endgroup\$
1
\$\begingroup\$

Sequences, \$118 \log_{256}(96) \approx 97.1\$ bytes

",3G,3GS,4,4S,5,5c,5s,6,6 Plus,6s,6s Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max"","p{H"iPhone "fhF}

Explanation

"..."","p{H"iPhone "fhF}
"..."                    // Push a string of suffixes of the models of iPhones
     ","p                // Split by commas
         {             } // For each model:
          H"iPhone "f    //   Print "iPhone " with no trailing newline
                     hF  //   And print the suffix with a trailing newline

Screenshot

Screenshot

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

C (gcc), 162 bytes

f(i,n){n="3G3GS44S55c5s66 Plus6s6s PlusSE77 Plus88 plusXXRXSXS Max1111 Pro11 Pro Max";for(i=24;i--;)printf("iPhone %s\n",n+=strlen(n++));}

-1 byte thanks to Neil!
-45 bytes thanks to dzaima!

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ 207 bytes \$\endgroup\$
    – Neil
    Commented Mar 8, 2020 at 19:51
  • \$\begingroup\$ 162 bytes \$\endgroup\$
    – dzaima
    Commented Mar 8, 2020 at 21:31
0
\$\begingroup\$

C# (Visual C# Interactive Compiler), 123 bytes

Write("iPhone,3G,3GS,4,4S,5,5c,6,6 Plus,SE,7,7 Plus,8,8 Plus,X,XR,XS,XS Max,11,11 Pro,11 Pro Max".Replace(",","\niPhone "))

Try it online!

C# (Visual C# Interactive Compiler), 131 chars, 154 bytes

foreach(var x in"ȔДȥ͖˶ଇ˷೷աଈ	ଉ\0΀Ƞਠࡼၼ")WriteLine($"iPhone {x%16-1:0;X;.}"+" GS Max Pro Maxs PluscSER".Substring(x/16%32,x>>9));

Though it isn't the shortest, I invested quite a lot of effort and it would be a shame to just toss it all away.

Note: There is a null byte in the string, but I can't copy-paste it so it's represented by \0 in the code.

Try it online!

\$\endgroup\$
1
  • 5
    \$\begingroup\$ I think you could use Write instead of WriteLine. If a trailing newline is needed, a \n i still shorter than WriteLine \$\endgroup\$ Commented Mar 9, 2020 at 8:33
0
\$\begingroup\$

Pyth, 103 bytes

j"
iPhone "[kk"3G""3GS"4"4S"5"5s""5c"6+6J" Plus"="6s"+GJ"SE"7+7J8+8~J" Max"\X"XR"K"XS"+KJ11="11 Pro"+bJ

Today I learned about the ~.

Try it online!

\$\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.