Last active
October 25, 2018 21:24
-
-
Save najibghadri/678e04b915277a90ddfce1ff84afbfe1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(khf1). | |
-author('najibg96@gmail.com'). | |
-vsn('2017-10-17'). | |
-export([cella/2]). | |
dsdsad | |
cella(S, I) when I =< length(S), I >= 0 -> | |
M = length(S), | |
K = trunc(math:sqrt(M)), | |
IS = (((I-1) div K) * K) + 1, | |
JS = (((I-1) rem K) * K) + 1, | |
SL = lists:sublist(S, IS, K), | |
lists:flatten(transpose([lists:sublist(L, JS, K) || L <- SL])). | |
transpose([[]|_]) -> []; | |
transpose(M) -> | |
[lists:map(fun hd/1, M) | transpose(lists:map(fun tl/1, M))]. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment