# How to Draw Melting Icicles

A sculptor is tasked to creating icicle sculptures for the new museum in Greenland. He has been given specifications by his boss, which consists of two numbers: [s, m] or size and melt. Size must be an odd number. He was given some photos of real icicles:

vvvvv [5, 0]
vvv
v

vvvvvvv [7, 0]
vvvvv
vvv
v

vvvvvvv [7, 2]
vvvvv

vvvvvvv [7, 3]

vvv [3, 1]


He needs a program to help draw. Any language allowed. The program needs to take in S and M, any method of input acceptable. You must then print out an ascii art representation of it.

S is how many vs are on the first layer. M is how many layers are cut out from the bottom.

This is , so as usual this competition is byte based. White space does count for byte counting. Least bytes wins.

Edit: You will never get a set of numbers that draws nothing, for example [5, 3]. Checking code is not required however.

• You say whitespace does count, but in the examples some lines have trailing spaces. Is that allowed? Nov 25, 2016 at 10:09

# V, 15 bytes

Àévò^lYp2x>òÀñd


Try it online!

Fairly straightforward.

À               " Arg1 times:
év             "   Insert a 'v'
ò       ò    " Recursively:
^l          "   Break if there is only one character on this line
Y         "   Yank this line
p        "   Paste it below us
2x      "   Delete two characters
>     "   Indent this line
À   " Arg2 times:
ñd "   Delete a line

• I think that V wins for "most obfuscatable language". Nov 25, 2016 at 2:54
• that language looks fun to debug Nov 25, 2016 at 10:46
• The source code looks like some random generated hash. I could use it as a safe password. Nov 25, 2016 at 21:51
• I like that there's a language called V that can solve this problem. Nov 26, 2016 at 1:18

# 05AB1E, 12 bytes

Code:

ÅÉ'v×R²F¨}.c


Explanation:

ÅÉ             # List of uneven numbers: [1, 3, 5, ..., input]
'v×          # String multiply by 'v', giving ['v', 'vvv', 'vvvvv', ...]
R         # Reverse the array
²F }     # Second input times, do...
¨      #   Remove the first element of the array
.c   # Centralize the array


Uses the CP-1252 encoding. Try it online!

• ;-Ý·¹+'v×.c would save one byte Nov 25, 2016 at 17:19
• @Osable isn't that just a completely different answer? Nov 26, 2016 at 1:18
• Good point, I really don't know since there is no big algorithm behind both answers. I'll post it as another answer if needed. Nov 26, 2016 at 9:45
• @Osable Nice find! I think you should put it as a different answer, since it's very different from this one. Nov 26, 2016 at 9:49

# 05AB1E, 11 bytes

;-Ý·¹+'v×.c

;-          Compute x = Input[1]-Input[0]/2  (e.g. 7,2 -> -1.5)
Ý         Push [0, ..., x]                 (e.g. 7,2 -> [0, -1])
·        Multiply each value by 2         (e.g. 7,2 -> [0, -2])
¹+      Add Input[0] to each value       (e.g. 7,2 -> [7, 5])
'v×   String multiply by 'v'
.c Center all strings and implicitly display them


Try it online!

• Good Job, you bean @Adnan's 12 bytes in 05AB1E!! Nov 26, 2016 at 16:12
• @yummypasta well, I think his nick is not a coincidence :) Nov 27, 2016 at 2:28
• Thanks! Adnan and Emigna usually help me more than I can help then. And you're right, my nickname is quite related to 05AB1E ;) . Nov 28, 2016 at 8:12

# MATL, 22 bytes

'v'itQ2/i-wX"R2&PRZ{Zv


Try it online!

### Explanation

'v'   % Push character 'v'
it    % Input first number. Duplicate
Q2/   % Add 1 and divide by 2
i-    % Input second number. Subtract
w     % Swap
X"    % Char matrix of 'v' repeated those many times along each dim
R     % Upper triangular part
2&P   % Flip horizontally
R     % Upper triangular part
Z{    % Split char matrix along first dimension into a cell array of strings
Zv    % Remove trailing spaces from each string. Implicitly display


# Jelly, 19 bytes

Rm-2”vẋµLḶ⁶ẋżðḣL_¥Y


TryItOnline!

### How?

Rm-2”vẋµLḶ⁶ẋżðḣL_¥Y - Main link: s, m
R                   - range(s)  [1,2,3,...s]
m-2                - mod -2    [s,s-2,s-4,...,1]
”v              - 'v'
ẋ             - repeat    ['v'*s,...,'vvv','v']  (call this y)
L           - length, effectively (s+1)/2
Ḷ          - lowered range [0,1,2,...length-1]
⁶         - ' '
ẋ        - repeat ['', ' ', ... ' '*(length-1)]
ż       - zip with y
L    -     length
_   -     subtract m
Y - join with line feeds
- implicit print

• I like that length-unlength chain in the middle ;-) Nov 25, 2016 at 23:47
• Yeah, J’ (range of length decremented) would also have the same effect, but there is no lowered version of J, and the LḶ is kind of cute :) Nov 26, 2016 at 5:17

## Batch, 142 bytes

@set/ah=%1-%2-%2
@set s=v
@for /l %%i in (3,2,%1)do @call set s=%%s%%vv
@for /l %%i in (1,2,%h%)do @call echo %%s%%&call set s= %%s:~0,-2%%


# Ruby, 46 44 bytes

->s,m{0.upto(s/2-m){|i|puts' '*i+?v*s;s-=2}}


2 bytes saved thanks to G B

• puts does not need the whitespace
– G B
Nov 25, 2016 at 11:06
• And you can save one more character by decrementing s: instead of ?v*(s-2*i) use ?v*s;s-=2
– G B
Nov 25, 2016 at 11:25

# Python, 76 73 bytes

def f(s,m):print"\n".join([' '*(s/2-i/2)+'V'*i for i in range(s,m*2,-2)])


Edit: Saved 3 bytes thanks to @TuukkaX and @Challenger5 (Thanks!)

• After the print, there's an useless whitespace :) Nov 25, 2016 at 4:53
• Why not use a lambda? lambda s,m:"\n".join([' '*(s/2-i/2)+'V'*i for i in range(s,m*2,-2)]) Nov 25, 2016 at 7:16
• You can put the function code directly after the def f(s,m):, saving two bytes. Nov 25, 2016 at 20:40
• @J843136028 It's the same number of bytes: def f() is 7 lambda  is 7. with Challenger5's tip, def is actually shorter. at least if that's what you meant like i think :)
– cure
Nov 26, 2016 at 1:21
• @nephi But you also remove the print, so it's 4 characters shorter (lambda s,m:"\n".join(...)), as lambdas basically have an implicit return. Nov 27, 2016 at 0:12

## JavaScript (ES6), 57 bytes

f=(s,m,p=)=>s<m+m?:p+v.repeat(s)+
+f(s-2,m,p+ )


Outputs a trailing newline. If a leading newline is acceptable, then for 54 bytes:

f=(s,m,p=
)=>s<m+m?:p+v.repeat(s)+f(s-2,m,p+ )


## Python 2, 63 bytes

lambda s,m:'\n'.join((s-x)/2*' '+x*'v'for x in range(s,m*2,-2))


# Turtlèd, 53 bytes

@v?,:l[v,l][ [ l]rr[ d,ur]ld' l]?<:d[ [ u]d[ ' d]luu]


## Explanation:

@v,           set char var to v, write it to cell

?:l        take positive int input, move that many character right, move 1 left

[v,l]   move left back to the v, writing v on all the cells it goes on

[                   ]                      until the current cell is a space

[ l]    move left until finding a space
rr  move two right

[     ]  until cell is a space
d,ur   move down, write v, move up and right

ld' l    move left, down, write space

[end of big loop]

[that part made the "icicle", the next melts some]

?<:
Take integer input again,
rotate counterclockwise, move that number right (now up the icicle)

d      move down
[               ] until cell is space
[ u]d   up until space is found, down 1
[ ' d]  until space is found, write space to cell and move down
luu    move left, up, up
[end loop]


## Java, 138 137 bytes

void m(int l,int r){int f=l;do{String v="";for(int i=0;i++<l;v+="v");if(l/2<r)break;System.out.printf("%"+f--+"s%n",v);l-=2;}while(l>0);}


Ungolfed:

void m(int l, int r) {
int f = l;
do {
String v = "";
for (int i = 0; i++ < l; v += "v");
if (l / 2 < r) break;
System.out.printf("%" + f-- + "s%n", v);
l -= 2;
} while (l > 0);
}


Update: One byte and loop body gone thanks to @ClaytonRamsey.

• You can cut down on one byte if you rewrite the for-loop as for(int i=0;i++<l;v+="v"); Nov 27, 2016 at 3:34

# C, 83 bytes

i,j;f(s,m){for(i=-1;i++<s/2-m;)for(j=-1;++j<=s;)putchar(j<s?j>=i&&s-j>i?86:32:10);}


Ungolfed and usage:

i,j;
f(s,m){
for(i=-1;i++<s/2-m;)
for(j=-1;++j<=s;)
putchar(j<s ?
j>=i&&s-j>i ? 86 : 32
: 10);
}

main() {

f(5,0);
f(7,0);
f(7,2);
f(7,3);
f(3,1);

}


# Pyth, 21 bytes

j<E.e+*kd*hyb\v_Uh/Q2


A program that takes input of S followed by M, newline-separated, and prints the result.

Test suite

How it works

j<E.e+*kd*hyb\v_Uh/Q2  Program. Inputs: Q, E
/Q2  Yield Q // 2
h      + 1
U      Yield [0, 1, 2, ..., Q //2 +1]
_       Reverse
.e                  Map over with elements as b and zero-indexed indices as k:
yb           2 * b
h              + 1
*   \v          "v" characters
+                  prepended with
k                k
* d                spaces
<E                    All but the last E elements
j                      Join on newlines
Implicitly print