-2
\$\begingroup\$

Your challenge is to make a program(less number of bytes than what the below program takes) that should print the map of India with any special character of choice.

TIO Link

#include <stdio.h>
int main()
{
    int a = 10, b = 0, c = 10;
    char* str = "TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq "
                "TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBL"
                "OFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm "
                "SOn TNn ULo0ULo#ULo-WHq!WFs XDt!";
    while (a != 0)
    {
    a = str[b++];
        while (a-- > 64)
        {
            if (++c == 90)
            {
                c = 10;  
                putchar('\n');
            }
            else
            {
                if (b % 2 == 0)
                    putchar('!');
                else
                    putchar(' ');
            }
        }
    }
    return 0;
}

The program outputs:

                !!!!!!                                                     
                !!!!!!!!!!                                                 
                 !!!!!!!!!!!!!!!                                           
                   !!!!!!!!!!!!!!                                          
                 !!!!!!!!!!!!!!!                                           
                  !!!!!!!!!!!!                                             
                  !!!!!!!!!!!!                                             
                    !!!!!!!!!!!!                                           
                    !!!!!!!!                                               
                    !!!!!!!!!!                                             
                   !!!!!!!!!!!!!!                                          
                 !!!!!!!!!!!!!!!!                                          
                !!!!!!!!!!!!!!!!                                  !!!!!    
              !!!!!!!!!!!!!!!!!!!                               !!!!!!!!!! 
             !!!!!!!!!!!!!!!!!!!!!!!                 !         !!!!!!!!!!  
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!              !!     !!!!!!!!!!!!    
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !!      !!!!!!!!       
        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!      
         !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!       
          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  !!!!!!!!!!!!       
   !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !!!!!!        
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!      !!!!!         
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !!!          
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!        !          
      !!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                       
       !!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                         
              !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                          
             !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                           
              !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                               
              !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                               
              !!!!!!!!!!!!!!!!!!!!!!!!!!!!                                 
              !!!!!!!!!!!!!!!!!!!!!!!!!!                                   
              !!!!!!!!!!!!!!!!!!!!!!!!!                                    
               !!!!!!!!!!!!!!!!!!!!!!!!                                    
                !!!!!!!!!!!!!!!!!!!!                                       
                !!!!!!!!!!!!!!!!!!!                                        
                 !!!!!!!!!!!!!!!!                                          
                  !!!!!!!!!!!!!!!!                                         
                  !!!!!!!!!!!!!!!                                          
                   !!!!!!!!!!!!!!                                          
                    !!!!!!!!!!!!                                           
                    !!!!!!!!!!!!                                           
                    !!!!!!!!!!!!                                           
                      !!!!!!!!                                             
                      !!!!!!                                               
                       !!!!                                             
\$\endgroup\$
4
  • \$\begingroup\$ Like @BruceForte said, I had added the requisite tio link \$\endgroup\$
    – Ajay
    Jul 26, 2017 at 5:39
  • 10
    \$\begingroup\$ I think printing a 2d region of one character isn't that interesting, and we've already had the batman symbol challenge which has more usable structure. \$\endgroup\$
    – xnor
    Jul 26, 2017 at 5:49
  • \$\begingroup\$ Are we free to use any two characters, or is the ocean restricted to the space character? Also I noticed you have specified "special character", what exactly does that mean (I currently use 0, but do not know if that counts as "special")? \$\endgroup\$ Jul 26, 2017 at 14:08
  • \$\begingroup\$ @xnor <3 domo origato, Mr. Xnorboto. \$\endgroup\$ Jul 29, 2017 at 23:41

11 Answers 11

7
\$\begingroup\$

Charcoal, 135 134 133 132 126 bytes

F¹²⁶F…"§”kL↷DXry"R⁴¹¤'➙ω⎈v¬⌊π2κÿρ“q↷0h˜⁶!⌊P[±9NH|N≡H´“i¬›FE‹t⁵→Z£314➙yqt⟲“⌊⌊‖↷ÞIuA?↷|⁻c″!!<;‹YS00y/;↥L’D∧§⎈k≕X”ι⎇﹪L⊞Oυω⁷⁵§ *ι⸿

Try it online!

Port of my C# answer. Link to the verbose version.

  • 6 bytes saved thanks to Neil!
\$\endgroup\$
4
  • 1
    \$\begingroup\$ AtIndex(" *", i) saves 4 bytes, I think. \$\endgroup\$
    – Neil
    Jul 26, 2017 at 11:38
  • \$\begingroup\$ @Neil nice! Thanks! \$\endgroup\$
    – Charlie
    Jul 26, 2017 at 11:42
  • 1
    \$\begingroup\$ I think you can save more bytes by using a Range instead of subtracting the ordinals. (for (Range("A", "Z")) would loop 25 times for example, so it would be shorter than for (Minus(Ordinal("Z"), 65)). \$\endgroup\$
    – Neil
    Jul 26, 2017 at 11:45
  • \$\begingroup\$ I tried porting this approach to the Batman question. It came in at 54 bytes F³⁶F…A§”v.£j⎚-n²λWHX↓wA8L$»δηπ41H″”ι⎇﹪L⊞Oυω²⁶§ *ι⸿‖O← but sadly I then noticed I could apply the AtIndex trick to save 2 further bytes on my own solution... \$\endgroup\$
    – Neil
    Jul 26, 2017 at 13:12
6
\$\begingroup\$

Jelly, (110? 113?) 112 bytes

Notes: The 2 bytes, a⁶ (near the end) may be dropped if 1 is acceptable for the ocean. If special character means digits are not acceptable and the ocean must be a space the byte count will be 113 (replace Ḃa⁶s75Y with ị⁾ !s75Y) which will use !.

“*ẊñDȯT¹^qɓ\j£œ%ñ2u{ṅʠỴ©ṾÇịṭxẏ¤Ḅʋ⁽~|}ṾṃƑ¡vṀGs®[Ȯkhɗṃ?ƇṿTṫ6HỌ¡ẏṣnD1ı¹ḍ1Ḣ4$ẸObẓ¢ƙṾⱮḃċỵ|)wY)ḌÇḤ~æṣt²5’ḃ70ĖŒṙḂa⁶s75Y

A full program printing the map. Uses 0 for the land.

Try it online!

How?

The first 99 bytes:

“*ẊñDȯT¹^qɓ\j£œ%ñ2u{ṅʠỴ©ṾÇịṭxẏ¤Ḅʋ⁽~|}ṾṃƑ¡vṀGs®[Ȯkhɗṃ?ƇṿTṫ6HỌ¡ẏṣnD1ı¹ḍ1Ḣ4$ẸObẓ¢ƙṾⱮḃċỵ|)wY)ḌÇḤ~æṣt²5’

is a base 250 literal (a very large number). The rest of the code manipulates this number:

“ ... ’ḃ70ĖŒṙḂa⁶s75Y - Main link: no arguments
“ ... ’              - the large number above
       ḃ70           - convert to bijective base 70 [16,6,69,10,66,...]
          Ė          - enumerate                    [[1,16],[2,6],[3,69],[4,10],[5,66],...]
           Œṙ        - run length decode            [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,3,3,...(69 total)...,3,4,4,4,4,4,4,4,4,4,4,5,5,...(66 total)...,5,...]
             Ḃ       - modulo 2                     [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,...(69 total)...,1,0,0,0,0,0,0,0,0,0,0,1,1,...(66 total)...,1,...]
               ⁶     - literal space character
              a      - logical and (vectorises)     [' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',0,0,0,0,0,0,' ',' ',...(69 total)...,' ',0,0,0,0,0,0,0,0,0,0,' ',' ',...(66 total)...,' ',...]
                s75  - split into chunks of length 75 (representing the rows of "text")
                   Y - join with newline characters (making a single list of ' ', 0, and '\n')
                     - implicit print (a list containing any characters is smashed, so
                     -             the 0s print as `0` and none of the `[,]` are shown)
\$\endgroup\$
4
\$\begingroup\$

Bubblegum, 132 bytes

00000000: b595 b719 4421 18c3 7aa6 30fb 0f79 a93b  ....D!..z.0..y.;
00000010: 4412 dfc3 25f6 2f32 a451 fda9 f49a 61c1  D...%./2.Q....a.
00000020: 4300 9163 84b7 7d60 6c3e 383b 2618 c852  C..c..}`l>8;&..R
00000030: e080 0290 9856 ed8b f503 1221 503b 106e  .....V.....!P;.n
00000040: 1231 6335 9c70 3027 0245 6242 88a6 0410  .1c5.p0'.EbB....
00000050: b097 c2dd ae27 c2c1 0346 8ca3 a05e 32fe  .....'...F...^2.
00000060: c710 b993 a288 97cc 55f8 2eee 877d 5407  ........U....}T.
00000070: 91cb 6e2e 3ee4 1f5e 1f91 3f00 7423 002d  ..n.>..^..?.t#.-
00000080: 6c98 70df                                l.p.

Try it online!

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

C# (.NET Core), 240 232 231 227 bytes

_=>{var r="";for(int i=0,j,k=0;i<126;i++)for(j=0;j++<@"2(g,d1`0]1_.a.c.a*e,b0]2\2D'45A,093#+,,@0$'.-G*$(*1_1P#.3N$.,(#M*(,W('1R*%0V*#2(#I@'#GIEIEK@O@O>Q<S;U:V6Y5[2^2]1_0`.a.a.c*e(h&"[i]-34;)r+=++k%75<1?'\n':" *"[i%2];return r;}

Try it online!

Same approach as for my C# answer for the Batman challenge.

  • 4 bytes saved thanks to Neil! His Charcoal tip could also be applied here! :)
\$\endgroup\$
4
  • \$\begingroup\$ Oh, well, if you're accepting C# tips, then r+=++k%75<1?'\n':" *"[i%2] can be r+=++k%75?" *"[i%2]:'\n'. \$\endgroup\$
    – Neil
    Jul 26, 2017 at 12:57
  • \$\begingroup\$ @Neil no, it can't. In C# the int type is not automatically cast to bool. \$\endgroup\$
    – Charlie
    Jul 26, 2017 at 13:03
  • \$\begingroup\$ Oh, it's as stupid as Java then? \$\endgroup\$
    – Neil
    Jul 26, 2017 at 13:12
  • \$\begingroup\$ @Neil yes, it is. :-) \$\endgroup\$
    – Charlie
    Jul 26, 2017 at 13:14
2
\$\begingroup\$

Python 2, 227 223 218 216 bytes

  • Thanks @Mr. Xcoder for 2 bytes: j%2>0 can be just j%2
for k in range(46):print''.join(ord(i)*' !'[j%2]for j,i in enumerate('''E
B>;=?A?C
@;:"
	

%=.,
+
504'%'#'#)--/13479<;=>??ACF0'''))[75*k:][:75]

Try it online!

Explanation

The idea is to store the information as the count of total characters in a cluster. For eg:ssssss!!!!ssss is encoded as [6,4,4](and since we have to just alternate thru two characters, this becomes easy. ;) ) This info can be compiled as a string by ascii characters for each count (see the string literal). Now we simply obtain the count and draw ! or a space alternately.

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

Retina, 289 bytes


16:16;,7#/9#,7#/8-18<<"!%20;,9#,7#&,6#@34&/4#"!31;,3#;&!17!9;!%8'"14&5-7=!8&6"!%8'=%9=;&1-10=;2-3"1="!8:2''@!6@%6''8&%>'@8%6"1=&%7@!1=%1>;/3';/>:1>:1>&,>,>%15'¶16#",6#"%17#&,8#&,8#/9#!%20<<-22"!%22:23@45
@
&&
>
4'
=
'#
<
-20
;
"&
:
"¶
/
&%1
-
#¶
,
!%1
'
##
&
!!
%
!¶
#
""
"
!!!!!!
\d+
$* 

Try it online!

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

JavaScript (ES6), 254 253 251 bytes

_=>`f5
f9
ge
id
ge
hb
hb
jb
j7
j9
id
gf
ffx4
diu9
cmg089
7td14b
6z07157
7zo
8z90b
9z71b
250z675
1zg54
5zb72
3zf70
550z2
640z0
dy
cy
dt
dt
dr
dp
do
en
fj
fi
gf
hf
he
id
jb
jb
jb
l7
l5
m3`.replace(/./g,m=>" !"[i%2].repeat(parseInt(m,36)+1,i+=m<"z"),i=0)

Test it

o.innerText=(
_=>`f5
f9
ge
id
ge
hb
hb
jb
j7
j9
id
gf
ffx4
diu9
cmg089
7td14b
6z07157
7zo
8z90b
9z71b
250z675
1zg54
5zb72
3zf70
550z2
640z0
dy
cy
dt
dt
dr
dp
do
en
fj
fi
gf
hf
he
id
jb
jb
jb
l7
l5
m3`.replace(/./g,m=>" !"[i%2].repeat(parseInt(m,36)+1,i+=m<"z"),i=0)
)()
<pre id=o>

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

JavaScript (ES7), 239 bytes

Encodes the shape and the line breaks separately.

let f =

_=>'h7hbigkfigjdjdldl9lbkfihhhz6fkwbeoi2ab9vf36d812937991qa1b2db193d472189731i7671d9451h927721486212f10e10fvfvftfrfqgphlhkihjhjgkfldldldn9n7o5'.replace(/1?./g,n=>' X'[i&1].repeat(parseInt(n,36)-1)+((++i|716000693/2**(i/2))&1?'':`
`),i=-26)

o.innerHTML = f()
<pre id=o style="font-size:6px"></pre>

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

C (gcc), 255 244 239 bytes

b,c;main(a){for(;a="TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBLOFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm SOn TNn ULo0ULo#ULo-WHq!WFs XDt!"[b++];)for(;a-->64;putchar(++c%80?33-b%2:10));}

Slightly bugfixed and golfed version of OP's reference implementation. Try it online!

Minimally less golfed:

b,c;
main(a){
  for(;a="TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBLOFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm SOn TNn ULo0ULo#ULo-WHq!WFs XDt!"[b++];)
    for(;a-->64;)
      putchar(++c%80?33-b%2:10);
}
\$\endgroup\$
0
\$\begingroup\$

C (gcc), 205 bytes

My solution quickly converged on something extremely close to ceilingcat's golfed version of OP's implementation, but output does differ slightly when it comes to leading spaces on each line, since I worked from the text found in OP's post, which does not exactly match the output of the reference implementation, most likely due to OP missing the leading spaces required for code text, but there are answers using that text as reference, so it's somewhat ambiguous.

i,j;main(c){for(;c="B8w<tAp@mAo>q>s>q:u<r@mBlBT7DEQ<@IC3;<<P@47>=W:48:AoA`3>C^4><83]:8<g87Ab:5@f:3B83YP73WYUYU[P_P_NaLcKeJfFiEkBnBmAo@p>q>q>s:u8x6b"[i++];)for(;c---50;j++)printf("\n%c"+(!j||j%75),33-i%2);}

Try it online!

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

Vyxal j, 442 bytes

»⌐ṫżṫṗƛ&%≠ɽ_~ẇ*⁼3L ≈;n~U7⋏₇ḭǔ°₁>Aµ1I(□]:ȯ≤KWƒʁY•₇⟩-RCa⟨&8ẋżṫẏL_ġN⇧ṗḞΠṄẇ%¨ḃ₆Q<Zǒ,]„∨TC⁋⟩`ɾOn^≬ݾ¨Ṫlṅ^£†i-ẏ₂↓∷×ṘǍ¶G?∑x∪ż∪İɖ¹p*₴Ḣ≈J₀↳₁‡x⌈↳D4xJḢmḃẇDpeH&⋏¹!≥₇∑;↑≬m†¥⁋†₇,Ż∪ß^ċ¡}GBİ£:U~ʁ⌈∴Ṡ^ṗ⁺Ȯo↓Ṅ%Ẏṗ§∴ḭ₈Ṁ‛∑ø≈dOƒ¥¤ɖ4Ẏ{⅛I∞_uė∇ṫḭB?U≤ǔ9F⟑q₴ẆŀṠz∞₁XṖ¨‛₇VB₁τḟAsżǒxP∵9)&∵β"Ż∆ ↲,₴øxJT.t꘍/₴ǎpe↔ḟqȯ(^≥Vḭ⁰Ȯɽτ∆ṙ°÷lW≠⇧Cb≠²∩]±ḭy∧D℅øJǔ₅⅛EGḭ≥ẋZ≥×8nΠḋ⟩)Ṗv‹'⇧@jq≥ḟ⁽]¾fǎ⅛Ȯ⌊bDa^ṀP;}ṫ⁼τ1„√ɽh⇩GW€⁼[6¼U~j_IṘ†gJ↔Ȧ$°§_„)Ż"₅‡xußġ₃ǔ↔×ɖɖ[æ¥s‹⁰≈c†t‹ṪṙḊ꘍bεβ¶∩∩{ǒḢġ†₅⟨L⌐∨H»`! `τ75ẇ

Try it Online!

Plain old binary, AKA I'm losing to everyone.

\$\endgroup\$

Your Answer

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

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