Skip to content

Commit

Permalink
Created Erlang solution (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Optimissedit authored Jul 4, 2022
1 parent e147ffa commit 9748568
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Erlang/optimissedit.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-module(optimissedit).
-export([coffee_to_code/0]).

% Initial Function to create the Coffee str
coffee_to_code() ->
Coffee = "Coffee",
io:format("~n~p ->", [Coffee]),
coffee_to_code(Coffee).

% Split coffee into substrings
coffee_to_code(C) ->
Head = string:substr(C,1,2),
Len = string:length(C),
Tail = string:substr(C, Len - 1, 1),
coffee_to_code(Head, Tail).

% Recombine substrings with a new character in the middle
coffee_to_code(H, T) ->
Half = string:concat(H, "d"),
Full = string:concat(Half, T),
io:format("~n~p\n", [Full]).

0 comments on commit 9748568

Please sign in to comment.