7
\$\begingroup\$

Use any programming language to display "AWSALILAND" in such a way, so that each letter is in a new line and repeated as many times as its position in the English alphabet. For example letter, (A) should be displayed just once because it is the first letter of the alphabet. Letter D should be displayed 4 times because it is the 4th letter of the alphabet.

So, the output should be this:

A
WWWWWWWWWWWWWWWWWWWWWWW
SSSSSSSSSSSSSSSSSSS
A
LLLLLLLLLLLL
IIIIIIIII
LLLLLLLLLLLL
A
NNNNNNNNNNNNNN
DDDD
\$\endgroup\$
8
  • 7
    \$\begingroup\$ Are lower-case letters OK? \$\endgroup\$
    – Emigna
    Oct 17, 2018 at 12:05
  • 35
    \$\begingroup\$ IMHO, this challenge would have been more interesting if the text was given as input/argument. \$\endgroup\$
    – Adám
    Oct 17, 2018 at 12:48
  • 6
    \$\begingroup\$ @Adám IMHO that wouldn't even be a very interesting challenge anyway. \$\endgroup\$
    – Wheat Wizard
    Oct 17, 2018 at 13:27
  • 2
    \$\begingroup\$ @PostLeftGhostHunter At least it would omit the unrelated challenge of compressing AWSALILAND. \$\endgroup\$
    – Adám
    Oct 17, 2018 at 13:29
  • 1
    \$\begingroup\$ is a list of lines an acceptable output format? \$\endgroup\$
    – Brian H.
    Oct 18, 2018 at 13:31

61 Answers 61

1
\$\begingroup\$

Vyxal j, 18 16 bytes

`AWSALILAND`ƛøA*

Try it Online!

Explained

`AWSALILAND`ƛøA*
            ƛ    # mapping lambda
             øA  # string to number in alphabet
               * # times the character

j flag to print with newlines

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

Jelly, 20 bytes

“AWSALILAND”ẋ"O_64ƊY

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ I'd suggest “µɗỊ²ẋ_’ṃØA to save a byte on the string, but that seems to throw an error when placed in the program... \$\endgroup\$ Oct 17, 2018 at 17:17
  • \$\begingroup\$ @ETHproductions You need to append a ¤ to that, therefore no bytes are saved. Same luck with compressed strings... :-( \$\endgroup\$ Oct 17, 2018 at 17:40
0
\$\begingroup\$

MBASIC, 86 bytes

 1 S$="AWSALILAND":FOR I=1 TO LEN(S$):P$=MID$(S$,I,1):PRINT STRING$(ASC(P$)-64,P$):NEXT

Output:

A
WWWWWWWWWWWWWWWWWWWWWWW
SSSSSSSSSSSSSSSSSSS
A
LLLLLLLLLLLL
IIIIIIIII
LLLLLLLLLLLL
A
NNNNNNNNNNNNNN
DDDD
\$\endgroup\$
0
\$\begingroup\$

Dart, 83 bytes

'AWSALILAND'.runes.forEach((r)=>print(String.fromCharCodes(List.filled(r-64, r))));

Try it online!

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

PHP, 71 bytes

<? for($i=0;$c="AWSALILAND"[$i++];)echo str_repeat($c,ord($c)-64)."\n";

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ You can save 2 bytes by removing the space after the opening tag and replacing \n with a literal newline. \$\endgroup\$
    – Shaggy
    Oct 18, 2018 at 22:17
0
\$\begingroup\$

Common Lisp, 96 bytes

(defun x(s)(dotimes(i(length s))(dotimes(j(-(char-int(char s i))96))(princ(char s i)))(terpri)))

Try it online!

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

Jelly, 17 bytes

“þ⁷ʂ:ñ⁵1»O_96׌uY

Try it online!

How?

“þ⁷ʂ:ñ⁵1»O_96׌uY - Main Link: no arguments
“þ⁷ʂ:ñ⁵1»         - compressed list of characters (using words aws, ali & land = awsaliland)
         O        - cast to ordinals = [97,119,115,97,108,105,108,97,110,100]
          _96     - subtract 96 = [1,23,19,1,12,9,12,1,14,4]
              Œu  - upper-case the chain's argument = "AWSALILAND"
             ×    - multiply = ["A","W...W","S...S","A","L...L","I...I","L...L","A","N...N","DDDD"]
                Y - join with newline characters = ["A",'\n',"W...W",'\n',"S...S",'\n',"A",'\n',"L...L",'\n',"I...I",'\n',"L...L",'\n',"A",'\n',"N...N",'\n',"DDDD"]
                  - implicit (smashing) print

Also @ 17 bytes: “þ⁷ʂ:ñ⁵1»ØaiⱮ׌uY, and “þ⁷ʂ:ñ⁵1»O%32׌uY

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

Go, 100 bytes

import(."fmt"
."strings")
func a(){for _,c:=range"AWSALILAND"{Println(Repeat(string(c),int(c)-64))}}

Try it online!

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

QBasic, 57 bytes

FOR i=1TO 10
c=ASC("AWSALILAND",i)
?STRING$(c-64,c)
NEXT

I'm so glad I was able to avoid using MID$() for this challenge!

How it works

  • Run a FOR loop over (1-based) indices of the characters in the string
  • Store the ASCII code of the current character as c
  • Create a string of c-64 repetitions of character c and print it
\$\endgroup\$
0
\$\begingroup\$

PHP, 58 bytes

while($c=AWSALILAND[$i++])echo str_pad("
",ord($c)-63,$c);

prints a leading linebreak. Run with -nr or try it online.

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

Python 2, 38 bytes

for c in'AWSALILAND':print ord(c)%64*c

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ I like that str_repeat operator. I sometimes wish that PHP had it - but with another character, so we can go on using strings as numbers. And for <char> in <string> ... I just love it! \$\endgroup\$
    – Titus
    Oct 18, 2018 at 12:44
0
\$\begingroup\$

Bubblegum, 29 bytes

00000000: 73e4 0ac7 0eb8 8231 0197 2397 0f12 e0f2  s......1..#.....
00000010: 8401 1461 a02a 3f14 c0e5 0204 00         ...a.*?......

Try it online!

I'm sorry...

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

F# (.NET Core), 66 bytes

"AWSALILAND"|>Seq.iter(fun x->printfn"%s"(new string(x,int x-64)))

Try it online!

Same logic than @pocki_c's answer

I am not used to F# golfing. All inputs are welcome :)

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

Ruby, 39 bytes

"AWSALILAND".chars{|x|x.*x.ord-64}

Try it offline!

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

APL(NARS), 22 chars, 44 bytes

⊃a/¨⍨⎕A⍳a←'AWSALILAND'

test

A                      
WWWWWWWWWWWWWWWWWWWWWWW
SSSSSSSSSSSSSSSSSSS    
A                      
LLLLLLLLLLLL           
IIIIIIIII              
LLLLLLLLLLLL           
A                      
NNNNNNNNNNNNNN         
DDDD                   
\$\endgroup\$
0
\$\begingroup\$

Java (JDK), 162 bytes

static void m(){String n="AWSALILAND";for(int i=0;i<n.length();i++){char c=n.charAt(i);int v=c;for(int z=0;z<v-64;z++)System.out.print(c);System.out.println("");}

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Sure, I will review and edit answer. \$\endgroup\$ Oct 20, 2018 at 4:59
  • \$\begingroup\$ Please check i have update my code. \$\endgroup\$ Oct 20, 2018 at 5:11
  • \$\begingroup\$ Seems to be valid now. Possible 124 bytes. \$\endgroup\$ Oct 20, 2018 at 10:55
  • \$\begingroup\$ 104 Bytes using a foreach loop \$\endgroup\$
    – Veskah
    Dec 28, 2018 at 1:26
0
\$\begingroup\$

PHP, 93 bytes

<?=!array_walk(str_split("AWSALILAND",1),function(&$v){echo str_repeat($v,ord($v)-64)."
";});

Try it online!



PHP, 81 bytes

<?php for(;$i++<10;)echo str_repeat(($s=AWSALILAND)[$i-1],ord($s[$i-1])-64)."
";

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ 1) Try <?=! - the "not" will negate the true; and false is printed empty. Or omit the php tag and run with -r (that flag is free). 2) 89 byte version: save four bytes with $i<strlen()...str_repeat($s[$i],ord($s[$i++])... \$\endgroup\$
    – Titus
    Oct 18, 2018 at 0:44
  • \$\begingroup\$ And: as this is Kolgomorov Complexity, you could hardcode the length - saving another four bytes. \$\endgroup\$
    – Titus
    Oct 18, 2018 at 0:52
0
\$\begingroup\$

///, 82 bytes

/$/NN//#/SSS//"/WWW//!/LLLL/A
"""""""WW
######S
A
!!!
IIIIIIIII
!!!
A
$$$$$$$
DDDD

Try it online!

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

Turing Machine But Way Worse - 4349 bytes

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

Made with the help of ASCII_only's program generator

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

Tcl, 88 bytes

lmap x [split AWSALILAND ""] {set s ""
time {set s $s$x} [expr [scan $x %c]-64]
puts $s}

Try it online!

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

Perl 6, 37 bytes

say .chr x$_-64 for "AWSALILAND".ords

Try it online!

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

VBA (Excel), 70 bytes

using Immediate window

a="AWSALILAND":For x=1To Len(a):b=Mid(a,x,1):?String(Asc(b)-64,b):Next
\$\endgroup\$
0
\$\begingroup\$

8088 machine code, IBM PC DOS, 40 bytes

Listing:

B4 02       MOV  AH, 2          ; DOS API display char function
B1 0A       MOV  CL, 10         ; CL length of string 
BE 011E     MOV  SI, OFFSET S   ; point SI to AWSALILAND string  
    LOOP_CHAR:   
AC          LODSB               ; load next byte into AL 
8A D0       MOV  DL, AL         ; put in DL for display 
2C 40       SUB  AL, 'A'-1      ; convert ASCII char to 1-based counter 
8A D8       MOV  BL, AL         ; move to BL for repeat loop 
    LOOP_REP: 
CD 21       INT  21H            ; display char in DL 
4B          DEC  BX             ; decrement repeat counter 
75 FB       JNZ  LOOP_REP       ; repeat char loop 
B2 0D       MOV  DL, 0DH        ; display CR 
CD 21       INT  21H 
B2 0A       MOV  DL, 0AH        ; display LF 
CD 21       INT  21H 
E2 EA       LOOP LOOP_CHAR      ; next char loop 
C3          RET                 ; return to DOS 

S   DB      'AWSALILAND'        ; define static string in memory

Actually turned out to be longer than I thought. Of course, it doesn't help that it costs 8 bytes to display a newline using the DOS console API.

Output

enter image description here

Download and test AWA.COM.

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

Deadfish~, 192 bytes

{i}ddsic{{d}}{i}cs{d}dddccc{cc}{{d}}{i}cdsii{c}ccccccccc{{d}}{i}cddsic{{d}}{i}cdsddddd{c}cc{{d}}{i}cdds{i}dccccccccc{{d}}{i}cdsddddd{c}cc{{d}}{i}cddsic{{d}}{i}cdsddd{c}cccc{{d}}{i}cddsiiiicccc

Try it online!

Frankly, I'm just stoked it's below 200 bytes.

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

Ahead, 34 bytes

Contains trailing newline.

"AWSALILAND"u$l<
~dW:k-A':\N\0<~n@

Try it online!

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

C++ (gcc), 90 83 bytes

#include<map>
int main(){for(auto c:"AWSALILAND")c&&puts(&std::string(c-64,c)[0]);}

Try it online!

Thanks to movatica for shaving off 7 bytes!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Don’t need c&& \$\endgroup\$
    – ceilingcat
    Oct 18, 2018 at 10:12
  • \$\begingroup\$ @ceilingcat: but then it will crash when it hits the terminating NUL byte. \$\endgroup\$
    – G. Sliepen
    Oct 19, 2018 at 11:29
  • 1
    \$\begingroup\$ &std::string(c-64,c)[0] saves three bytes against std::string(c-64,c).c_str() #include<map> instead of #include<string> saves another 3 bytes. \$\endgroup\$
    – movatica
    May 5, 2019 at 18:02
0
\$\begingroup\$

Retina, 56 bytes

K`AWSALILAND
L`.
W
23*W
S
19*S
L
22*L
I
9*I
D
4*D
N
14*N

Explanation:

K`AWSALIAND

Sets the working string to AWSALIAND

L`.

Puts each character onto a new line. L is a list, and each item is found by the regex /./.

character
n*character

Replace all occurences of character with n lots of the character.

Try it online!

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

Poetic, 470 bytes

any days i wish i could&i say i could,i can not
still at the age where,a lot of times,i can not raise my own money
guess i got myself overly exhausted,or spent
no pun is meant
i was a child of ten,a child of ten
a thing i know:i saved a buck a month
m-one-y,m-one-y,m-ones-y
still,i had a dream,i had a vision
oh my god,what a dream
i had a vision i was rich
at first im like:o,i have a payoff,o
however,truly i am not especially pleased
indeed,o,i see i am scared of it

Try it online!

I don't especially like the fact that I have to hardcode AWSALILAND (mostly because I don't know what that means). But at least this works.

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

Husk, 19 bytes

mSRo-64c"AWSALILAND

Try it online!

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

Deadfish~, 284 bytes

{iiiiii}iiiiic{ddddd}dddddc{{i}dd}ddd{cc}ccc{{d}ii}iiic{{i}ddd}iii{c}ccccccccc{{d}iii}dddc{iiiii}iiiiic{ddddd}dddddc{iiiiii}iiiiii{c}cc{dddddd}ddddddc{iiiiii}iiiccccccccc{dddddd}dddc{iiiiii}iiiiii{c}cc{dddddd}ddddddc{iiiii}iiiiic{ddddd}dddddc{{i}ddd}dd{c}cccc{{d}iii}iic{iiiiii}ddcccc

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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