Skip to main content
added hourglass and saved some bytes
Source Link
corvus_192
  • 5.9k
  • 16
  • 26

Scala, 4444 30 bytes (5151 45 without asterisk, 41 for the bountyhourglass)

With##With asterisk in code (4430 bytes):

(ni:Int)=>(i to(""+'*')*n1,-1).scanLeft("")map(_+_"*"*).tail //create a range from i to 1 and map each number to that number of asterisks 

Without##Without asterisk (5145 bytes):

Seq.fill(_i:Int)=>(i to(41+11,-1)toChar).scanLeftmap("")(_+_(41+1)tail.toChar+"")*) //same as above, but without a literal asterisk 

Without##Without asterisk and easy ways of calculating 42 (6257 bytes):

Seq.fill(_i:Int)=>(i to(1,-1))map(((math sqrt("7G"##)toChar).scanLeft(""toChar+"")(_+_*)tail 

## is the hashcode method, which returns 1764 for the string "7G", the square root of 1764 is 42, the ascii code for *

##Hourglass:

(& :Int)=>((&to(1,-1))++(2 to&))map("*"*) (& :Int)=> //define an anonymus function with an int parameter called & ( (& to (1,-1)) //a range from & to 1, counting by -1, aka downwards ++ //concat (2 to&) //a range from 2 to & ) map( //map each number to "*" * //the string "*" repeated x times ) 

Scala, 44 bytes (51 for the bounty)

With asterisk in code (44 bytes):

(n:Int)=>((""+'*')*n).scanLeft("")(_+_).tail 

Without asterisk (51 bytes):

Seq.fill(_:Int)((41+1)toChar).scanLeft("")(_+_)tail 

Without asterisk and easy ways of calculating 42 (62 bytes):

Seq.fill(_:Int)(math sqrt("7G"##)toChar).scanLeft("")(_+_)tail 

## is the hashcode method, which returns 1764 for the string "7G", the square root of 1764 is 42, the ascii code for *

Scala, 44 30 bytes (51 45 without asterisk, 41 for hourglass)

##With asterisk in code (30 bytes):

(i:Int)=>(i to(1,-1))map("*"*) //create a range from i to 1 and map each number to that number of asterisks 

##Without asterisk (45 bytes):

(i:Int)=>(i to(1,-1))map(((41+1).toChar+"")*) //same as above, but without a literal asterisk 

##Without asterisk and easy ways of calculating 42 (57 bytes):

(i:Int)=>(i to(1,-1))map(((math sqrt("7G"##)).toChar+"")*) 

## is the hashcode method, which returns 1764 for the string "7G", the square root of 1764 is 42, the ascii code for *

##Hourglass:

(& :Int)=>((&to(1,-1))++(2 to&))map("*"*) (& :Int)=> //define an anonymus function with an int parameter called & ( (& to (1,-1)) //a range from & to 1, counting by -1, aka downwards ++ //concat (2 to&) //a range from 2 to & ) map( //map each number to "*" * //the string "*" repeated x times ) 
added 123 characters in body; edited body
Source Link
corvus_192
  • 5.9k
  • 16
  • 26

Scala, 44 bytes (6251 for the bounty)

With asterisk in code (44 bytes):

(n:Int)=>((""+'*')*n).scanLeft("")(_+_).tail 

Without asterisk (51 bytes):

Seq.fill(_:Int)((41+1)toChar).scanLeft("")(_+_)tail 

Without asterisk and easy ways of calculating 42 (62 bytes):

Seq.fill(_:Int)(math sqrt("7G"##)toChar).scanLeft("")(_+_)tail 

## is the hashcode method, which returns 1764 for the string "7G", the square root of 1764 is 42, the ascii code for *

Scala, 44 bytes (62 for the bounty)

With asterisk in code (44 bytes):

(n:Int)=>((""+'*')*n).scanLeft("")(_+_).tail 

Without asterisk (62 bytes):

Seq.fill(_:Int)(math sqrt("7G"##)toChar).scanLeft("")(_+_)tail 

## is the hashcode method, which returns 1764 for the string "7G", the square root of 1764 is 42, the ascii code for *

Scala, 44 bytes (51 for the bounty)

With asterisk in code (44 bytes):

(n:Int)=>((""+'*')*n).scanLeft("")(_+_).tail 

Without asterisk (51 bytes):

Seq.fill(_:Int)((41+1)toChar).scanLeft("")(_+_)tail 

Without asterisk and easy ways of calculating 42 (62 bytes):

Seq.fill(_:Int)(math sqrt("7G"##)toChar).scanLeft("")(_+_)tail 

## is the hashcode method, which returns 1764 for the string "7G", the square root of 1764 is 42, the ascii code for *

deleted 2 characters in body
Source Link
corvus_192
  • 5.9k
  • 16
  • 26

Scala, 44 bytes (5362 for the bounty)

With asterisk in code (44 bytes):

(n:Int)=>((""+'*')*n).scanLeft("")(_+_).tail 

Without asterisk (6462 bytes):

Seq.fill(_:Int)(math sqrt("7G"##)toChar).scanLeft("")(_ + __+_)tail 

## is the hashcode method, which returns 1764 for the string "7G", the square root of 1764 is 42, the ascii code for *

Scala, 44 bytes (53 for the bounty)

With asterisk in code (44 bytes):

(n:Int)=>((""+'*')*n).scanLeft("")(_+_).tail 

Without asterisk (64 bytes):

Seq.fill(_:Int)(math sqrt("7G"##)toChar).scanLeft("")(_ + _)tail 

## is the hashcode method, which returns 1764 for the string "7G", the square root of 1764 is 42, the ascii code for *

Scala, 44 bytes (62 for the bounty)

With asterisk in code (44 bytes):

(n:Int)=>((""+'*')*n).scanLeft("")(_+_).tail 

Without asterisk (62 bytes):

Seq.fill(_:Int)(math sqrt("7G"##)toChar).scanLeft("")(_+_)tail 

## is the hashcode method, which returns 1764 for the string "7G", the square root of 1764 is 42, the ascii code for *

added 132 characters in body
Source Link
corvus_192
  • 5.9k
  • 16
  • 26
Loading
edited body
Source Link
corvus_192
  • 5.9k
  • 16
  • 26
Loading
Source Link
corvus_192
  • 5.9k
  • 16
  • 26
Loading