Skip to content

Instantly share code, notes, and snippets.

@cnovoab
Last active August 31, 2015 20:03
Show Gist options
  • Save cnovoab/07c5870295b95241e4fa to your computer and use it in GitHub Desktop.
Save cnovoab/07c5870295b95241e4fa to your computer and use it in GitHub Desktop.
String name = new String("silas");
Integer suffix = new Integer(10);
name.reverse().append(suffix.toString());
@svasquezm
Copy link

I've ported this code to Ruby

lazhash = {
  0 => 'zero',
  1 =>  'one',
  2 =>  'two',
  3 =>  'three',
  4 =>  'four',
  5 =>  'five',
  6 => 'six',
  7 => 'seven',
  8 => 'eight',
  9 => 'nine',
  10 => 'ten'
}
puts "silas".reverse+lazhash[10]

@jplazcano87
Copy link

I've ported this code to Objective-C

//
//  main.m
//  salisten
//
//  Created by Inzpiral on 8/28/15.
//  Copyright (c) 2015 Inzpiral. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
  @autoreleasepool {
    NSString * name =@"silas";
    NSMutableDictionary *lazDictionary               = [[NSMutableDictionary alloc] init];
    [lazDictionary setObject:@"ten" forKey:@"10"];
    NSMutableString *reversedString = [NSMutableString string];
    NSInteger charIndex = [name length];
    while (charIndex > 0) {
      charIndex--;
      NSRange subStrRange = NSMakeRange(charIndex, 1);
      [reversedString appendString:[name substringWithRange:subStrRange]];
    }
    NSString *result = [NSString stringWithFormat:@"%@%@", reversedString, [lazDictionary objectForKey:@"10"]];
    NSLog(@"%@", result);
  }
  return 0;
}

@cnovoab
Copy link
Author

cnovoab commented Aug 28, 2015

PHP version:

$name = "silas";
$laz_assoc_array = array( "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten");
echo  strrev($name) . $laz_assoc_array[10];

@cnovoab
Copy link
Author

cnovoab commented Aug 31, 2015

JS:

var name = "silas";
var laz_array = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
alert(name.split("").reverse().join("") + laz_array[10]);

@cnovoab
Copy link
Author

cnovoab commented Aug 31, 2015

Bash port:

#!/bin/bash
name="silas"
laz_array=("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten")
reversed_name=$(echo $name | rev)
echo "$reversed_name${laz_array[10]}"

@svasquezm
Copy link

Other approach can be using random chars until we get the "SALISTEN" word

i = 0
salisten_word = "SALISTEN"
word = ""

while salisten_word != word
 random_char = 65.+(rand(25)).chr
 puts word + random_char
 if random_char == salisten_word[i]
  word = word + random_char
  i = i + 1
  next
 end
end

The results you can get are:
E
A
Q
C
S
SD
SW
ST
SH
SM
SE
SW
SP
SI
SN
SW
SI
SM
SA
SAA
SAH
SAN
SAY
SAG
SAJ
SAK
SAV
SAA
SAG
SAP
SAL
SALY
SALV
SALG
SALF
SALU
SALP
SALH
SALE
SALI
SALIK
SALIX
SALIB
SALIE
SALIO
SALIX
SALIY
SALIU
SALIR
SALIK
SALIN
SALIF
SALIQ
SALIH
SALIT
SALIY
SALIE
SALIY
SALIT
SALIV
SALIN
SALIL
SALIO
SALIS
SALISY
SALISO
SALISQ
SALISP
SALISH
SALISE
SALISO
SALISL
SALISL
SALISX
SALISP
SALISF
SALISQ
SALISX
SALISO
SALISS
SALISE
SALISG
SALISD
SALISD
SALISF
SALISA
SALISB
SALISX
SALISP
SALISV
SALISV
SALISG
SALISC
SALISW
SALISL
SALISX
SALISB
SALISL
SALISO
SALISE
SALISG
SALISB
SALISP
SALISD
SALISG
SALISM
SALISG
SALISL
SALISH
SALISI
SALISJ
SALISS
SALISG
SALISQ
SALISL
SALISI
SALISF
SALISF
SALISJ
SALIST
SALISTK
SALISTG
SALISTA
SALISTS
SALISTE
SALISTEW
SALISTER
SALISTEP
SALISTEQ
SALISTEN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment